Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbe2dfbd82 | ||
|
|
5442a2e5fe | ||
|
|
58b4d8c84f | ||
|
|
f5c6c8a072 | ||
|
|
9d5ab4a2d6 | ||
|
|
32f704459f | ||
|
|
e4795182ca | ||
|
|
3297dbdaab | ||
|
|
a65a5985e6 | ||
|
|
77eac494ad | ||
|
|
4498f59607 | ||
|
|
6322913310 | ||
|
|
be2f34a045 | ||
|
|
cce0c89168 | ||
|
|
58cc197c89 | ||
|
|
bbb6d0eda9 | ||
|
|
c03068f0ec | ||
|
|
e8f352930d | ||
|
|
bf2c560db5 | ||
|
|
63189a6196 | ||
|
|
9990690332 | ||
|
|
ee163cc342 | ||
|
|
cf27f7e11b | ||
|
|
12986865c8 | ||
|
|
aac0fc741a | ||
|
|
c33f95d64b | ||
|
|
eb7255b34f | ||
|
|
3982798d5e | ||
|
|
ded1ebd4e7 | ||
|
|
c261d4e333 | ||
|
|
7b1400e238 | ||
|
|
7c2048bc6b | ||
|
|
2b1d5664fe | ||
|
|
5403686e20 | ||
|
|
e90c72fc8b | ||
|
|
1910ef54a4 | ||
|
|
45686f9482 | ||
|
|
a6b0d214af | ||
|
|
2a1a2a936b | ||
|
|
060275d1ae | ||
|
|
abb54d2538 | ||
|
|
98fc472a40 | ||
|
|
4034429042 | ||
|
|
ca212b8736 | ||
|
|
4c2593629d | ||
|
|
612d85ca2a | ||
|
|
b25b92dddc | ||
|
|
f01376ebe1 | ||
|
|
03acde19b8 | ||
|
|
1de533ca9c | ||
|
|
ce2037400c | ||
|
|
379fe12979 | ||
|
|
a285f53753 | ||
|
|
ed36eed112 | ||
|
|
ddf6f574f6 | ||
|
|
4f7c4e8b4e | ||
|
|
f2a82ddd0f | ||
|
|
3cec316683 | ||
|
|
c23b5e674b | ||
|
|
8bf8222c31 | ||
|
|
0c19e966cc | ||
|
|
9fbda5a6e0 | ||
|
|
3d7d39073f | ||
|
|
ae26aebdf8 | ||
|
|
c43f442fb9 | ||
|
|
f97a6d0418 | ||
|
|
7cd2fa5f6a | ||
|
|
6015552aab | ||
|
|
8748c02b20 | ||
|
|
6e04d4aa93 | ||
|
|
4a955f7b77 | ||
|
|
227143728d | ||
|
|
7330555c37 |
+3
-1
@@ -1,4 +1,4 @@
|
||||
30
|
||||
31
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
@@ -23,3 +23,5 @@
|
||||
4.7.2
|
||||
4.9.2
|
||||
4.11.2
|
||||
|
||||
4.16.2
|
||||
@@ -1,5 +1,71 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.17.1 Jul 5, 2021
|
||||
|
||||
Upgrade priority: Low. Allows cleaner access to multiple `.at` queries via new API.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Added `Emergency` to `ElectionPhase` (Thanks to https://github.com/arjanz)
|
||||
|
||||
Changes:
|
||||
|
||||
- Added `await api.at(<blockHash>)` to retrieve API instances at a point
|
||||
- Added `fallbackType` for type classes (only struct, as defined)
|
||||
- Allow `instances` API config to drive derive collective locations
|
||||
- Ensure correct registry is attached to historic metadata
|
||||
- Align static metadata with latest Substrate
|
||||
|
||||
|
||||
## 4.16.2 Jun 27, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for Polkadot with runtime >= 9050.
|
||||
|
||||
Changes:
|
||||
|
||||
- Correct `CompactAssignments` & `RawSolution` types for Polkadot
|
||||
|
||||
|
||||
## 4.16.1 Jun 26, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for full from-genesis queries on Kusama.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust types for uniques (Thanks to https://github.com/Yuripetusko)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add Kusama, Polkadot & Westend 9050 upgrade blocks
|
||||
- Add Kusama & Westend 9070 upgrade blocks
|
||||
- Adjust API decoration to lazy-create event and storage types
|
||||
- Use TS `override` as applicable (with `--noImplicitOverrides` option)
|
||||
- Add missing historic `Heartbeat: HeartbeatTo244` mapping to Kusama
|
||||
- Remove duplication from contracts registry
|
||||
- Add explicit check for scale-info 0.7+ (contracts index lookups)
|
||||
- Align static metadata with latest Substrate
|
||||
|
||||
|
||||
## 4.15.1 Jun 19, 2021
|
||||
|
||||
Upgrade priority: Medium. Recommended for all chains where Xcm is used (addition of new `XcmOrigin`)
|
||||
|
||||
Contributed:
|
||||
|
||||
- Added `ChargeAssetTxPayment` extension (Thanks to https://github.com/apopiak)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for type decoding of nested fixed vectors, tuples and structs
|
||||
- Added `childstate_getKeysPaged` RPC
|
||||
- Add `XcmOrigin` mapping for `OriginCaller` generation
|
||||
- Align static metadata with latest Substrate
|
||||
- Adjust error message for contracts V3 (extrinsic from runtime)
|
||||
- Correct module optionality in `api.derive.balances.account`
|
||||
- Add alias for `GenericAddress` -> `GenericMultiAddress`
|
||||
- Adjust metadata doc generation (keep spaces between subsequent lines)
|
||||
|
||||
|
||||
## 4.14.1 Jun 14, 2021
|
||||
|
||||
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
|
||||
|
||||
+1
-1
@@ -27,6 +27,6 @@ module.exports = {
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
],
|
||||
testTimeout: 10000,
|
||||
testTimeout: 30000,
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
||||
};
|
||||
|
||||
+7
-7
@@ -8,7 +8,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.3.2"
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -20,19 +20,19 @@
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "polkadot-dev-run-test --coverage --detectOpenHandles --forceExit --runInBand --testPathIgnorePatterns e2e",
|
||||
"test": "polkadot-dev-run-test --coverage --forceExit --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.5",
|
||||
"@babel/core": "^7.14.6",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.5",
|
||||
"@polkadot/dev": "^0.62.42",
|
||||
"@polkadot/ts": "^0.3.90",
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/dev": "^0.62.44",
|
||||
"@polkadot/ts": "^0.4.2",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.23",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "4.14.1"
|
||||
"version": "4.17.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
@@ -19,10 +19,10 @@
|
||||
"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.14.5",
|
||||
"@polkadot/api": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api": "4.17.1",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/x-rxjs": "^6.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ function findMessage <T extends AbiMessage> (list: T[], messageOrId: T | string
|
||||
? list.find(({ identifier }) => [identifier, stringCamelCase(identifier)].includes(messageOrId.toString()))
|
||||
: messageOrId;
|
||||
|
||||
return assertReturn(message, `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
|
||||
return assertReturn(message, () => `Attempted to call an invalid contract interface, ${stringify(messageOrId)}`);
|
||||
}
|
||||
|
||||
export class Abi {
|
||||
@@ -127,7 +127,7 @@ export class Abi {
|
||||
const args = this.#createArgs(spec.args, spec);
|
||||
const event = {
|
||||
args,
|
||||
docs: spec.docs.map((doc) => doc.toString()),
|
||||
docs: spec.docs.map((d) => d.toString()),
|
||||
fromU8a: (data: Uint8Array): DecodedEvent => ({
|
||||
args: this.#decodeArgs(args, data),
|
||||
event
|
||||
@@ -145,7 +145,7 @@ export class Abi {
|
||||
const message = {
|
||||
...add,
|
||||
args,
|
||||
docs: spec.docs.map((doc) => doc.toString()),
|
||||
docs: spec.docs.map((d) => d.toString()),
|
||||
fromU8a: (data: Uint8Array): DecodedMessage => ({
|
||||
args: this.#decodeArgs(args, data),
|
||||
message
|
||||
|
||||
@@ -35,8 +35,10 @@ export class MetaRegistry extends TypeRegistry {
|
||||
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
|
||||
super();
|
||||
|
||||
// type indexes are 1-based pre-1.0 and 0-based post-1.0
|
||||
this.typeOffset = metadataVersion.split('.')[0] === '0' ? 1 : 0;
|
||||
const [major, minor] = metadataVersion.split('.').map((n) => parseInt(n, 10));
|
||||
|
||||
// type indexes are 1-based pre 0.7 and 0-based post
|
||||
this.typeOffset = (major === 0 && minor < 7) ? 1 : 0;
|
||||
|
||||
if (chainProperties) {
|
||||
this.setChainProperties(chainProperties);
|
||||
@@ -124,7 +126,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
: {}
|
||||
),
|
||||
...(path.length > 1
|
||||
? { namespace: path.map((segment) => segment.toString()).join('::') }
|
||||
? { namespace: path.map((s) => s.toString()).join('::') }
|
||||
: {}
|
||||
),
|
||||
...(type.params.length > 0
|
||||
@@ -154,15 +156,13 @@ export class MetaRegistry extends TypeRegistry {
|
||||
|
||||
assert(isTuple || isStruct, 'Invalid fields type detected, expected either Tuple or Struct');
|
||||
|
||||
const sub = fields.map(({ name, type }) => {
|
||||
return {
|
||||
...this.getMetaTypeDef({ type }),
|
||||
...(name.isSome
|
||||
? { name: name.unwrap().toString() }
|
||||
: {}
|
||||
)
|
||||
};
|
||||
});
|
||||
const sub = fields.map(({ name, type }) => ({
|
||||
...this.getMetaTypeDef({ type }),
|
||||
...(name.isSome
|
||||
? { name: name.unwrap().toString() }
|
||||
: {}
|
||||
)
|
||||
}));
|
||||
|
||||
return isTuple && sub.length === 1
|
||||
? sub[0]
|
||||
@@ -213,32 +213,28 @@ export class MetaRegistry extends TypeRegistry {
|
||||
const { params, path } = this.#getMetaType(id);
|
||||
const specialVariant = path[0].toString();
|
||||
|
||||
if (specialVariant === 'Option') {
|
||||
return {
|
||||
return specialVariant === 'Option'
|
||||
? {
|
||||
info: TypeDefInfo.Option,
|
||||
sub: this.getMetaTypeDef({ type: params[0] })
|
||||
};
|
||||
} else if (specialVariant === 'Result') {
|
||||
return {
|
||||
info: TypeDefInfo.Result,
|
||||
sub: params.map((type, index) => ({
|
||||
name: ['Ok', 'Error'][index],
|
||||
...this.getMetaTypeDef({ type })
|
||||
}))
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
info: TypeDefInfo.Enum,
|
||||
sub: this.#extractVariantSub(variants)
|
||||
};
|
||||
}
|
||||
: specialVariant === 'Result'
|
||||
? {
|
||||
info: TypeDefInfo.Result,
|
||||
sub: params.map((type, index) => ({
|
||||
name: ['Ok', 'Error'][index],
|
||||
...this.getMetaTypeDef({ type })
|
||||
}))
|
||||
}
|
||||
: {
|
||||
info: TypeDefInfo.Enum,
|
||||
sub: this.#extractVariantSub(variants)
|
||||
};
|
||||
}
|
||||
|
||||
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => {
|
||||
const isAllUnitVariants = variants.every(({ fields }) => fields.length === 0);
|
||||
|
||||
if (isAllUnitVariants) {
|
||||
return variants.map(({ discriminant, name }) => ({
|
||||
return variants.every(({ fields }) => fields.length === 0)
|
||||
? variants.map(({ discriminant, name }) => ({
|
||||
...(
|
||||
discriminant.isSome
|
||||
? { ext: { discriminant: discriminant.unwrap().toNumber() } }
|
||||
@@ -247,14 +243,10 @@ export class MetaRegistry extends TypeRegistry {
|
||||
info: TypeDefInfo.Plain,
|
||||
name: name.toString(),
|
||||
type: 'Null'
|
||||
}));
|
||||
}
|
||||
|
||||
return variants.map(({ fields, name }) =>
|
||||
withTypeString({
|
||||
}))
|
||||
: variants.map(({ fields, name }) => withTypeString({
|
||||
...this.#extractFields(fields),
|
||||
name: name.toString()
|
||||
})
|
||||
);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ export abstract class Base<ApiType extends ApiTypes> {
|
||||
this.registry = this.abi.registry;
|
||||
this._decorateMethod = decorateMethod;
|
||||
|
||||
assert(isFunction(api.rx.tx.contracts?.instantiateWithCode), 'You need to connect to a node with a V3 contracts module. Your node does not expose api.tx.contracts.instantiateWithCode on this instance');
|
||||
assert(!!(api && api.isConnected && api.tx && api.tx.contracts && Object.keys(api.tx.contracts).length), 'Your API has not been initialized correctly and it not decorated with the runtime interfaces for contracts as retrieved from the on-chain runtime');
|
||||
assert(isFunction(api.tx.contracts.instantiateWithCode), 'You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,12 @@ import { TypeRegistry } from '@polkadot/types';
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
export const mockApi = {
|
||||
isConnected: true,
|
||||
registry,
|
||||
rx: {
|
||||
tx: {
|
||||
contracts: {
|
||||
instantiateWithCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
tx: {
|
||||
contracts: {
|
||||
instantiateWithCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.17.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
@@ -19,16 +19,16 @@
|
||||
"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.14.5",
|
||||
"@polkadot/api": "4.14.1",
|
||||
"@polkadot/rpc-core": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/util-crypto": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api": "4.17.1",
|
||||
"@polkadot/rpc-core": "4.17.1",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/util-crypto": "^6.11.1",
|
||||
"@polkadot/x-rxjs": "^6.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.8.1",
|
||||
"@polkadot/rpc-provider": "4.14.1"
|
||||
"@polkadot/keyring": "^6.11.1",
|
||||
"@polkadot/rpc-provider": "4.17.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,13 +23,19 @@ type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
|
||||
}
|
||||
}
|
||||
|
||||
function zeroBalance (api: ApiInterfaceRx) {
|
||||
return api.registry.createType('Balance');
|
||||
}
|
||||
|
||||
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
|
||||
const votingBalance = api.registry.createType('Balance', freeBalance.toBn());
|
||||
|
||||
return {
|
||||
freeBalance,
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
reservedBalance,
|
||||
votingBalance: api.registry.createType('Balance', freeBalance.toBn())
|
||||
votingBalance
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,7 +61,16 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
||||
]).pipe(
|
||||
map(([freeBalance, reservedBalance, accountNonce]): Result => [
|
||||
accountNonce,
|
||||
[[freeBalance, reservedBalance, api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||
[[freeBalance, reservedBalance, zeroBalance(api), zeroBalance(api)]]
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
function querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.query.system.accountNonce<Index>(accountId).pipe(
|
||||
map((accountNonce): Result => [
|
||||
accountNonce,
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
])
|
||||
);
|
||||
}
|
||||
@@ -71,6 +86,7 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
|
||||
const extract = (data: AccountData[]) =>
|
||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
||||
|
||||
// NOTE this is for the first case where we do have instances specified
|
||||
return isFunction(api.query.system.account)
|
||||
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
|
||||
@@ -80,16 +96,27 @@ function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, module
|
||||
);
|
||||
}
|
||||
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
// AccountInfo is current, support old, eg. Edgeware
|
||||
return api.query.system.account<AccountInfo | ITuple<[Index, AccountData]>>(accountId).pipe(
|
||||
map((infoOrTuple): Result => {
|
||||
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
|
||||
const data = (infoOrTuple as AccountInfo).nonce
|
||||
? (infoOrTuple as AccountInfo).data
|
||||
: (infoOrTuple as [Index, AccountData])[1];
|
||||
|
||||
const nonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
|
||||
|
||||
if (!data || data.isEmpty) {
|
||||
return [
|
||||
nonce,
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
];
|
||||
}
|
||||
|
||||
const { feeFrozen, free, miscFrozen, reserved } = data;
|
||||
|
||||
return [
|
||||
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
|
||||
nonce,
|
||||
[[free, reserved, feeFrozen, miscFrozen]]
|
||||
];
|
||||
})
|
||||
@@ -113,6 +140,10 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
|
||||
*/
|
||||
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||
const empty: Result = [
|
||||
api.registry.createType('Index'),
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
];
|
||||
|
||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
@@ -122,19 +153,17 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
|
||||
of(accountId),
|
||||
balanceInstances
|
||||
? queryBalancesAccount(api, accountId, balanceInstances)
|
||||
: isFunction(api.query.system.account)
|
||||
? queryCurrent(api, accountId)
|
||||
: isFunction(api.query.balances.account)
|
||||
: isFunction(api.query.system?.account)
|
||||
? querySystemAccount(api, accountId)
|
||||
: isFunction(api.query.balances?.account)
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: queryBalancesFree(api, accountId)
|
||||
])
|
||||
: of([
|
||||
api.registry.createType('AccountId'),
|
||||
[
|
||||
api.registry.createType('Index'),
|
||||
[[api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance'), api.registry.createType('Balance')]]
|
||||
]
|
||||
: isFunction(api.query.balances?.freeBalance)
|
||||
? queryBalancesFree(api, accountId)
|
||||
: isFunction(api.query.system?.accountNonce)
|
||||
? querySystemNonce(api, accountId)
|
||||
: of(empty)
|
||||
])
|
||||
: of([api.registry.createType('AccountId'), empty])
|
||||
)
|
||||
),
|
||||
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
|
||||
export function getInstance (api: ApiInterfaceRx, section: string): string {
|
||||
const instances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), section);
|
||||
|
||||
return instances && instances.length
|
||||
? instances[0]
|
||||
: section;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './members';
|
||||
export * from './prime';
|
||||
export * from './proposals';
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { Collective } from './types';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { getInstance } from './getInstance';
|
||||
|
||||
export function members (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<AccountId[]> {
|
||||
const section = getInstance(api, _section);
|
||||
|
||||
return memo(instanceId, (): Observable<AccountId[]> =>
|
||||
isFunction(api.query[section]?.members)
|
||||
? api.query[section as 'council'].members()
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { getInstance } from './getInstance';
|
||||
|
||||
export function prime (instanceId: string, api: ApiInterfaceRx, _section: string): () => Observable<AccountId | null> {
|
||||
const section = getInstance(api, _section);
|
||||
|
||||
return memo(instanceId, (): Observable<AccountId | null> =>
|
||||
isFunction(api.query[section as 'council']?.prime)
|
||||
? api.query[section as 'council'].prime<Option<AccountId>>().pipe(
|
||||
map((optPrime): AccountId | null =>
|
||||
optPrime.unwrapOr(null)
|
||||
)
|
||||
)
|
||||
: of(null)
|
||||
);
|
||||
}
|
||||
@@ -2,18 +2,18 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { Option, u32 } from '@polkadot/types';
|
||||
import type { Hash, Proposal, Votes } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
import type { Collective } from './types';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { catchError, map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type Collective = 'council' | 'membership' | 'technicalCommittee';
|
||||
import { getInstance } from './getInstance';
|
||||
|
||||
type Result = [(Hash | Uint8Array | string)[], (Option<Proposal> | null)[], Option<Votes>[]];
|
||||
|
||||
@@ -31,7 +31,7 @@ function parse (api: ApiInterfaceRx, [hashes, proposals, votes]: Result): Derive
|
||||
.filter((proposal): proposal is DeriveCollectiveProposal => !!proposal);
|
||||
}
|
||||
|
||||
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: Collective): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
|
||||
function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: string): (hashes: (Hash | Uint8Array | string)[]) => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, (hashes: (Hash | Uint8Array | string)[]): Observable<DeriveCollectiveProposal[]> =>
|
||||
(isFunction(api.query[section]?.proposals) && hashes.length
|
||||
? combineLatest<Result>([
|
||||
@@ -51,19 +51,48 @@ function _proposalsFrom (instanceId: string, api: ApiInterfaceRx, section: Colle
|
||||
);
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx, section: Collective): () => Observable<DeriveCollectiveProposal[]> {
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
export function hasProposals (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<boolean> {
|
||||
const section = getInstance(api, _section);
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
|
||||
isFunction(api.query[section]?.proposals)
|
||||
? api.query[section as 'council'].proposals().pipe(
|
||||
switchMap(proposalsFrom)
|
||||
)
|
||||
: of([] as DeriveCollectiveProposal[])
|
||||
return memo(instanceId, (): Observable<boolean> =>
|
||||
of(isFunction(api.query[section]?.proposals))
|
||||
);
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx, section: Collective): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
export function proposalCount (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<u32 | null> {
|
||||
const section = getInstance(api, _section);
|
||||
|
||||
return memo(instanceId, (): Observable<u32 | null> =>
|
||||
isFunction(api.query[section].proposalCount)
|
||||
? api.query[section as 'council'].proposalCount()
|
||||
: of(null)
|
||||
);
|
||||
}
|
||||
|
||||
export function proposalHashes (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<Hash[]> {
|
||||
const section = getInstance(api, _section);
|
||||
|
||||
return memo(instanceId, (): Observable<Hash[]> =>
|
||||
isFunction(api.query[section]?.proposals)
|
||||
? api.query[section as 'council'].proposals()
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx, _section: Collective): () => Observable<DeriveCollectiveProposal[]> {
|
||||
const section = getInstance(api, _section);
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
const getHashes = proposalHashes(instanceId, api, _section);
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveCollectiveProposal[]> =>
|
||||
getHashes().pipe(
|
||||
switchMap(proposalsFrom)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx, _section: Collective): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
const section = getInstance(api, _section);
|
||||
const proposalsFrom = _proposalsFrom(instanceId, api, section);
|
||||
|
||||
return memo(instanceId, (hash: Hash | Uint8Array | string): Observable<DeriveCollectiveProposal | null> =>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export type Collective = 'council' | 'membership' | 'technicalCommittee';
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './members';
|
||||
export * from './prime';
|
||||
export * from './proposals';
|
||||
export * from './votes';
|
||||
export * from './votesOf';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { members as collectiveMembers } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function members (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
||||
return memo(instanceId, collectiveMembers(instanceId, api, 'council'));
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { prime as collectivePrime } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function prime (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId | null> {
|
||||
return memo(instanceId, collectivePrime(instanceId, api, 'council'));
|
||||
}
|
||||
@@ -2,17 +2,30 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { u32 } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { proposal as collectiveProposal, proposals as collectiveProposals } from '../collective';
|
||||
import { hasProposals as collectiveHasProposals, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function hasProposals (instanceId: string, api: ApiInterfaceRx): () => Observable<boolean> {
|
||||
return memo(instanceId, collectiveHasProposals(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
return memo(instanceId, collectiveProposal(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
export function proposalCount (instanceId: string, api: ApiInterfaceRx): () => Observable<u32 | null> {
|
||||
return memo(instanceId, collectiveProposalCount(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
export function proposalHashes (instanceId: string, api: ApiInterfaceRx): () => Observable<Hash[]> {
|
||||
return memo(instanceId, collectiveProposalHashes(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, collectiveProposals(instanceId, api, 'council'));
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx, QueryableModuleStorage } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { AccountId, Balance, Voter } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCouncilVote, DeriveCouncilVotes } from '../types';
|
||||
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
@@ -20,24 +20,27 @@ function isVoter (value: VoteEntry): value is Voter {
|
||||
return !Array.isArray(value);
|
||||
}
|
||||
|
||||
function retrieveStakeOf (api: ApiInterfaceRx): Observable<[AccountId, Balance][]> {
|
||||
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||
function retrieveStakeOf (elections: QueryableModuleStorage<'rxjs'>): Observable<[AccountId, Balance][]> {
|
||||
return elections.stakeOf.entries<Balance, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([{ args: [accountId] }, stake]) => [accountId, stake])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveVoteOf (api: ApiInterfaceRx): Observable<[AccountId, AccountId[]][]> {
|
||||
return (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
function retrieveVoteOf (elections: QueryableModuleStorage<'rxjs'>): Observable<[AccountId, AccountId[]][]> {
|
||||
return elections.votesOf.entries<Vec<AccountId>, [AccountId]>().pipe(
|
||||
map((entries) =>
|
||||
entries.map(([{ args: [accountId] }, votes]) => [accountId, votes])
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
return combineLatest([retrieveStakeOf(api), retrieveVoteOf(api)]).pipe(
|
||||
function retrievePrev (api: ApiInterfaceRx, elections: QueryableModuleStorage<'rxjs'>): Observable<DeriveCouncilVotes> {
|
||||
return combineLatest([
|
||||
retrieveStakeOf(elections),
|
||||
retrieveVoteOf(elections)
|
||||
]).pipe(
|
||||
map(([stakes, votes]): DeriveCouncilVotes => {
|
||||
const result: DeriveCouncilVotes = [];
|
||||
|
||||
@@ -60,9 +63,7 @@ function retrievePrev (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
const elections = (api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections);
|
||||
|
||||
function retrieveCurrent (elections: QueryableModuleStorage<'rxjs'>): Observable<DeriveCouncilVotes> {
|
||||
return elections.voting.entries<VoteEntry, [AccountId]>().pipe(
|
||||
map((entries): DeriveCouncilVotes =>
|
||||
entries.map(([{ args: [accountId] }, value]): [AccountId, DeriveCouncilVote] => [
|
||||
@@ -76,9 +77,13 @@ function retrieveCurrent (api: ApiInterfaceRx): Observable<DeriveCouncilVotes> {
|
||||
}
|
||||
|
||||
export function votes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCouncilVotes> {
|
||||
const elections = api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections;
|
||||
|
||||
return memo(instanceId, (): Observable<DeriveCouncilVotes> =>
|
||||
(api.query.phragmenElection || api.query.electionsPhragmen || api.query.elections).stakeOf
|
||||
? retrievePrev(api)
|
||||
: retrieveCurrent(api)
|
||||
elections
|
||||
? elections.stakeOf
|
||||
? retrievePrev(api, elections)
|
||||
: retrieveCurrent(elections)
|
||||
: of([])
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveElectionsInfo } from './types';
|
||||
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
@@ -42,30 +43,48 @@ function sortAccounts ([, balanceA]: [AccountId, Balance], [, balanceB]: [Accoun
|
||||
}
|
||||
|
||||
function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
const section = api.query.phragmenElection
|
||||
const elections = api.query.phragmenElection
|
||||
? 'phragmenElection'
|
||||
: api.query.electionsPhragmen
|
||||
? 'electionsPhragmen'
|
||||
: 'elections';
|
||||
: api.query.elections
|
||||
? 'elections'
|
||||
: null;
|
||||
const [council] = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'council') || ['council'];
|
||||
|
||||
return api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||
api.query.council.members,
|
||||
api.query[section].candidates,
|
||||
api.query[section].members,
|
||||
api.query[section].runnersUp
|
||||
]).pipe(
|
||||
return (
|
||||
elections
|
||||
? api.queryMulti<[Vec<AccountId>, Vec<Candidate>, Vec<Member>, Vec<Member>]>([
|
||||
api.query[council].members,
|
||||
api.query[elections].candidates,
|
||||
api.query[elections].members,
|
||||
api.query[elections].runnersUp
|
||||
])
|
||||
: combineLatest<[Vec<AccountId>, Candidate[], Member[], Member[]]>([
|
||||
api.query[council].members(),
|
||||
of([]),
|
||||
of([]),
|
||||
of([])
|
||||
])
|
||||
).pipe(
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
...(
|
||||
elections
|
||||
? {
|
||||
candidacyBond: api.consts[elections].candidacyBond as Balance,
|
||||
desiredRunnersUp: api.consts[elections].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[elections].desiredMembers as u32,
|
||||
termDuration: api.consts[elections].termDuration as BlockNumber,
|
||||
votingBond: api.consts[elections].votingBond as Balance
|
||||
}
|
||||
: {}
|
||||
),
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates: candidates.map(getCandidate),
|
||||
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.length
|
||||
? members.map(getAccountTuple).sort(sortAccounts)
|
||||
: councilMembers.map((accountId): [AccountId, Balance] => [accountId, api.registry.createType('Balance')]),
|
||||
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts),
|
||||
termDuration: api.consts[section].termDuration as BlockNumber,
|
||||
votingBond: api.consts[section].votingBond as Balance
|
||||
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts)
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ export interface DeriveElectionsInfo {
|
||||
candidates: AccountId[];
|
||||
candidateCount: u32;
|
||||
candidacyBond?: Balance;
|
||||
desiredRunnersUp: u32;
|
||||
desiredSeats: u32;
|
||||
desiredRunnersUp?: u32;
|
||||
desiredSeats?: u32;
|
||||
members: [AccountId, Balance][];
|
||||
nextVoterSet?: SetIndex;
|
||||
runnersUp: [AccountId, Balance][];
|
||||
termDuration: BlockNumber;
|
||||
termDuration?: BlockNumber;
|
||||
voteCount?: VoteIndex;
|
||||
voterCount?: SetIndex;
|
||||
votingBond?: Balance;
|
||||
|
||||
@@ -28,6 +28,11 @@ import * as tx from './tx';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export * from './type';
|
||||
|
||||
interface Avail {
|
||||
instances: string[];
|
||||
withDetect?: boolean;
|
||||
}
|
||||
|
||||
export const derive = { accounts, balances, bounties, chain, contracts, council, democracy, elections, imOnline, membership, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
|
||||
type DeriveSection<Section> = {
|
||||
@@ -44,19 +49,19 @@ export type DeriveCustom = Record<string, Record<string, (instanceId: string, ap
|
||||
export type ExactDerive = DeriveAllSections<typeof derive>;
|
||||
|
||||
// Enable derive only if some of these modules are available
|
||||
const deriveAvail: Record<string, string[]> = {
|
||||
contracts: ['contracts'],
|
||||
council: ['council'],
|
||||
democracy: ['democracy'],
|
||||
elections: ['phragmenElection', 'electionsPhragmen', 'elections'],
|
||||
imOnline: ['imOnline'],
|
||||
membership: ['membership'],
|
||||
parachains: ['parachains', 'registrar'],
|
||||
session: ['session'],
|
||||
society: ['society'],
|
||||
staking: ['staking'],
|
||||
technicalCommittee: ['technicalCommittee'],
|
||||
treasury: ['treasury']
|
||||
const deriveAvail: Record<string, Avail> = {
|
||||
contracts: { instances: ['contracts'] },
|
||||
council: { instances: ['council'], withDetect: true },
|
||||
democracy: { instances: ['democracy'] },
|
||||
elections: { instances: ['phragmenElection', 'electionsPhragmen', 'elections', 'council'], withDetect: true },
|
||||
imOnline: { instances: ['imOnline'] },
|
||||
membership: { instances: ['membership'] },
|
||||
parachains: { instances: ['parachains', 'registrar'] },
|
||||
session: { instances: ['session'] },
|
||||
society: { instances: ['society'] },
|
||||
staking: { instances: ['staking'] },
|
||||
technicalCommittee: { instances: ['technicalCommittee'], withDetect: true },
|
||||
treasury: { instances: ['treasury'] }
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -66,11 +71,19 @@ const deriveAvail: Record<string, string[]> = {
|
||||
/** @internal */
|
||||
function injectFunctions<AllSections> (instanceId: string, api: ApiInterfaceRx, allSections: AllSections): DeriveAllSections<AllSections> {
|
||||
const queryKeys = Object.keys(api.query);
|
||||
const specName = api.runtimeVersion.specName.toString();
|
||||
|
||||
return Object
|
||||
.keys(allSections)
|
||||
.filter((sectionName): boolean =>
|
||||
!deriveAvail[sectionName] || deriveAvail[sectionName].some((query): boolean => queryKeys.includes(query))
|
||||
.filter((sectionName) =>
|
||||
!deriveAvail[sectionName] ||
|
||||
deriveAvail[sectionName].instances.some((q) => queryKeys.includes(q)) ||
|
||||
(
|
||||
deriveAvail[sectionName].withDetect &&
|
||||
deriveAvail[sectionName].instances.some((q) =>
|
||||
(api.registry.getModuleInstances(specName, q) || []).some((q) => queryKeys.includes(q))
|
||||
)
|
||||
)
|
||||
)
|
||||
.reduce((deriveAcc, sectionName): DeriveAllSections<AllSections> => {
|
||||
const section = allSections[sectionName as keyof AllSections];
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './members';
|
||||
export * from './prime';
|
||||
export * from './proposals';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { members as collectiveMembers } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function members (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
||||
return memo(instanceId, collectiveMembers(instanceId, api, 'membership'));
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { prime as collectivePrime } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function prime (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId | null> {
|
||||
return memo(instanceId, collectivePrime(instanceId, api, 'membership'));
|
||||
}
|
||||
@@ -2,12 +2,30 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { u32 } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { proposals as collectiveProposals } from '../collective';
|
||||
import { hasProposals as collectiveHasProposals, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function hasProposals (instanceId: string, api: ApiInterfaceRx): () => Observable<boolean> {
|
||||
return memo(instanceId, collectiveHasProposals(instanceId, api, 'membership'));
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
return memo(instanceId, collectiveProposal(instanceId, api, 'membership'));
|
||||
}
|
||||
|
||||
export function proposalCount (instanceId: string, api: ApiInterfaceRx): () => Observable<u32 | null> {
|
||||
return memo(instanceId, collectiveProposalCount(instanceId, api, 'membership'));
|
||||
}
|
||||
|
||||
export function proposalHashes (instanceId: string, api: ApiInterfaceRx): () => Observable<Hash[]> {
|
||||
return memo(instanceId, collectiveProposalHashes(instanceId, api, 'membership'));
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, collectiveProposals(instanceId, api, 'membership'));
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.17.1' };
|
||||
|
||||
@@ -120,8 +120,6 @@ function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][
|
||||
return false;
|
||||
}
|
||||
|
||||
reward.isStakerPayout = true;
|
||||
|
||||
removeClaimed(validators, queryValidators, reward);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -81,7 +81,6 @@ export interface DeriveStakerRewardValidator {
|
||||
export interface DeriveStakerReward {
|
||||
era: EraIndex;
|
||||
eraReward: Balance;
|
||||
isStakerPayout?: boolean;
|
||||
isEmpty: boolean;
|
||||
isValidator: boolean;
|
||||
nominating: DeriveEraExposureNominating[];
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export * from './members';
|
||||
export * from './prime';
|
||||
export * from './proposals';
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { members as collectiveMembers } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function members (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
|
||||
return memo(instanceId, collectiveMembers(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { prime as collectivePrime } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function prime (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId | null> {
|
||||
return memo(instanceId, collectivePrime(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
@@ -2,12 +2,30 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { u32 } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveCollectiveProposal } from '../types';
|
||||
|
||||
import { proposals as collectiveProposals } from '../collective';
|
||||
import { hasProposals as collectiveHasProposals, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective';
|
||||
import { memo } from '../util';
|
||||
|
||||
export function hasProposals (instanceId: string, api: ApiInterfaceRx): () => Observable<boolean> {
|
||||
return memo(instanceId, collectiveHasProposals(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
|
||||
export function proposal (instanceId: string, api: ApiInterfaceRx): (hash: Hash | Uint8Array | string) => Observable<DeriveCollectiveProposal | null> {
|
||||
return memo(instanceId, collectiveProposal(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
|
||||
export function proposalCount (instanceId: string, api: ApiInterfaceRx): () => Observable<u32 | null> {
|
||||
return memo(instanceId, collectiveProposalCount(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
|
||||
export function proposalHashes (instanceId: string, api: ApiInterfaceRx): () => Observable<Hash[]> {
|
||||
return memo(instanceId, collectiveProposalHashes(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
|
||||
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveCollectiveProposal[]> {
|
||||
return memo(instanceId, collectiveProposals(instanceId, api, 'technicalCommittee'));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ export function createApiWithAugmentations (): ApiPromise {
|
||||
|
||||
const api = new ApiPromise({ provider: new WsProvider('ws://', false), registry });
|
||||
|
||||
api.injectMetadata(metadata, true);
|
||||
api.injectMetadata(metadata, true, registry);
|
||||
|
||||
return api;
|
||||
}
|
||||
|
||||
+12
-12
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
@@ -19,17 +19,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.14.5",
|
||||
"@polkadot/api-derive": "4.14.1",
|
||||
"@polkadot/keyring": "^6.8.1",
|
||||
"@polkadot/metadata": "4.14.1",
|
||||
"@polkadot/rpc-core": "4.14.1",
|
||||
"@polkadot/rpc-provider": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/types-known": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/util-crypto": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1",
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api-derive": "4.17.1",
|
||||
"@polkadot/keyring": "^6.11.1",
|
||||
"@polkadot/metadata": "4.17.1",
|
||||
"@polkadot/rpc-core": "4.17.1",
|
||||
"@polkadot/rpc-provider": "4.17.1",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/types-known": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/util-crypto": "^6.11.1",
|
||||
"@polkadot/x-rxjs": "^6.11.1",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Vec, u16, u32, u64, u8 } from '@polkadot/types';
|
||||
import type { Vec, u16, u32, u64 } from '@polkadot/types';
|
||||
import type { Codec } from '@polkadot/types/types';
|
||||
import type { Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
@@ -199,10 +199,42 @@ declare module '@polkadot/api/types/consts' {
|
||||
* to submit the worker's solution.
|
||||
**/
|
||||
offchainRepeat: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Base deposit for a signed solution.
|
||||
**/
|
||||
signedDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Per-byte deposit for a signed solution.
|
||||
**/
|
||||
signedDepositByte: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Per-weight deposit for a signed solution.
|
||||
**/
|
||||
signedDepositWeight: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum number of signed submissions that can be queued.
|
||||
*
|
||||
* It is best to avoid adjusting this during an election, as it impacts downstream data
|
||||
* structures. In particular, `SignedSubmissionIndices<T>` is bounded on this value. If you
|
||||
* update this value during an election, you _must_ ensure that
|
||||
* `SignedSubmissionIndices.len()` is less than or equal to the new value. Otherwise,
|
||||
* attempts to submit new solutions may cause a runtime panic.
|
||||
**/
|
||||
signedMaxSubmissions: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum weight of a signed solution.
|
||||
*
|
||||
* This should probably be similar to [`Config::MinerMaxWeight`].
|
||||
**/
|
||||
signedMaxWeight: Weight & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Duration of the signed phase.
|
||||
**/
|
||||
signedPhase: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Base reward for a signed solution
|
||||
**/
|
||||
signedRewardBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum amount of improvement to the solution score that defines a solution as
|
||||
* "better" (in any phase).
|
||||
@@ -508,9 +540,6 @@ declare module '@polkadot/api/types/consts' {
|
||||
* Number of eras that staked funds must remain bonded for.
|
||||
**/
|
||||
bondingDuration: EraIndex & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum number of nominations per nominator.
|
||||
**/
|
||||
maxNominations: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of nominators rewarded for each validator.
|
||||
@@ -526,9 +555,8 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* Number of eras that slashes are deferred by, after computation.
|
||||
*
|
||||
* This should be less than the bonding duration.
|
||||
* Set to 0 if slashes should be applied immediately, without opportunity for
|
||||
* intervention.
|
||||
* This should be less than the bonding duration. Set to 0 if slashes
|
||||
* should be applied immediately, without opportunity for intervention.
|
||||
**/
|
||||
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -560,7 +588,7 @@ declare module '@polkadot/api/types/consts' {
|
||||
* that the runtime should know about the prefix in order to make use of it as
|
||||
* an identifier of the chain.
|
||||
**/
|
||||
ss58Prefix: u8 & AugmentedConst<ApiType>;
|
||||
ss58Prefix: u16 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Get the chain's current version.
|
||||
**/
|
||||
|
||||
@@ -256,9 +256,9 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
DuplicateTopics: AugmentedError<ApiType>;
|
||||
/**
|
||||
* `seal_input` was called twice from the same contract execution context.
|
||||
* `seal_call` forwarded this contracts input. It therefore is no longer available.
|
||||
**/
|
||||
InputAlreadyRead: AugmentedError<ApiType>;
|
||||
InputForwarded: AugmentedError<ApiType>;
|
||||
/**
|
||||
* An origin TrieId written in the current block.
|
||||
**/
|
||||
@@ -316,9 +316,7 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
RandomSubjectTooLong: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The action performed is not allowed while the contract performing it is already
|
||||
* on the call stack. Those actions are contract self destruction and restoration
|
||||
* of a tombstone.
|
||||
* A call tried to invoke a contract that is flagged as non-reentrant.
|
||||
**/
|
||||
ReentranceDenied: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -343,6 +341,11 @@ declare module '@polkadot/api/types/errors' {
|
||||
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
|
||||
**/
|
||||
TerminatedInConstructor: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Termination of a contract is not allowed while the contract is already
|
||||
* on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to.
|
||||
**/
|
||||
TerminatedWhileReentrant: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The amount of topics passed to `seal_deposit_events` exceeds the limit.
|
||||
**/
|
||||
@@ -548,6 +551,18 @@ declare module '@polkadot/api/types/errors' {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
/**
|
||||
* The call is not allowed at this point.
|
||||
**/
|
||||
CallNotAllowed: AugmentedError<ApiType>;
|
||||
/**
|
||||
* `Self::insert_submission` returned an invalid index.
|
||||
**/
|
||||
InvalidSubmissionIndex: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Snapshot metadata should exist but didn't.
|
||||
**/
|
||||
MissingSnapshotMetadata: AugmentedError<ApiType>;
|
||||
/**
|
||||
* OCW submitted solution for wrong round
|
||||
**/
|
||||
@@ -564,6 +579,22 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Wrong number of winners presented.
|
||||
**/
|
||||
PreDispatchWrongWinnerCount: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The origin failed to pay the deposit.
|
||||
**/
|
||||
SignedCannotPayDeposit: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Witness data to dispatchable is invalid.
|
||||
**/
|
||||
SignedInvalidWitness: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The queue was full, and the solution was not better than any of the existing ones.
|
||||
**/
|
||||
SignedQueueFull: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The signed submission consumes too much weight
|
||||
**/
|
||||
SignedTooMuchWeight: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
@@ -1179,6 +1210,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* A nomination target was supplied that was blocked or otherwise not a validator.
|
||||
**/
|
||||
BadTarget: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The user has enough bond and thus cannot be chilled forcefully by an external person.
|
||||
**/
|
||||
CannotChillOther: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Duplicate index.
|
||||
**/
|
||||
@@ -1200,9 +1235,9 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
IncorrectSlashingSpans: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Can not bond with value less than minimum balance.
|
||||
* Can not bond with value less than minimum required.
|
||||
**/
|
||||
InsufficientValue: AugmentedError<ApiType>;
|
||||
InsufficientBond: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Invalid era to reward.
|
||||
**/
|
||||
@@ -1235,10 +1270,20 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Can not rebond without unlocking chunks.
|
||||
**/
|
||||
NoUnlockChunk: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are too many nominators in the system. Governance needs to adjust the staking settings
|
||||
* to keep things safe for the runtime.
|
||||
**/
|
||||
TooManyNominators: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many nomination targets supplied.
|
||||
**/
|
||||
TooManyTargets: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are too many validators in the system. Governance needs to adjust the staking settings
|
||||
* to keep things safe for the runtime.
|
||||
**/
|
||||
TooManyValidators: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
|
||||
@@ -391,7 +391,7 @@ declare module '@polkadot/api/types/events' {
|
||||
/**
|
||||
* An account has been rewarded for their signed submission being finalized.
|
||||
**/
|
||||
Rewarded: AugmentedEvent<ApiType, [AccountId]>;
|
||||
Rewarded: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* The signed phase of the given round has started.
|
||||
**/
|
||||
@@ -399,14 +399,16 @@ declare module '@polkadot/api/types/events' {
|
||||
/**
|
||||
* An account has been slashed for submitting an invalid signed submission.
|
||||
**/
|
||||
Slashed: AugmentedEvent<ApiType, [AccountId]>;
|
||||
Slashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* The `bool` is `true` when a previous solution was ejected to make room for this one.
|
||||
**/
|
||||
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute, bool]>;
|
||||
/**
|
||||
* The unsigned phase of the given round has started.
|
||||
**/
|
||||
@@ -835,6 +837,10 @@ declare module '@polkadot/api/types/events' {
|
||||
* A new set of stakers was elected.
|
||||
**/
|
||||
StakingElection: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* The election failed. No new era is planned.
|
||||
**/
|
||||
StakingElectionFailed: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* An account has unbonded this amount. \[stash, amount\]
|
||||
**/
|
||||
|
||||
@@ -20,11 +20,11 @@ import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lotter
|
||||
import type { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, TransactionInfo, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Percent, Releases, Slot, TransactionInfo, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
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, ElectionPhase, ElectionScore, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, ElectionPhase, ElectionScore, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SignedSubmissionOf, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, SubmissionIndicesOf, 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';
|
||||
@@ -403,6 +403,37 @@ declare module '@polkadot/api/types/storage' {
|
||||
* This is merely incremented once per every time that an upstream `elect` is called.
|
||||
**/
|
||||
round: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* A sorted, bounded set of `(score, index)`, where each `index` points to a value in
|
||||
* `SignedSubmissions`.
|
||||
*
|
||||
* We never need to process more than a single signed submission at a time. Signed submissions
|
||||
* can be quite large, so we're willing to pay the cost of multiple database accesses to access
|
||||
* them one at a time instead of reading and decoding all of them at once.
|
||||
**/
|
||||
signedSubmissionIndices: AugmentedQuery<ApiType, () => Observable<SubmissionIndicesOf>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The next index to be assigned to an incoming signed submission.
|
||||
*
|
||||
* Every accepted submission is assigned a unique index; that index is bound to that particular
|
||||
* submission for the duration of the election. On election finalization, the next index is
|
||||
* reset to 0.
|
||||
*
|
||||
* We can't just use `SignedSubmissionIndices.len()`, because that's a bounded set; past its
|
||||
* capacity, it will simply saturate. We can't just iterate over `SignedSubmissionsMap`,
|
||||
* because iteration is slow. Instead, we store the value here.
|
||||
**/
|
||||
signedSubmissionNextIndex: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Unchecked, signed solutions.
|
||||
*
|
||||
* Together with `SubmissionIndices`, this stores a bounded set of `SignedSubmissions` while
|
||||
* allowing us to keep only a single one in memory at a time.
|
||||
*
|
||||
* Twox note: the key of the map is an auto-incrementing index which users cannot inspect or
|
||||
* affect; we shouldn't need a cryptographically secure hasher.
|
||||
**/
|
||||
signedSubmissionsMap: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<SignedSubmissionOf>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
|
||||
/**
|
||||
* Snapshot data of the round.
|
||||
*
|
||||
@@ -883,6 +914,20 @@ declare module '@polkadot/api/types/storage' {
|
||||
* canceled by extraordinary circumstances (e.g. governance).
|
||||
**/
|
||||
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The threshold for when users can start calling `chill_other` for other validators / nominators.
|
||||
* The threshold is compared to the actual number of validators / nominators (`CountFor*`) in
|
||||
* the system compared to the configured max (`Max*Count`).
|
||||
**/
|
||||
chillThreshold: AugmentedQuery<ApiType, () => Observable<Option<Percent>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* A tracker to keep count of the number of items in the `Nominators` map.
|
||||
**/
|
||||
counterForNominators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* A tracker to keep count of the number of items in the `Validators` map.
|
||||
**/
|
||||
counterForValidators: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The current era index.
|
||||
*
|
||||
@@ -978,12 +1023,34 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Map from all (unlocked) "controller" accounts to the info regarding the staking.
|
||||
**/
|
||||
ledger: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<StakingLedger>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* The maximum nominator count before we stop allowing new validators to join.
|
||||
*
|
||||
* When this value is not set, no limits are enforced.
|
||||
**/
|
||||
maxNominatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The maximum validator count before we stop allowing new validators to join.
|
||||
*
|
||||
* When this value is not set, no limits are enforced.
|
||||
**/
|
||||
maxValidatorsCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Minimum number of staking participants before emergency conditions are imposed.
|
||||
**/
|
||||
minimumValidatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The minimum active bond to become and maintain the role of a nominator.
|
||||
**/
|
||||
minNominatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The minimum active bond to become and maintain the role of a validator.
|
||||
**/
|
||||
minValidatorBond: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The map from nominator stash key to the set of stash keys of all validators to nominate.
|
||||
*
|
||||
* When updating this storage item, you must also update the `CounterForNominators`.
|
||||
**/
|
||||
nominators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Nominations>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
@@ -1026,6 +1093,8 @@ declare module '@polkadot/api/types/storage' {
|
||||
validatorCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The map from (wannabe) validator stash key to the preferences of that validator.
|
||||
*
|
||||
* When updating this storage item, you must also update the `CounterForValidators`.
|
||||
**/
|
||||
validators: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<ValidatorPrefs>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
|
||||
@@ -106,6 +106,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
* Returns the keys with prefix from a child storage, leave empty to get all the keys
|
||||
**/
|
||||
getKeys: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
|
||||
/**
|
||||
* Returns the keys with prefix from a child storage with pagination support
|
||||
**/
|
||||
getKeysPaged: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
|
||||
/**
|
||||
* Returns a child storage entry at a specific block state
|
||||
**/
|
||||
|
||||
@@ -19,7 +19,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 { ElectionScore, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { ElectionScore, EraIndex, RawSolution, ReadySolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { Key } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { ClassId, DestroyWitness, InstanceId } from '@polkadot/types/interfaces/uniques';
|
||||
@@ -134,6 +134,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Emits `Destroyed` event when successful.
|
||||
*
|
||||
* NOTE: It can be helpful to first freeze an asset before destroying it so that you
|
||||
* can provide accurate witness information and prevent users from manipulating state
|
||||
* in a way that can make it harder to destroy.
|
||||
*
|
||||
* Weight: `O(c + p + a)` where:
|
||||
* - `c = (witness.accounts - witness.sufficients)`
|
||||
* - `s = witness.sufficients`
|
||||
@@ -538,6 +542,27 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
transfer: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, Compact<Balance>]>;
|
||||
/**
|
||||
* Transfer the entire transferable balance from the caller account.
|
||||
*
|
||||
* NOTE: This function only attempts to transfer _transferable_ balances. This means that
|
||||
* any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be
|
||||
* transferred by this function. To ensure that this function results in a killed account,
|
||||
* you might need to prepare the account by removing any reference counters, storage
|
||||
* deposits, etc...
|
||||
*
|
||||
* The dispatch origin of this call must be Signed.
|
||||
*
|
||||
* - `dest`: The recipient of the transfer.
|
||||
* - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all
|
||||
* of the funds the account has, causing the sender account to be killed (false), or
|
||||
* transfer everything except at least the existential deposit, which will guarantee to
|
||||
* keep the sender account alive (true).
|
||||
* # <weight>
|
||||
* - O(1). Just like transfer, but reading the user's transferable balance first.
|
||||
* #</weight>
|
||||
**/
|
||||
transferAll: AugmentedSubmittable<(dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, keepAlive: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, bool]>;
|
||||
/**
|
||||
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
|
||||
* origin account.
|
||||
@@ -1221,6 +1246,17 @@ declare module '@polkadot/api/types/submittable' {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
/**
|
||||
* Set a solution in the queue, to be handed out to the client of this pallet in the next
|
||||
* call to `ElectionProvider::elect`.
|
||||
*
|
||||
* This can only be set by `T::ForceOrigin`, and only when the phase is `Emergency`.
|
||||
*
|
||||
* The solution is not checked for any feasibility and is assumed to be trustworthy, as any
|
||||
* feasibility check itself can in principle cause the election process to fail (due to
|
||||
* memory/weight constrains).
|
||||
**/
|
||||
setEmergencyElectionResult: AugmentedSubmittable<(solution: ReadySolution | { supports?: any; score?: any; compute?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ReadySolution]>;
|
||||
/**
|
||||
* Set a new value for `MinimumUntrustedScore`.
|
||||
*
|
||||
@@ -1229,6 +1265,22 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* This check can be turned off by setting the value to `None`.
|
||||
**/
|
||||
setMinimumUntrustedScore: AugmentedSubmittable<(maybeNextScore: Option<ElectionScore> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<ElectionScore>]>;
|
||||
/**
|
||||
* Submit a solution for the signed phase.
|
||||
*
|
||||
* The dispatch origin fo this call must be __signed__.
|
||||
*
|
||||
* The solution is potentially queued, based on the claimed score and processed at the end
|
||||
* of the signed phase.
|
||||
*
|
||||
* A deposit is reserved and recorded for the solution. Based on the outcome, the solution
|
||||
* might be rewarded, slashed, or get all or a part of the deposit back.
|
||||
*
|
||||
* # <weight>
|
||||
* Queue size must be provided as witness data.
|
||||
* # </weight>
|
||||
**/
|
||||
submit: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, numSignedSubmissions: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, u32]>;
|
||||
/**
|
||||
* Submit a solution for the unsigned phase.
|
||||
*
|
||||
@@ -2525,7 +2577,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.
|
||||
* - DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`
|
||||
* - DbWrites: `NextKeys`, `origin account`
|
||||
* - DbWrites per key id: `KeyOwnder`
|
||||
* - DbWrites per key id: `KeyOwner`
|
||||
* # </weight>
|
||||
**/
|
||||
purgeKeys: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
@@ -2960,12 +3012,43 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
chill: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Declare a `controller` to stop participating as either a validator or nominator.
|
||||
*
|
||||
* Effects will be felt at the beginning of the next era.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_, but can be called by anyone.
|
||||
*
|
||||
* If the caller is the same as the controller being targeted, then no further checks are
|
||||
* enforced, and this function behaves just like `chill`.
|
||||
*
|
||||
* If the caller is different than the controller being targeted, the following conditions
|
||||
* must be met:
|
||||
* * A `ChillThreshold` must be set and checked which defines how close to the max
|
||||
* nominators or validators we must reach before users can start chilling one-another.
|
||||
* * A `MaxNominatorCount` and `MaxValidatorCount` must be set which is used to determine
|
||||
* how close we are to the threshold.
|
||||
* * A `MinNominatorBond` and `MinValidatorBond` must be set and checked, which determines
|
||||
* if this is a person that should be chilled because they have not met the threshold
|
||||
* bond required.
|
||||
*
|
||||
* This can be helpful if bond requirements are updated, and we need to remove old users
|
||||
* who do not satisfy these requirements.
|
||||
*
|
||||
**/
|
||||
chillOther: AugmentedSubmittable<(controller: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId]>;
|
||||
/**
|
||||
* Force there to be a new era at the end of the next session. After this, it will be
|
||||
* reset to normal (non-forced) behaviour.
|
||||
*
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # Warning
|
||||
*
|
||||
* The election process starts multiple blocks before the end of the era.
|
||||
* If this is called just before a new era is triggered, the election process may not
|
||||
* have enough blocks to get a result.
|
||||
*
|
||||
* # <weight>
|
||||
* - No arguments.
|
||||
* - Weight: O(1)
|
||||
@@ -2978,6 +3061,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # Warning
|
||||
*
|
||||
* The election process starts multiple blocks before the end of the era.
|
||||
* If this is called just before a new era is triggered, the election process may not
|
||||
* have enough blocks to get a result.
|
||||
*
|
||||
* # <weight>
|
||||
* - Weight: O(1)
|
||||
* - Write: ForceEra
|
||||
@@ -2989,6 +3078,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # Warning
|
||||
*
|
||||
* The election process starts multiple blocks before the end of the era.
|
||||
* Thus the election process may be ongoing when this is called. In this case the
|
||||
* election will continue until the next era is triggered.
|
||||
*
|
||||
* # <weight>
|
||||
* - No arguments.
|
||||
* - Weight: O(1)
|
||||
@@ -3206,6 +3301,22 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
setPayee: AugmentedSubmittable<(payee: RewardDestination | { Staked: any } | { Stash: any } | { Controller: any } | { Account: any } | { None: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RewardDestination]>;
|
||||
/**
|
||||
* Update the various staking limits this pallet.
|
||||
*
|
||||
* * `min_nominator_bond`: The minimum active bond needed to be a nominator.
|
||||
* * `min_validator_bond`: The minimum active bond needed to be a validator.
|
||||
* * `max_nominator_count`: The max number of users who can be a nominator at once.
|
||||
* When set to `None`, no limit is enforced.
|
||||
* * `max_validator_count`: The max number of users who can be a validator at once.
|
||||
* When set to `None`, no limit is enforced.
|
||||
*
|
||||
* Origin must be Root to call this function.
|
||||
*
|
||||
* NOTE: Existing nominators and validators will not be affected by this update.
|
||||
* to kick people under the new limits, `chill_other` should be called.
|
||||
**/
|
||||
setStakingLimits: AugmentedSubmittable<(minNominatorBond: BalanceOf | AnyNumber | Uint8Array, minValidatorBond: BalanceOf | AnyNumber | Uint8Array, maxNominatorCount: Option<u32> | null | object | string | Uint8Array, maxValidatorCount: Option<u32> | null | object | string | Uint8Array, threshold: Option<Percent> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [BalanceOf, BalanceOf, Option<u32>, Option<u32>, Option<Percent>]>;
|
||||
/**
|
||||
* Sets the ideal number of validators.
|
||||
*
|
||||
@@ -3229,6 +3340,9 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need
|
||||
* to be called first to remove some of the chunks (if possible).
|
||||
*
|
||||
* If a user encounters the `InsufficientBond` error when calling this extrinsic,
|
||||
* they should call `chill` first in order to free up their bonded funds.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ by the controller, not the stash.
|
||||
* And, it can be only called when [`EraElectionStatus`] is `Closed`.
|
||||
*
|
||||
@@ -4049,10 +4163,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Weight: `O(n + m)` where:
|
||||
* - `n = witness.instances`
|
||||
* - `m = witness.instance_metdadatas`
|
||||
* - `m = witness.instance_metadatas`
|
||||
* - `a = witness.attributes`
|
||||
**/
|
||||
destroy: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, witness: DestroyWitness | { instances?: any; instanceMetadatas?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, DestroyWitness]>;
|
||||
destroy: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, witness: DestroyWitness | { instances?: any; instanceMetadatas?: any; attributes?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, DestroyWitness]>;
|
||||
/**
|
||||
* Alter the attributes of a given asset.
|
||||
*
|
||||
|
||||
@@ -8,7 +8,8 @@ import type { Call, Hash, RpcMethods, RuntimeVersion } from '@polkadot/types/int
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, IMethod, InterfaceTypes, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { SubmittableExtrinsic } from '../submittable/types';
|
||||
import type { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorage, QueryableStorageAt, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
import type { VersionedRegistry } from './types';
|
||||
|
||||
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
|
||||
import { memo } from '@polkadot/api-derive/util';
|
||||
@@ -18,7 +19,7 @@ import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { DEFAULT_VERSION as EXTRINSIC_DEFAULT_VERSION } from '@polkadot/types/extrinsic/constants';
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import { arrayChunk, arrayFlatten, assert, BN, compactStripLength, logger, u8aToHex } from '@polkadot/util';
|
||||
import { arrayChunk, arrayFlatten, assert, BN, BN_ZERO, compactStripLength, logger, u8aToHex } from '@polkadot/util';
|
||||
import { BehaviorSubject, combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap, tap, toArray } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
@@ -36,6 +37,11 @@ interface MetaDecoration {
|
||||
toJSON: () => any;
|
||||
}
|
||||
|
||||
interface FullDecoration<ApiType extends ApiTypes> {
|
||||
decoratedApi: ApiDecoration<ApiType>;
|
||||
decoratedMeta: DecoratedMeta;
|
||||
}
|
||||
|
||||
// the max amount of keys/values that we will retrieve at once
|
||||
const PAGE_SIZE_K = 1000; // limit aligned with the 1k on the node (trie lookups are heavy)
|
||||
const PAGE_SIZE_V = 250; // limited since the data may be very large (e.g. misfiring elections)
|
||||
@@ -186,8 +192,43 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return this._rpcCore.provider.hasSubscriptions || !!this._rpcCore.state.queryStorageAt;
|
||||
}
|
||||
|
||||
public injectMetadata (metadata: Metadata, fromEmpty?: boolean, registry?: Registry): void {
|
||||
const decoratedMeta = expandMetadata(registry || this.#registry, metadata);
|
||||
protected _injectDecorated (registry: VersionedRegistry<ApiType>, fromEmpty?: boolean, blockHash?: Uint8Array): FullDecoration<ApiType> {
|
||||
const decoratedMeta = expandMetadata(registry.registry, registry.metadata);
|
||||
|
||||
// clear the decoration, we are redoing it here
|
||||
if (fromEmpty || !registry.decoration) {
|
||||
registry.decoration = {
|
||||
consts: {},
|
||||
errors: {},
|
||||
events: {},
|
||||
query: {}
|
||||
} as ApiDecoration<ApiType>;
|
||||
}
|
||||
|
||||
// adjust the versioned registry
|
||||
augmentObject('consts', decoratedMeta.consts, registry.decoration.consts, fromEmpty);
|
||||
augmentObject('errors', decoratedMeta.errors, registry.decoration.errors, fromEmpty);
|
||||
augmentObject('events', decoratedMeta.events, registry.decoration.events, fromEmpty);
|
||||
|
||||
const storage = blockHash
|
||||
? this._decorateStorageAt(decoratedMeta, this._decorateMethod, blockHash)
|
||||
: this._decorateStorage(decoratedMeta, this._decorateMethod);
|
||||
|
||||
augmentObject('query', storage, registry.decoration.query, fromEmpty);
|
||||
|
||||
return {
|
||||
decoratedApi: registry.decoration,
|
||||
decoratedMeta
|
||||
};
|
||||
}
|
||||
|
||||
protected _injectMetadata (registry: VersionedRegistry<ApiType>, fromEmpty?: boolean): void {
|
||||
const { decoratedApi, decoratedMeta } = this._injectDecorated(registry, fromEmpty);
|
||||
|
||||
this._consts = decoratedApi.consts;
|
||||
this._errors = decoratedApi.errors;
|
||||
this._events = decoratedApi.events;
|
||||
this._query = decoratedApi.query;
|
||||
|
||||
if (fromEmpty || !this._extrinsics) {
|
||||
this._extrinsics = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
|
||||
@@ -197,17 +238,19 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
augmentObject(null, this._decorateExtrinsics(decoratedMeta, this._rxDecorateMethod), this._rx.tx, false);
|
||||
}
|
||||
|
||||
// this API
|
||||
augmentObject('query', this._decorateStorage(decoratedMeta, this._decorateMethod), this._query, fromEmpty);
|
||||
augmentObject('consts', decoratedMeta.consts, this._consts, fromEmpty);
|
||||
augmentObject('errors', decoratedMeta.errors, this._errors, fromEmpty);
|
||||
augmentObject('events', decoratedMeta.events, this._events, fromEmpty);
|
||||
|
||||
// rx
|
||||
augmentObject(null, this._decorateStorage(decoratedMeta, this._rxDecorateMethod), this._rx.query, fromEmpty);
|
||||
augmentObject(null, decoratedMeta.consts, this._rx.consts, fromEmpty);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
|
||||
*/
|
||||
public injectMetadata (metadata: Metadata, fromEmpty?: boolean, registry?: Registry): void {
|
||||
this._injectMetadata({ metadata, registry: registry || this.#registry, specVersion: BN_ZERO }, fromEmpty);
|
||||
}
|
||||
|
||||
private _decorateFunctionMeta (input: MetaDecoration, output: MetaDecoration): MetaDecoration {
|
||||
output.meta = input.meta;
|
||||
output.method = input.method;
|
||||
@@ -353,6 +396,18 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}, {} as QueryableStorage<ApiType>);
|
||||
}
|
||||
|
||||
protected _decorateStorageAt<ApiType extends ApiTypes> ({ query }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageAt<ApiType> {
|
||||
return Object.entries(query).reduce((out, [name, section]): QueryableStorageAt<ApiType> => {
|
||||
out[name] = Object.entries(section).reduce((out, [name, method]): QueryableModuleStorageAt<ApiType> => {
|
||||
out[name] = this._decorateStorageEntryAt(method, decorateMethod, blockHash);
|
||||
|
||||
return out;
|
||||
}, {} as QueryableModuleStorageAt<ApiType>);
|
||||
|
||||
return out;
|
||||
}, {} as QueryableStorageAt<ApiType>);
|
||||
}
|
||||
|
||||
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
||||
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
|
||||
@@ -371,7 +426,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
this._rpcCore.state.getStorageHash(getArgs(args)));
|
||||
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section && key.method === creator.method;
|
||||
key.section === creator.section &&
|
||||
key.method === creator.method;
|
||||
|
||||
decorated.key = (...args: Arg[]): string =>
|
||||
u8aToHex(compactStripLength(creator(
|
||||
@@ -435,6 +491,59 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return this._decorateFunctionMeta(creator as any, decorated) as unknown as QueryableStorageEntry<ApiType>;
|
||||
}
|
||||
|
||||
private _decorateStorageEntryAt<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageEntryAt<ApiType> {
|
||||
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
|
||||
|
||||
// Disable this where it occurs for each field we are decorating
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
const decorated = decorateMethod((...args: Arg[]): Observable<Codec> =>
|
||||
this._rpcCore.state.getStorage(getArgs(args), blockHash));
|
||||
|
||||
decorated.creator = creator;
|
||||
|
||||
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
|
||||
this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
|
||||
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section &&
|
||||
key.method === creator.method;
|
||||
|
||||
decorated.key = (...args: Arg[]): string =>
|
||||
u8aToHex(compactStripLength(creator(
|
||||
creator.meta.type.isPlain
|
||||
? undefined
|
||||
: creator.meta.type.isMap
|
||||
? args[0]
|
||||
: creator.meta.type.isDoubleMap
|
||||
? [args[0], args[1]]
|
||||
: args
|
||||
))[1]);
|
||||
|
||||
decorated.keyPrefix = (...keys: Arg[]): string =>
|
||||
u8aToHex(creator.keyPrefix(...keys));
|
||||
|
||||
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
|
||||
|
||||
// FIXME NMap support
|
||||
// .keys() & .entries() only available on map types
|
||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
|
||||
decorated.entries = decorateMethod(
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, blockHash, args)));
|
||||
|
||||
decorated.keys = decorateMethod(
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, blockHash, args)));
|
||||
}
|
||||
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
return this._decorateFunctionMeta(creator as any, decorated) as unknown as QueryableStorageEntry<ApiType>;
|
||||
}
|
||||
|
||||
// Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
|
||||
// we make a subscription, alternatively we push this through a single-shot query
|
||||
private _decorateStorageCall<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Metadata } from '@polkadot/metadata';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types';
|
||||
import type { ApiDecoration, ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types';
|
||||
|
||||
import { assertReturn } from '@polkadot/util';
|
||||
|
||||
@@ -21,7 +21,7 @@ function assertResult<T> (value: T | undefined): T {
|
||||
return assertReturn(value, 'Api needs to be initialized before using, listen on \'ready\'');
|
||||
}
|
||||
|
||||
export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
|
||||
export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> implements ApiDecoration<ApiType> {
|
||||
/**
|
||||
* @description Contains the parameter types (constants) of all modules.
|
||||
*
|
||||
@@ -82,13 +82,6 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
|
||||
return assertResult(this._genesisHash);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` when subscriptions are supported
|
||||
*/
|
||||
public get hasSubscriptions (): boolean {
|
||||
return this._rpcCore.provider.hasSubscriptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true is the underlying provider is connected
|
||||
*/
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/inte
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { Observable, Subscription } from '@polkadot/x-rxjs';
|
||||
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
import type { ApiBase, ApiDecoration, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
import type { VersionedRegistry } from './types';
|
||||
|
||||
import { Metadata } from '@polkadot/metadata';
|
||||
@@ -28,7 +28,7 @@ const l = logger('api/init');
|
||||
export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
#healthTimer: NodeJS.Timeout | null = null;
|
||||
|
||||
#registries: VersionedRegistry[] = [];
|
||||
#registries: VersionedRegistry<ApiType>[] = [];
|
||||
|
||||
#updateSub?: Subscription | null = null;
|
||||
|
||||
@@ -44,7 +44,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
if (!options.source) {
|
||||
this.registerTypes(options.types);
|
||||
} else {
|
||||
this.#registries = options.source.#registries;
|
||||
this.#registries = options.source.#registries as VersionedRegistry<ApiType>[];
|
||||
}
|
||||
|
||||
this._rpc = this._decorateRpc(this._rpcCore, this._decorateMethod);
|
||||
@@ -79,7 +79,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
/**
|
||||
* @description Decorates a registry based on the runtime version
|
||||
*/
|
||||
private _initRegistry (registry: Registry, chain: Text, version: { specName: Text, specVersion: BN }, metadata: Metadata, chainProps?: ChainProperties): Registry {
|
||||
private _initRegistry (registry: Registry, chain: Text, version: { specName: Text, specVersion: BN }, metadata: Metadata, chainProps?: ChainProperties): void {
|
||||
registry.setChainProperties(chainProps || this.registry.getChainProperties());
|
||||
registry.setKnownTypes(this._options);
|
||||
registry.register(getSpecTypes(registry, chain, version.specName, version.specVersion));
|
||||
@@ -94,14 +94,36 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
...getSpecExtensions(registry, chain, version.specName),
|
||||
...(this._options.signedExtensions || {})
|
||||
});
|
||||
}
|
||||
|
||||
return registry;
|
||||
/**
|
||||
* @description Returns the default versioned registry
|
||||
*/
|
||||
private _getDefaultRegistry (): VersionedRegistry<ApiType> {
|
||||
// get the default registry version
|
||||
const thisRegistry = this.#registries.find(({ isDefault }) => isDefault);
|
||||
|
||||
assert(thisRegistry, 'Initialization error, cannot find the default registry');
|
||||
|
||||
return thisRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a decorated API instance at a specific point in time
|
||||
*/
|
||||
public async at (blockHash: Uint8Array | string): Promise<ApiDecoration<ApiType>> {
|
||||
const u8aHash = u8aToU8a(blockHash);
|
||||
const registry = await this.getBlockRegistry(u8aHash);
|
||||
|
||||
return registry.decoration
|
||||
? registry.decoration
|
||||
: this._injectDecorated(registry, true, u8aHash).decoratedApi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sets up a registry based on the block hash defined
|
||||
*/
|
||||
public async getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry> {
|
||||
public async getBlockRegistry (blockHash: Uint8Array): Promise<VersionedRegistry<ApiType>> {
|
||||
const existingViaHash = this.#registries.find(({ lastBlockHash }) =>
|
||||
lastBlockHash && u8aEq(lastBlockHash, blockHash)
|
||||
);
|
||||
@@ -141,13 +163,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
}
|
||||
|
||||
// nothing has been found, construct new
|
||||
const metadata = new Metadata(this.registry,
|
||||
const registry = new TypeRegistry(blockHash);
|
||||
const metadata = new Metadata(registry,
|
||||
await (this._rpcCore.state.getMetadata as RpcInterfaceMethod).raw(header.parentHash).toPromise()
|
||||
);
|
||||
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
|
||||
|
||||
this._initRegistry(registry, this._runtimeChain as Text, version, metadata);
|
||||
|
||||
// add our new registry
|
||||
const result = { isDefault: false, lastBlockHash: blockHash, metadata, metadataConsts: null, registry, specVersion: version.specVersion };
|
||||
const result = { lastBlockHash: blockHash, metadata, registry, specVersion: version.specVersion };
|
||||
|
||||
this.#registries.push(result);
|
||||
|
||||
@@ -230,18 +254,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
this._rx.runtimeVersion = version;
|
||||
|
||||
// update the default registry version
|
||||
const thisRegistry = this.#registries.find(({ isDefault }) => isDefault);
|
||||
|
||||
assert(thisRegistry, 'Initialization error, cannot find the default registry');
|
||||
const thisRegistry = this._getDefaultRegistry();
|
||||
|
||||
// setup the data as per the current versions
|
||||
thisRegistry.metadata = metadata;
|
||||
thisRegistry.metadataConsts = null;
|
||||
thisRegistry.specVersion = version.specVersion;
|
||||
|
||||
// clear the registry types to ensure that we override correctly
|
||||
this._initRegistry(thisRegistry.registry.init(), this._runtimeChain as Text, version, metadata);
|
||||
this.injectMetadata(metadata, false, thisRegistry.registry);
|
||||
this._injectMetadata(thisRegistry, false);
|
||||
|
||||
return this._detectCapabilities(thisRegistry.registry);
|
||||
})
|
||||
@@ -282,11 +303,11 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// setup the initial registry, when we have none
|
||||
if (!this.#registries.length) {
|
||||
this.#registries.push({ isDefault: true, lastBlockHash: null, metadata, metadataConsts: null, registry: this.registry, specVersion: runtimeVersion.specVersion });
|
||||
this.#registries.push({ isDefault: true, metadata, registry: this.registry, specVersion: runtimeVersion.specVersion });
|
||||
}
|
||||
|
||||
// get unique types & validate
|
||||
metadata.getUniqTypes(false);
|
||||
metadata.getUniqTypes(this._options.throwOnUnknown || false);
|
||||
|
||||
return [genesisHash, metadata];
|
||||
}
|
||||
@@ -298,7 +319,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
this._rx.runtimeVersion = this._runtimeVersion as RuntimeVersion; // must be set here
|
||||
|
||||
// inject metadata and adjust the types as detected
|
||||
this.injectMetadata(metadata, true);
|
||||
this._injectMetadata(this._getDefaultRegistry(), true);
|
||||
|
||||
// derive is last, since it uses the decorated rx
|
||||
this._rx.derive = this._decorateDeriveRx(this._rxDecorateMethod);
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Metadata } from '@polkadot/metadata';
|
||||
import type { Constants } from '@polkadot/metadata/decorate/types';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { ApiDecoration, ApiTypes } from '../types';
|
||||
|
||||
export interface VersionedRegistry {
|
||||
isDefault: boolean;
|
||||
lastBlockHash: Uint8Array | null;
|
||||
export interface VersionedRegistry<ApiType extends ApiTypes> {
|
||||
decoration?: ApiDecoration<ApiType> | null;
|
||||
isDefault?: boolean;
|
||||
lastBlockHash?: Uint8Array | null;
|
||||
metadata: Metadata;
|
||||
metadataConsts: Constants | null;
|
||||
registry: Registry;
|
||||
specVersion: BN;
|
||||
}
|
||||
|
||||
@@ -239,6 +239,16 @@ async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function at (api: ApiPromise): Promise<void> {
|
||||
const apiAt = await api.at('0x1234');
|
||||
|
||||
// get old balances
|
||||
console.log(await apiAt.query.balances.freeBalance('0x1234'));
|
||||
|
||||
// get some constants
|
||||
console.log(apiAt.consts.balances.existentialDeposit);
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
const api = await ApiPromise.create();
|
||||
const pairs = createTestPairs();
|
||||
@@ -253,7 +263,8 @@ async function main (): Promise<void> {
|
||||
queryExtra(api, pairs),
|
||||
rpc(api),
|
||||
types(api),
|
||||
tx(api, pairs)
|
||||
tx(api, pairs),
|
||||
at(api)
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.17.1' };
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
import type { SubmittableExtrinsic } from '../types';
|
||||
|
||||
import { jest } from '@jest/globals';
|
||||
|
||||
import { createPair } from '@polkadot/keyring/pair';
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
import { MockProvider } from '@polkadot/rpc-provider/mock';
|
||||
@@ -91,7 +93,7 @@ describe('ApiPromise', (): void => {
|
||||
super({ provider });
|
||||
}
|
||||
|
||||
protected _loadMeta (): Promise<boolean> {
|
||||
protected override _loadMeta (): Promise<boolean> {
|
||||
throw new Error('Simulate failure to load meta');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, decorate
|
||||
* @description Sign a transaction, returning the this to allow chaining, i.e. .sign(...).send(). When options, e.g. nonce/blockHash are not specified, it will be inferred. To retrieve eg. nonce use `signAsync` (the preferred interface, this is provided for backwards compatibility)
|
||||
* @deprecated
|
||||
*/
|
||||
public sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
|
||||
public override sign (account: IKeyringPair, optionsOrNonce?: Partial<SignerOptions>): this {
|
||||
super.sign(account, this.#makeSignOptions(this.#optionsOrNonce(optionsOrNonce), {}));
|
||||
|
||||
return this;
|
||||
|
||||
@@ -14,7 +14,10 @@ import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, Signat
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { ApiBase } from '../base';
|
||||
import type { DeriveAllSections } from '../util/decorate';
|
||||
import type { ApiTypes } from './base';
|
||||
import type { QueryableConsts } from './consts';
|
||||
import type { DecoratedErrors } from './errors';
|
||||
import type { DecoratedEvents } from './events';
|
||||
import type { DecoratedRpc } from './rpc';
|
||||
import type { QueryableStorage, QueryableStorageMulti } from './storage';
|
||||
import type { SubmittableExtrinsics } from './submittable';
|
||||
@@ -73,6 +76,10 @@ export interface ApiOptions extends RegisteredTypes {
|
||||
* @description Throws an error when the initial connection fails (same as isReadyOrError)
|
||||
*/
|
||||
throwOnConnect?: boolean;
|
||||
/**
|
||||
* @description Throws an error when some types are unknown (useful with throwOnConnect)
|
||||
*/
|
||||
throwOnUnknown?: boolean;
|
||||
}
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
@@ -99,3 +106,10 @@ export interface SignerOptions extends SignatureOptions {
|
||||
blockNumber: BN;
|
||||
genesisHash: Hash;
|
||||
}
|
||||
|
||||
export interface ApiDecoration<ApiType extends ApiTypes> {
|
||||
consts: QueryableConsts<ApiType>;
|
||||
errors: DecoratedErrors<ApiType>;
|
||||
events: DecoratedEvents<ApiType>;
|
||||
query: QueryableStorage<ApiType>;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,11 @@ export interface StorageEntryPromiseOverloads {
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, arg3: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloadsAt {
|
||||
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
|
||||
}
|
||||
|
||||
// This is the most generic typings we can have for a storage entry function
|
||||
type GenericStorageEntryFunction = (...args: CodecArg[]) => Observable<Codec>
|
||||
|
||||
@@ -36,6 +41,17 @@ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple =
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
: AugmentedQuery<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloads;
|
||||
|
||||
export type QueryableStorageEntryAt<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||
ApiType extends 'rxjs'
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
? AugmentedQueryAt<'rxjs', GenericStorageEntryFunction, A>
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
: AugmentedQueryAt<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloadsAt;
|
||||
|
||||
export interface QueryableStorageAt<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
|
||||
[key: string]: QueryableModuleStorageAt<ApiType>;
|
||||
}
|
||||
|
||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
|
||||
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
|
||||
creator: StorageEntry;
|
||||
@@ -56,10 +72,24 @@ export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunctio
|
||||
multi: ApiType extends 'rxjs' ? StorageEntryObservableMulti : StorageEntryPromiseMulti;
|
||||
}
|
||||
|
||||
export interface StorageEntryBaseAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> {
|
||||
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>, K extends AnyTuple = A>(...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, [StorageKey<K>, T][]>;
|
||||
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
|
||||
key: (...args: Parameters<F>) => string;
|
||||
keyPrefix: (...args: DropLast<Parameters<F>>) => string;
|
||||
keys: <K extends AnyTuple = A> (...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
|
||||
}
|
||||
|
||||
export interface QueryableModuleStorage<ApiType extends ApiTypes> {
|
||||
[index: string]: QueryableStorageEntry<ApiType, AnyTuple>;
|
||||
}
|
||||
|
||||
export interface QueryableModuleStorageAt<ApiType extends ApiTypes> {
|
||||
[index: string]: QueryableStorageEntryAt<ApiType, AnyTuple>;
|
||||
}
|
||||
|
||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||
QueryableStorageEntry<ApiType> |
|
||||
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
|
||||
@@ -83,5 +113,7 @@ export interface AugmentedQueries<ApiType extends ApiTypes> { }
|
||||
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
|
||||
|
||||
export type AugmentedQueryAt<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBaseAt<ApiType, F, A>;
|
||||
|
||||
// backwards compatibility-only
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = AugmentedQuery<ApiType, F, A>;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { jest } from '@jest/globals';
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
describe('misc online tests', (): void => {
|
||||
|
||||
@@ -7,6 +7,8 @@ import type { Option } from '@polkadot/types/codec';
|
||||
import type { AccountId, AccountIndex, AccountInfo, Address, Balance, BlockNumber, Index } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { jest } from '@jest/globals';
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
import { memo } from '@polkadot/api-derive/util/memo';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
@@ -19,13 +19,13 @@
|
||||
"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.14.5",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/types-known": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/util-crypto": "^6.8.1"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/types-known": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/util-crypto": "^6.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.8.1"
|
||||
"@polkadot/keyring": "^6.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ export class MetadataVersioned extends Struct {
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): Record<string, AnyJson> {
|
||||
public override toJSON (): Record<string, AnyJson> {
|
||||
// HACK(y): ensure that we apply the aliases if we have not done so already, this is
|
||||
// needed to ensure we have the correct overrides (which is only applied in toLatest)
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
|
||||
@@ -89,7 +89,7 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
|
||||
// meta fallback only applies to actual entry values, create one for head
|
||||
(iterFn as IterFn).meta = registry.createType('StorageEntryMetadataLatest', {
|
||||
documentation,
|
||||
fallback: registry.createType('Bytes', registry.createType(outputType.toString() as 'Raw').toHex()),
|
||||
fallback: registry.createType('Bytes'),
|
||||
modifier: registry.createType('StorageEntryModifierLatest', 1), // required
|
||||
name,
|
||||
type: registry.createType('StorageEntryTypeLatest', registry.createType('Type', outputType), 0)
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.17.1' };
|
||||
|
||||
@@ -499,15 +499,15 @@
|
||||
{
|
||||
"name": "Version",
|
||||
"type": "RuntimeVersion",
|
||||
"value": "0x106e6f6465387375627374726174652d6e6f64650a0000000b0100000000000034df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a05000000d2bc9897eed08f1502000000f78b278be53f454c02000000ed99c5acb25eedf502000000cbca25e39f14238702000000687ad44ad37f03c201000000bc9d89904f5b923f0100000068b66ba122c93fa70100000037c8bb1350a9a2a80100000091d5df18b0d2cf5801000000ab3c0572291feb8b0100000002000000",
|
||||
"value": "0x106e6f6465387375627374726174652d6e6f64650a0000000b0100000000000034df6acb689907609b0300000037e397fc7c91f5e40100000040fe3ad401f8959a05000000d2bc9897eed08f1503000000f78b278be53f454c02000000ed99c5acb25eedf502000000cbca25e39f14238702000000687ad44ad37f03c201000000bc9d89904f5b923f0100000068b66ba122c93fa70100000037c8bb1350a9a2a80100000091d5df18b0d2cf5801000000ab3c0572291feb8b0100000002000000",
|
||||
"documentation": [
|
||||
" Get the chain's current version."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SS58Prefix",
|
||||
"type": "u8",
|
||||
"value": "0x2a",
|
||||
"type": "u16",
|
||||
"value": "0x2a00",
|
||||
"documentation": [
|
||||
" The designated SS85 prefix of this chain.",
|
||||
"",
|
||||
@@ -1638,6 +1638,39 @@
|
||||
" - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)",
|
||||
" #</weight>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "transfer_all",
|
||||
"args": [
|
||||
{
|
||||
"name": "dest",
|
||||
"type": "LookupSource"
|
||||
},
|
||||
{
|
||||
"name": "keep_alive",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Transfer the entire transferable balance from the caller account.",
|
||||
"",
|
||||
" NOTE: This function only attempts to transfer _transferable_ balances. This means that",
|
||||
" any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be",
|
||||
" transferred by this function. To ensure that this function results in a killed account,",
|
||||
" you might need to prepare the account by removing any reference counters, storage",
|
||||
" deposits, etc...",
|
||||
"",
|
||||
" The dispatch origin of this call must be Signed.",
|
||||
"",
|
||||
" - `dest`: The recipient of the transfer.",
|
||||
" - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all",
|
||||
" of the funds the account has, causing the sender account to be killed (false), or",
|
||||
" transfer everything except at least the existential deposit, which will guarantee to",
|
||||
" keep the sender account alive (true).",
|
||||
" # <weight>",
|
||||
" - O(1). Just like transfer, but reading the user's transferable balance first.",
|
||||
" #</weight>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
@@ -1921,6 +1954,63 @@
|
||||
" Only exists when [`Snapshot`] is present."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedSubmissionNextIndex",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "u32"
|
||||
},
|
||||
"fallback": "0x00000000",
|
||||
"documentation": [
|
||||
" The next index to be assigned to an incoming signed submission.",
|
||||
"",
|
||||
" Every accepted submission is assigned a unique index; that index is bound to that particular",
|
||||
" submission for the duration of the election. On election finalization, the next index is",
|
||||
" reset to 0.",
|
||||
"",
|
||||
" We can't just use `SignedSubmissionIndices.len()`, because that's a bounded set; past its",
|
||||
" capacity, it will simply saturate. We can't just iterate over `SignedSubmissionsMap`,",
|
||||
" because iteration is slow. Instead, we store the value here."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedSubmissionIndices",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "SubmissionIndicesOf"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" A sorted, bounded set of `(score, index)`, where each `index` points to a value in",
|
||||
" `SignedSubmissions`.",
|
||||
"",
|
||||
" We never need to process more than a single signed submission at a time. Signed submissions",
|
||||
" can be quite large, so we're willing to pay the cost of multiple database accesses to access",
|
||||
" them one at a time instead of reading and decoding all of them at once."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedSubmissionsMap",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"map": {
|
||||
"hasher": "Twox64Concat",
|
||||
"key": "u32",
|
||||
"value": "SignedSubmissionOf",
|
||||
"linked": false
|
||||
}
|
||||
},
|
||||
"fallback": "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000",
|
||||
"documentation": [
|
||||
" Unchecked, signed solutions.",
|
||||
"",
|
||||
" Together with `SubmissionIndices`, this stores a bounded set of `SignedSubmissions` while",
|
||||
" allowing us to keep only a single one in memory at a time.",
|
||||
"",
|
||||
" Twox note: the key of the map is an auto-incrementing index which users cannot inspect or",
|
||||
" affect; we shouldn't need a cryptographically secure hasher."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MinimumUntrustedScore",
|
||||
"modifier": "Optional",
|
||||
@@ -1982,19 +2072,69 @@
|
||||
"",
|
||||
" This check can be turned off by setting the value to `None`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set_emergency_election_result",
|
||||
"args": [
|
||||
{
|
||||
"name": "solution",
|
||||
"type": "ReadySolution"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Set a solution in the queue, to be handed out to the client of this pallet in the next",
|
||||
" call to `ElectionProvider::elect`.",
|
||||
"",
|
||||
" This can only be set by `T::ForceOrigin`, and only when the phase is `Emergency`.",
|
||||
"",
|
||||
" The solution is not checked for any feasibility and is assumed to be trustworthy, as any",
|
||||
" feasibility check itself can in principle cause the election process to fail (due to",
|
||||
" memory/weight constrains)."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "submit",
|
||||
"args": [
|
||||
{
|
||||
"name": "solution",
|
||||
"type": "RawSolution"
|
||||
},
|
||||
{
|
||||
"name": "num_signed_submissions",
|
||||
"type": "u32"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Submit a solution for the signed phase.",
|
||||
"",
|
||||
" The dispatch origin fo this call must be __signed__.",
|
||||
"",
|
||||
" The solution is potentially queued, based on the claimed score and processed at the end",
|
||||
" of the signed phase.",
|
||||
"",
|
||||
" A deposit is reserved and recorded for the solution. Based on the outcome, the solution",
|
||||
" might be rewarded, slashed, or get all or a part of the deposit back.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" Queue size must be provided as witness data.",
|
||||
" # </weight>"
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"name": "SolutionStored",
|
||||
"args": [
|
||||
"ElectionCompute"
|
||||
"ElectionCompute",
|
||||
"bool"
|
||||
],
|
||||
"documentation": [
|
||||
" 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."
|
||||
" solution is unsigned, this means that it has also been processed.",
|
||||
"",
|
||||
" The `bool` is `true` when a previous solution was ejected to make room for this one."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2010,7 +2150,8 @@
|
||||
{
|
||||
"name": "Rewarded",
|
||||
"args": [
|
||||
"AccountId"
|
||||
"AccountId",
|
||||
"Balance"
|
||||
],
|
||||
"documentation": [
|
||||
" An account has been rewarded for their signed submission being finalized."
|
||||
@@ -2019,7 +2160,8 @@
|
||||
{
|
||||
"name": "Slashed",
|
||||
"args": [
|
||||
"AccountId"
|
||||
"AccountId",
|
||||
"Balance"
|
||||
],
|
||||
"documentation": [
|
||||
" An account has been slashed for submitting an invalid signed submission."
|
||||
@@ -2080,6 +2222,62 @@
|
||||
" For example, if it is 5, that means that at least 5 blocks will elapse between attempts",
|
||||
" to submit the worker's solution."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedMaxSubmissions",
|
||||
"type": "u32",
|
||||
"value": "0x0a000000",
|
||||
"documentation": [
|
||||
" Maximum number of signed submissions that can be queued.",
|
||||
"",
|
||||
" It is best to avoid adjusting this during an election, as it impacts downstream data",
|
||||
" structures. In particular, `SignedSubmissionIndices<T>` is bounded on this value. If you",
|
||||
" update this value during an election, you _must_ ensure that",
|
||||
" `SignedSubmissionIndices.len()` is less than or equal to the new value. Otherwise,",
|
||||
" attempts to submit new solutions may cause a runtime panic."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedMaxWeight",
|
||||
"type": "Weight",
|
||||
"value": "0xc07c907c2d010000",
|
||||
"documentation": [
|
||||
" Maximum weight of a signed solution.",
|
||||
"",
|
||||
" This should probably be similar to [`Config::MinerMaxWeight`]."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedRewardBase",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00407a10f35a00000000000000000000",
|
||||
"documentation": [
|
||||
" Base reward for a signed solution"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedDepositBase",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00407a10f35a00000000000000000000",
|
||||
"documentation": [
|
||||
" Base deposit for a signed solution."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedDepositByte",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x0010a5d4e80000000000000000000000",
|
||||
"documentation": [
|
||||
" Per-byte deposit for a signed solution."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedDepositWeight",
|
||||
"type": "BalanceOf",
|
||||
"value": "0x00000000000000000000000000000000",
|
||||
"documentation": [
|
||||
" Per-weight deposit for a signed solution."
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
@@ -2101,11 +2299,53 @@
|
||||
" Submission was too weak, score-wise."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedQueueFull",
|
||||
"documentation": [
|
||||
" The queue was full, and the solution was not better than any of the existing ones."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedCannotPayDeposit",
|
||||
"documentation": [
|
||||
" The origin failed to pay the deposit."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedInvalidWitness",
|
||||
"documentation": [
|
||||
" Witness data to dispatchable is invalid."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "SignedTooMuchWeight",
|
||||
"documentation": [
|
||||
" The signed submission consumes too much weight"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "OcwCallWrongEra",
|
||||
"documentation": [
|
||||
" OCW submitted solution for wrong round"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MissingSnapshotMetadata",
|
||||
"documentation": [
|
||||
" Snapshot metadata should exist but didn't."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InvalidSubmissionIndex",
|
||||
"documentation": [
|
||||
" `Self::insert_submission` returned an invalid index."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CallNotAllowed",
|
||||
"documentation": [
|
||||
" The call is not allowed at this point."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 8
|
||||
@@ -2183,6 +2423,28 @@
|
||||
" Map from all locked \"stash\" accounts to the controller account."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MinNominatorBond",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "BalanceOf"
|
||||
},
|
||||
"fallback": "0x00000000000000000000000000000000",
|
||||
"documentation": [
|
||||
" The minimum active bond to become and maintain the role of a nominator."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MinValidatorBond",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "BalanceOf"
|
||||
},
|
||||
"fallback": "0x00000000000000000000000000000000",
|
||||
"documentation": [
|
||||
" The minimum active bond to become and maintain the role of a validator."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Ledger",
|
||||
"modifier": "Optional",
|
||||
@@ -2228,7 +2490,33 @@
|
||||
},
|
||||
"fallback": "0x0000",
|
||||
"documentation": [
|
||||
" The map from (wannabe) validator stash key to the preferences of that validator."
|
||||
" The map from (wannabe) validator stash key to the preferences of that validator.",
|
||||
"",
|
||||
" When updating this storage item, you must also update the `CounterForValidators`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CounterForValidators",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "u32"
|
||||
},
|
||||
"fallback": "0x00000000",
|
||||
"documentation": [
|
||||
" A tracker to keep count of the number of items in the `Validators` map."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxValidatorsCount",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "u32"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The maximum validator count before we stop allowing new validators to join.",
|
||||
"",
|
||||
" When this value is not set, no limits are enforced."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2244,7 +2532,33 @@
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The map from nominator stash key to the set of stash keys of all validators to nominate."
|
||||
" The map from nominator stash key to the set of stash keys of all validators to nominate.",
|
||||
"",
|
||||
" When updating this storage item, you must also update the `CounterForNominators`."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CounterForNominators",
|
||||
"modifier": "Default",
|
||||
"type": {
|
||||
"plain": "u32"
|
||||
},
|
||||
"fallback": "0x00000000",
|
||||
"documentation": [
|
||||
" A tracker to keep count of the number of items in the `Nominators` map."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "MaxNominatorsCount",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "u32"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The maximum nominator count before we stop allowing new validators to join.",
|
||||
"",
|
||||
" When this value is not set, no limits are enforced."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -2580,13 +2894,26 @@
|
||||
"type": {
|
||||
"plain": "Releases"
|
||||
},
|
||||
"fallback": "0x05",
|
||||
"fallback": "0x06",
|
||||
"documentation": [
|
||||
" True if network has been upgraded to this version.",
|
||||
" Storage version of the pallet.",
|
||||
"",
|
||||
" This is set to v6.0.0 for new networks."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ChillThreshold",
|
||||
"modifier": "Optional",
|
||||
"type": {
|
||||
"plain": "Percent"
|
||||
},
|
||||
"fallback": "0x00",
|
||||
"documentation": [
|
||||
" The threshold for when users can start calling `chill_other` for other validators / nominators.",
|
||||
" The threshold is compared to the actual number of validators / nominators (`CountFor*`) in",
|
||||
" the system compared to the configured max (`Max*Count`)."
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2684,6 +3011,9 @@
|
||||
" can co-exists at the same time. In that case, [`Call::withdraw_unbonded`] need",
|
||||
" to be called first to remove some of the chunks (if possible).",
|
||||
"",
|
||||
" If a user encounters the `InsufficientBond` error when calling this extrinsic,",
|
||||
" they should call `chill` first in order to free up their bonded funds.",
|
||||
"",
|
||||
" The dispatch origin for this call must be _Signed_ by the controller, not the stash.",
|
||||
" And, it can be only called when [`EraElectionStatus`] is `Closed`.",
|
||||
"",
|
||||
@@ -2947,6 +3277,12 @@
|
||||
"",
|
||||
" The dispatch origin must be Root.",
|
||||
"",
|
||||
" # Warning",
|
||||
"",
|
||||
" The election process starts multiple blocks before the end of the era.",
|
||||
" Thus the election process may be ongoing when this is called. In this case the",
|
||||
" election will continue until the next era is triggered.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" - No arguments.",
|
||||
" - Weight: O(1)",
|
||||
@@ -2963,6 +3299,12 @@
|
||||
"",
|
||||
" The dispatch origin must be Root.",
|
||||
"",
|
||||
" # Warning",
|
||||
"",
|
||||
" The election process starts multiple blocks before the end of the era.",
|
||||
" If this is called just before a new era is triggered, the election process may not",
|
||||
" have enough blocks to get a result.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" - No arguments.",
|
||||
" - Weight: O(1)",
|
||||
@@ -3022,6 +3364,12 @@
|
||||
"",
|
||||
" The dispatch origin must be Root.",
|
||||
"",
|
||||
" # Warning",
|
||||
"",
|
||||
" The election process starts multiple blocks before the end of the era.",
|
||||
" If this is called just before a new era is triggered, the election process may not",
|
||||
" have enough blocks to get a result.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" - Weight: O(1)",
|
||||
" - Write: ForceEra",
|
||||
@@ -3213,6 +3561,79 @@
|
||||
" Note: Making this call only makes sense if you first set the validator preferences to",
|
||||
" block any further nominations."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "set_staking_limits",
|
||||
"args": [
|
||||
{
|
||||
"name": "min_nominator_bond",
|
||||
"type": "BalanceOf"
|
||||
},
|
||||
{
|
||||
"name": "min_validator_bond",
|
||||
"type": "BalanceOf"
|
||||
},
|
||||
{
|
||||
"name": "max_nominator_count",
|
||||
"type": "Option<u32>"
|
||||
},
|
||||
{
|
||||
"name": "max_validator_count",
|
||||
"type": "Option<u32>"
|
||||
},
|
||||
{
|
||||
"name": "threshold",
|
||||
"type": "Option<Percent>"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Update the various staking limits this pallet.",
|
||||
"",
|
||||
" * `min_nominator_bond`: The minimum active bond needed to be a nominator.",
|
||||
" * `min_validator_bond`: The minimum active bond needed to be a validator.",
|
||||
" * `max_nominator_count`: The max number of users who can be a nominator at once.",
|
||||
" When set to `None`, no limit is enforced.",
|
||||
" * `max_validator_count`: The max number of users who can be a validator at once.",
|
||||
" When set to `None`, no limit is enforced.",
|
||||
"",
|
||||
" Origin must be Root to call this function.",
|
||||
"",
|
||||
" NOTE: Existing nominators and validators will not be affected by this update.",
|
||||
" to kick people under the new limits, `chill_other` should be called."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "chill_other",
|
||||
"args": [
|
||||
{
|
||||
"name": "controller",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"documentation": [
|
||||
" Declare a `controller` to stop participating as either a validator or nominator.",
|
||||
"",
|
||||
" Effects will be felt at the beginning of the next era.",
|
||||
"",
|
||||
" The dispatch origin for this call must be _Signed_, but can be called by anyone.",
|
||||
"",
|
||||
" If the caller is the same as the controller being targeted, then no further checks are",
|
||||
" enforced, and this function behaves just like `chill`.",
|
||||
"",
|
||||
" If the caller is different than the controller being targeted, the following conditions",
|
||||
" must be met:",
|
||||
" * A `ChillThreshold` must be set and checked which defines how close to the max",
|
||||
" nominators or validators we must reach before users can start chilling one-another.",
|
||||
" * A `MaxNominatorCount` and `MaxValidatorCount` must be set which is used to determine",
|
||||
" how close we are to the threshold.",
|
||||
" * A `MinNominatorBond` and `MinValidatorBond` must be set and checked, which determines",
|
||||
" if this is a person that should be chilled because they have not met the threshold",
|
||||
" bond required.",
|
||||
"",
|
||||
" This can be helpful if bond requirements are updated, and we need to remove old users",
|
||||
" who do not satisfy these requirements.",
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
@@ -3310,6 +3731,13 @@
|
||||
"documentation": [
|
||||
" A nominator has been kicked from a validator. \\[nominator, stash\\]"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "StakingElectionFailed",
|
||||
"args": [],
|
||||
"documentation": [
|
||||
" The election failed. No new era is planned."
|
||||
]
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
@@ -3336,9 +3764,8 @@
|
||||
"documentation": [
|
||||
" Number of eras that slashes are deferred by, after computation.",
|
||||
"",
|
||||
" This should be less than the bonding duration.",
|
||||
" Set to 0 if slashes should be applied immediately, without opportunity for",
|
||||
" intervention."
|
||||
" This should be less than the bonding duration. Set to 0 if slashes",
|
||||
" should be applied immediately, without opportunity for intervention."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3356,9 +3783,7 @@
|
||||
"name": "MaxNominations",
|
||||
"type": "u32",
|
||||
"value": "0x10000000",
|
||||
"documentation": [
|
||||
" Maximum number of nominations per nominator."
|
||||
]
|
||||
"documentation": []
|
||||
}
|
||||
],
|
||||
"errors": [
|
||||
@@ -3405,9 +3830,9 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InsufficientValue",
|
||||
"name": "InsufficientBond",
|
||||
"documentation": [
|
||||
" Can not bond with value less than minimum balance."
|
||||
" Can not bond with value less than minimum required."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -3481,6 +3906,26 @@
|
||||
"documentation": [
|
||||
" A nomination target was supplied that was blocked or otherwise not a validator."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "CannotChillOther",
|
||||
"documentation": [
|
||||
" The user has enough bond and thus cannot be chilled forcefully by an external person."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TooManyNominators",
|
||||
"documentation": [
|
||||
" There are too many nominators in the system. Governance needs to adjust the staking settings",
|
||||
" to keep things safe for the runtime."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "TooManyValidators",
|
||||
"documentation": [
|
||||
" There are too many validators in the system. Governance needs to adjust the staking settings",
|
||||
" to keep things safe for the runtime."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 9
|
||||
@@ -3627,7 +4072,7 @@
|
||||
" Actual cost depends on the number of length of `T::Keys::key_ids()` which is fixed.",
|
||||
" - DbReads: `T::ValidatorIdOf`, `NextKeys`, `origin account`",
|
||||
" - DbWrites: `NextKeys`, `origin account`",
|
||||
" - DbWrites per key id: `KeyOwnder`",
|
||||
" - DbWrites per key id: `KeyOwner`",
|
||||
" # </weight>"
|
||||
]
|
||||
}
|
||||
@@ -7317,7 +7762,7 @@
|
||||
{
|
||||
"name": "Schedule",
|
||||
"type": "Schedule",
|
||||
"value": "0x0400000000020000000100008000000010000000001000000001000020000000200000000040000000000200020000008e060000e2fc0100cd0f030009170000861d0000030c00001f1800005629000082000000b059010055810200c00b000029070000590800003b060000b8160000a61a0000600700000de8b607b10600007d060000e6090000dc070000d5050000d70500005b06000043090000390900001c0900004d0900001d09000030090000180900004109000038090000680900007d080000f80800008e08000003220000371e0000fd210000e71d0000a6080000ab080000d5080000db090000d8090000190a00001e0b00000c09000052f72400000000006ee52400000000009c212400000000003039500000000000702a240000000000644f240000000000ce3a240000000000dc54240000000000f0182400000000001e31240000000000b0c14700000000009a12120000000000c0406d0000000000f4000000000000007854420000000000e302000000000000f03a7d2000000000672000000000000040a9e729000000002c1e000000000000650f000000000000ac13aa09000000006c835b0000000000c229870000000000dad6c907000000009409000000000000c0681300000000007c0b1900000000000210b20900000000b502000000000000fee1300800000000c274080200000000db050000000000006c548a0a00000000aab1da0f00000000f50e000000000000608b390800000000500200000000000002030000000000008e63f022000000007e2100000000000067020000000000002c030000000000002909000000000000a41f230000000000c3120000000000007ca6230000000000020d00000000000000bd1f00000000001506000000000000a6a81f0000000000fc05000000000000",
|
||||
"value": "0x0400000000020000000100008000000010000000001000000001000020000000200000000040000000000200020000008e0f0000b04602009a8c0300a9720000767600005e380000ea5e00000753000097000000579e030088130500b60000007a170000c11100005721000099370000483a0000d0110000d8d12c08bc4300005c430000bb2e0000a942000000260000b72300009c370000ad540000de540000ca5400000354000018550000e553000011550000c053000007540000da540000a0530000e85300008d5400004a690000bd680000a56a000096670000b053000013540000055400006a5500009255000060550000f455000033550000cae32900000000007a332a00000000004041290000000000a6fb5d000000000060c02a0000000000e6d6290000000000065329000000000062002a0000000000d425290000000000b0522a00000000005cb3540000000000b41c1600000000008057640000000000000100000000000008f6380000000000710200000000000078d68a210000000098d6de2a000000007c75640900000000466d6f000000000070baac0000000000ec73de07000000007406000000000000922c190000000000fc9f1d00000000008618ee0900000000450200000000000082dc6108000000003e573102000000002704000000000000cc94430b000000009406e1100000000096fa930800000000dc010000000000009c020000000000001843c12400000000f001000000000000b80200000000000094070000000000008a9b2a0000000000561200000000000046432b0000000000ab0c000000000000c08c260000000000b005000000000000acd2260000000000b005000000000000",
|
||||
"documentation": [
|
||||
" Cost schedule and limits."
|
||||
]
|
||||
@@ -7403,7 +7848,7 @@
|
||||
{
|
||||
"name": "DeletionQueueDepth",
|
||||
"type": "u32",
|
||||
"value": "0x85040000",
|
||||
"value": "0x1a040000",
|
||||
"documentation": [
|
||||
" The maximum number of tries that can be queued for deletion."
|
||||
]
|
||||
@@ -7561,17 +8006,16 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ReentranceDenied",
|
||||
"name": "TerminatedWhileReentrant",
|
||||
"documentation": [
|
||||
" The action performed is not allowed while the contract performing it is already",
|
||||
" on the call stack. Those actions are contract self destruction and restoration",
|
||||
" of a tombstone."
|
||||
" Termination of a contract is not allowed while the contract is already",
|
||||
" on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "InputAlreadyRead",
|
||||
"name": "InputForwarded",
|
||||
"documentation": [
|
||||
" `seal_input` was called twice from the same contract execution context."
|
||||
" `seal_call` forwarded this contracts input. It therefore is no longer available."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -7647,6 +8091,12 @@
|
||||
"documentation": [
|
||||
" The debug message specified to `seal_debug_message` does contain invalid UTF-8."
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ReentranceDenied",
|
||||
"documentation": [
|
||||
" A call tried to invoke a contract that is flagged as non-reentrant."
|
||||
]
|
||||
}
|
||||
],
|
||||
"index": 18
|
||||
@@ -7951,7 +8401,7 @@
|
||||
{
|
||||
"name": "AuthorityDiscovery",
|
||||
"storage": null,
|
||||
"calls": [],
|
||||
"calls": null,
|
||||
"events": null,
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
@@ -8018,7 +8468,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"calls": [],
|
||||
"calls": null,
|
||||
"events": [
|
||||
{
|
||||
"name": "Offence",
|
||||
@@ -8066,7 +8516,7 @@
|
||||
}
|
||||
]
|
||||
},
|
||||
"calls": [],
|
||||
"calls": null,
|
||||
"events": null,
|
||||
"constants": [],
|
||||
"errors": [],
|
||||
@@ -12825,6 +13275,10 @@
|
||||
"",
|
||||
" Emits `Destroyed` event when successful.",
|
||||
"",
|
||||
" NOTE: It can be helpful to first freeze an asset before destroying it so that you",
|
||||
" can provide accurate witness information and prevent users from manipulating state",
|
||||
" in a way that can make it harder to destroy.",
|
||||
"",
|
||||
" Weight: `O(c + p + a)` where:",
|
||||
" - `c = (witness.accounts - witness.sufficients)`",
|
||||
" - `s = witness.sufficients`",
|
||||
@@ -14629,7 +15083,7 @@
|
||||
"",
|
||||
" Weight: `O(n + m)` where:",
|
||||
" - `n = witness.instances`",
|
||||
" - `m = witness.instance_metdadatas`",
|
||||
" - `m = witness.instance_metadatas`",
|
||||
" - `a = witness.attributes`"
|
||||
]
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -13,10 +13,13 @@ import { stringCamelCase } from '@polkadot/util';
|
||||
// in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
|
||||
const KNOWN_ORIGINS: Record<string, string> = {
|
||||
/* eslint-disable sort-keys */
|
||||
// Substrate/Polkadot
|
||||
// Substrate
|
||||
Council: 'CollectiveOrigin',
|
||||
System: 'SystemOrigin',
|
||||
TechnicalCommittee: 'CollectiveOrigin',
|
||||
// Polkadot
|
||||
Xcm: 'XcmOrigin',
|
||||
XcmPallet: 'XcmOrigin',
|
||||
// Acala
|
||||
Authority: 'AuthorityOrigin',
|
||||
GeneralCouncil: 'CollectiveOrigin'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
@@ -19,14 +19,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.14.5",
|
||||
"@polkadot/metadata": "4.14.1",
|
||||
"@polkadot/rpc-provider": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/metadata": "4.17.1",
|
||||
"@polkadot/rpc-provider": "4.17.1",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/x-rxjs": "^6.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.8.1"
|
||||
"@polkadot/keyring": "^6.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.17.1' };
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { jest } from '@jest/globals';
|
||||
|
||||
import { of, timer } from '@polkadot/x-rxjs';
|
||||
|
||||
import { drr } from '.';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
@@ -19,18 +19,18 @@
|
||||
"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.14.5",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/util-crypto": "^6.8.1",
|
||||
"@polkadot/x-fetch": "^6.8.1",
|
||||
"@polkadot/x-global": "^6.8.1",
|
||||
"@polkadot/x-ws": "^6.8.1",
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/util-crypto": "^6.11.1",
|
||||
"@polkadot/x-fetch": "^6.11.1",
|
||||
"@polkadot/x-global": "^6.11.1",
|
||||
"@polkadot/x-ws": "^6.11.1",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.8.1",
|
||||
"@polkadot/metadata": "4.14.1",
|
||||
"@polkadot/keyring": "^6.11.1",
|
||||
"@polkadot/metadata": "4.17.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.1.0"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.17.1' };
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
import type { Mock } from './../mock/types';
|
||||
|
||||
import { jest } from '@jest/globals';
|
||||
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { WsProvider } from './';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
@@ -26,14 +26,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.14.5",
|
||||
"@babel/core": "^7.14.6",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.5",
|
||||
"@polkadot/api": "4.14.1",
|
||||
"@polkadot/metadata": "4.14.1",
|
||||
"@polkadot/rpc-provider": "4.14.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api": "4.17.1",
|
||||
"@polkadot/metadata": "4.17.1",
|
||||
"@polkadot/rpc-provider": "4.17.1",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.0.1"
|
||||
|
||||
@@ -54,7 +54,7 @@ function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
? `${md}\n\n` // empty line
|
||||
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
|
||||
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
|
||||
: `${md}${docLine.replace(/^#{1,3} /, '#### ')} `
|
||||
: `${md} ${docLine.replace(/^#{1,3} /, '#### ')} `
|
||||
, '')
|
||||
.replace(/#### <weight>/g, '<weight>')
|
||||
.replace(/<weight>(.|\n)*?<\/weight>/g, '')
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.17.1' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
@@ -19,9 +19,9 @@
|
||||
"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.14.5",
|
||||
"@polkadot/networks": "^6.8.1",
|
||||
"@polkadot/types": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/networks": "^6.11.1",
|
||||
"@polkadot/types": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
balances: {
|
||||
Status: 'BalanceStatus'
|
||||
},
|
||||
beefy: {
|
||||
AuthorityId: 'BeefyId'
|
||||
},
|
||||
contracts: {
|
||||
StorageKey: 'ContractStorageKey'
|
||||
},
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.14.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.17.1' };
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
CompactAssignments: 'CompactAssignmentsWith24',
|
||||
RawSolution: 'RawSolutionWith24',
|
||||
Keys: 'SessionKeys6',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement', 'CancelProxy']
|
||||
@@ -16,9 +18,9 @@ const addrIndicesTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'LookupSource',
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'IndicesLookupSource',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithCommission'
|
||||
};
|
||||
|
||||
@@ -26,9 +28,9 @@ const addrAccountIdTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithCommission'
|
||||
};
|
||||
|
||||
@@ -42,6 +44,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchError: 'DispatchErrorTo198',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Heartbeat: 'HeartbeatTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -60,6 +63,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Heartbeat: 'HeartbeatTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -79,6 +83,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Heartbeat: 'HeartbeatTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -97,6 +102,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Heartbeat: 'HeartbeatTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
@@ -112,6 +118,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Heartbeat: 'HeartbeatTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
@@ -126,6 +133,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
...addrAccountIdTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Heartbeat: 'HeartbeatTo244',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259'
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
Keys: 'SessionKeys6',
|
||||
ProxyType: {
|
||||
_enum: {
|
||||
@@ -23,10 +25,8 @@ const sharedTypes = {
|
||||
const addrAccountIdTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
ValidatorPrefs: 'ValidatorPrefsWithCommission'
|
||||
};
|
||||
|
||||
@@ -70,21 +70,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [28, 29],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16',
|
||||
AccountInfo: 'AccountInfoWithDualRefCount'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [30, 9000],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsWith16',
|
||||
RawSolution: 'RawSolutionWith16'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [9010, undefined],
|
||||
minmax: [30, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022],
|
||||
[3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027],
|
||||
[6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010], [7668600, 9030],
|
||||
[7812476, 9040]
|
||||
[7812476, 9040], [8010981, 9050], [8073833, 9070]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -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], [3899547, 28], [4345767, 29], [4876134, 30]
|
||||
[3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30], [5661442, 9050]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -10,7 +10,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
|
||||
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49],
|
||||
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010], [5784566, 9030],
|
||||
[5879822, 9031], [5896856, 9032], [5897316, 9033]
|
||||
[5879822, 9031], [5896856, 9032], [5897316, 9033], [6117927, 9050], [6210274, 9070]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "4.14.1",
|
||||
"version": "4.17.1",
|
||||
"type": "module",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
@@ -19,14 +19,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.5",
|
||||
"@polkadot/metadata": "4.14.1",
|
||||
"@polkadot/util": "^6.8.1",
|
||||
"@polkadot/util-crypto": "^6.8.1",
|
||||
"@polkadot/x-rxjs": "^6.8.1"
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/metadata": "4.17.1",
|
||||
"@polkadot/util": "^6.11.1",
|
||||
"@polkadot/util-crypto": "^6.11.1",
|
||||
"@polkadot/x-rxjs": "^6.11.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.8.1",
|
||||
"@polkadot/keyring": "^6.11.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interface
|
||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
|
||||
import type { BeefyCommitment, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BridgedBlockHash, BridgedBlockNumber, BridgedHeader, InitializationData } from '@polkadot/types/interfaces/bridges';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
@@ -48,16 +48,16 @@ import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray
|
||||
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactAssignmentsTo265, CompactAssignmentsWith16, CompactAssignmentsWith24, 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, RawSolutionTo265, RawSolutionWith16, RawSolutionWith24, 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 { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactAssignmentsTo265, CompactAssignmentsWith16, CompactAssignmentsWith24, 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, RawSolutionTo265, RawSolutionWith16, RawSolutionWith24, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SignedSubmission, SignedSubmissionOf, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, SubmissionIndicesOf, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ApiId, BlockTrace, BlockTraceEvent, BlockTraceEventData, BlockTraceSpan, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, RuntimeVersionPartial, StorageChangeSet, TraceBlockResponse, TraceError } from '@polkadot/types/interfaces/state';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, ArithmeticError, 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, TokenError, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithRefCountU8, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, ArithmeticError, 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, TokenError, 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 { ClassDetails, ClassId, ClassMetadata, DepositBalance, DepositBalanceOf, DestroyWitness, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
|
||||
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
import type { AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, BodyId, BodyPart, BodyPartAtLeastProportion, BodyPartFraction, BodyPartMoreThanProportion, DoubleEncodedCall, InboundStatus, Junction, MultiAsset, MultiAssetAbstractFungible, MultiAssetAbstractNonFungible, MultiAssetConcreteFungible, MultiAssetConcreteNonFungible, MultiLocation, NetworkId, OutboundStatus, Outcome, PluralityJunction, QueueConfigData, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, Xcm, XcmAssetEffects, XcmError, XcmHrmpChannelAccepted, XcmHrmpChannelClosing, XcmHrmpNewChannelOpenRequest, XcmOrder, XcmOrderBuyExecution, XcmOrderDepositAsset, XcmOrderDepositReserveAsset, XcmOrderExchangeAsset, XcmOrderInitiateReserveWithdraw, XcmOrderInitiateTeleport, XcmOrderQueryHolding, XcmOriginKind, XcmQueryResponse, XcmRelayedFrom, XcmReserveAssetDeposit, XcmResponse, XcmTeleportAsset, XcmTransact, XcmTransferAsset, XcmTransferReserveAsset, XcmWithdrawAsset, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
|
||||
import type { AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, BodyId, BodyPart, BodyPartAtLeastProportion, BodyPartFraction, BodyPartMoreThanProportion, DoubleEncodedCall, InboundStatus, Junction, MultiAsset, MultiAssetAbstractFungible, MultiAssetAbstractNonFungible, MultiAssetConcreteFungible, MultiAssetConcreteNonFungible, MultiLocation, NetworkId, OutboundStatus, Outcome, PluralityJunction, QueueConfigData, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, Xcm, XcmAssetEffects, XcmError, XcmHrmpChannelAccepted, XcmHrmpChannelClosing, XcmHrmpNewChannelOpenRequest, XcmOrder, XcmOrderBuyExecution, XcmOrderDepositAsset, XcmOrderDepositReserveAsset, XcmOrderExchangeAsset, XcmOrderInitiateReserveWithdraw, XcmOrderInitiateTeleport, XcmOrderQueryHolding, XcmOrigin, XcmOriginKind, XcmQueryResponse, XcmRelayedFrom, XcmReserveAssetDeposit, XcmResponse, XcmTeleportAsset, XcmTransact, XcmTransferAsset, XcmTransferReserveAsset, XcmWithdrawAsset, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
|
||||
|
||||
declare module '@polkadot/types/types/registry' {
|
||||
export interface InterfaceTypes {
|
||||
@@ -168,6 +168,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<AccountInfoWithDualRefCount>': Option<AccountInfoWithDualRefCount>;
|
||||
'Option<AccountInfoWithProviders>': Option<AccountInfoWithProviders>;
|
||||
'Option<AccountInfoWithRefCount>': Option<AccountInfoWithRefCount>;
|
||||
'Option<AccountInfoWithRefCountU8>': Option<AccountInfoWithRefCountU8>;
|
||||
'Option<AccountInfoWithTripleRefCount>': Option<AccountInfoWithTripleRefCount>;
|
||||
'Option<AccountKey20Junction>': Option<AccountKey20Junction>;
|
||||
'Option<AccountStatus>': Option<AccountStatus>;
|
||||
@@ -226,6 +227,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<BalanceOf>': Option<BalanceOf>;
|
||||
'Option<BalanceStatus>': Option<BalanceStatus>;
|
||||
'Option<BeefyCommitment>': Option<BeefyCommitment>;
|
||||
'Option<BeefyId>': Option<BeefyId>;
|
||||
'Option<BeefyKey>': Option<BeefyKey>;
|
||||
'Option<BeefyNextAuthoritySet>': Option<BeefyNextAuthoritySet>;
|
||||
'Option<BeefyPayload>': Option<BeefyPayload>;
|
||||
@@ -840,6 +842,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<SignedBlock>': Option<SignedBlock>;
|
||||
'Option<SignedBlockWithJustification>': Option<SignedBlockWithJustification>;
|
||||
'Option<SignedBlockWithJustifications>': Option<SignedBlockWithJustifications>;
|
||||
'Option<SignedSubmission>': Option<SignedSubmission>;
|
||||
'Option<SignedSubmissionOf>': Option<SignedSubmissionOf>;
|
||||
'Option<SignerPayload>': Option<SignerPayload>;
|
||||
'Option<SigningContext>': Option<SigningContext>;
|
||||
'Option<SiLookupTypeId>': Option<SiLookupTypeId>;
|
||||
@@ -911,6 +915,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<StoredState>': Option<StoredState>;
|
||||
'Option<StrikeCount>': Option<StrikeCount>;
|
||||
'Option<SubId>': Option<SubId>;
|
||||
'Option<SubmissionIndicesOf>': Option<SubmissionIndicesOf>;
|
||||
'Option<SyncState>': Option<SyncState>;
|
||||
'Option<SystemInherentData>': Option<SystemInherentData>;
|
||||
'Option<SystemOrigin>': Option<SystemOrigin>;
|
||||
@@ -1018,6 +1023,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<XcmOrderInitiateReserveWithdraw>': Option<XcmOrderInitiateReserveWithdraw>;
|
||||
'Option<XcmOrderInitiateTeleport>': Option<XcmOrderInitiateTeleport>;
|
||||
'Option<XcmOrderQueryHolding>': Option<XcmOrderQueryHolding>;
|
||||
'Option<XcmOrigin>': Option<XcmOrigin>;
|
||||
'Option<XcmOriginKind>': Option<XcmOriginKind>;
|
||||
'Option<XcmpMessageFormat>': Option<XcmpMessageFormat>;
|
||||
'Option<XcmQueryResponse>': Option<XcmQueryResponse>;
|
||||
@@ -1042,6 +1048,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<AccountInfoWithDualRefCount>': Vec<AccountInfoWithDualRefCount>;
|
||||
'Vec<AccountInfoWithProviders>': Vec<AccountInfoWithProviders>;
|
||||
'Vec<AccountInfoWithRefCount>': Vec<AccountInfoWithRefCount>;
|
||||
'Vec<AccountInfoWithRefCountU8>': Vec<AccountInfoWithRefCountU8>;
|
||||
'Vec<AccountInfoWithTripleRefCount>': Vec<AccountInfoWithTripleRefCount>;
|
||||
'Vec<AccountKey20Junction>': Vec<AccountKey20Junction>;
|
||||
'Vec<AccountStatus>': Vec<AccountStatus>;
|
||||
@@ -1100,6 +1107,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<BalanceOf>': Vec<BalanceOf>;
|
||||
'Vec<BalanceStatus>': Vec<BalanceStatus>;
|
||||
'Vec<BeefyCommitment>': Vec<BeefyCommitment>;
|
||||
'Vec<BeefyId>': Vec<BeefyId>;
|
||||
'Vec<BeefyKey>': Vec<BeefyKey>;
|
||||
'Vec<BeefyNextAuthoritySet>': Vec<BeefyNextAuthoritySet>;
|
||||
'Vec<BeefyPayload>': Vec<BeefyPayload>;
|
||||
@@ -1714,6 +1722,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<SignedBlock>': Vec<SignedBlock>;
|
||||
'Vec<SignedBlockWithJustification>': Vec<SignedBlockWithJustification>;
|
||||
'Vec<SignedBlockWithJustifications>': Vec<SignedBlockWithJustifications>;
|
||||
'Vec<SignedSubmission>': Vec<SignedSubmission>;
|
||||
'Vec<SignedSubmissionOf>': Vec<SignedSubmissionOf>;
|
||||
'Vec<SignerPayload>': Vec<SignerPayload>;
|
||||
'Vec<SigningContext>': Vec<SigningContext>;
|
||||
'Vec<SiLookupTypeId>': Vec<SiLookupTypeId>;
|
||||
@@ -1785,6 +1795,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<StoredState>': Vec<StoredState>;
|
||||
'Vec<StrikeCount>': Vec<StrikeCount>;
|
||||
'Vec<SubId>': Vec<SubId>;
|
||||
'Vec<SubmissionIndicesOf>': Vec<SubmissionIndicesOf>;
|
||||
'Vec<SyncState>': Vec<SyncState>;
|
||||
'Vec<SystemInherentData>': Vec<SystemInherentData>;
|
||||
'Vec<SystemOrigin>': Vec<SystemOrigin>;
|
||||
@@ -1892,6 +1903,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<XcmOrderInitiateReserveWithdraw>': Vec<XcmOrderInitiateReserveWithdraw>;
|
||||
'Vec<XcmOrderInitiateTeleport>': Vec<XcmOrderInitiateTeleport>;
|
||||
'Vec<XcmOrderQueryHolding>': Vec<XcmOrderQueryHolding>;
|
||||
'Vec<XcmOrigin>': Vec<XcmOrigin>;
|
||||
'Vec<XcmOriginKind>': Vec<XcmOriginKind>;
|
||||
'Vec<XcmpMessageFormat>': Vec<XcmpMessageFormat>;
|
||||
'Vec<XcmQueryResponse>': Vec<XcmQueryResponse>;
|
||||
@@ -1916,6 +1928,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountInfoWithDualRefCount: AccountInfoWithDualRefCount;
|
||||
AccountInfoWithProviders: AccountInfoWithProviders;
|
||||
AccountInfoWithRefCount: AccountInfoWithRefCount;
|
||||
AccountInfoWithRefCountU8: AccountInfoWithRefCountU8;
|
||||
AccountInfoWithTripleRefCount: AccountInfoWithTripleRefCount;
|
||||
AccountKey20Junction: AccountKey20Junction;
|
||||
AccountStatus: AccountStatus;
|
||||
@@ -1974,6 +1987,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
BalanceOf: BalanceOf;
|
||||
BalanceStatus: BalanceStatus;
|
||||
BeefyCommitment: BeefyCommitment;
|
||||
BeefyId: BeefyId;
|
||||
BeefyKey: BeefyKey;
|
||||
BeefyNextAuthoritySet: BeefyNextAuthoritySet;
|
||||
BeefyPayload: BeefyPayload;
|
||||
@@ -2588,6 +2602,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
SignedBlock: SignedBlock;
|
||||
SignedBlockWithJustification: SignedBlockWithJustification;
|
||||
SignedBlockWithJustifications: SignedBlockWithJustifications;
|
||||
SignedSubmission: SignedSubmission;
|
||||
SignedSubmissionOf: SignedSubmissionOf;
|
||||
SignerPayload: SignerPayload;
|
||||
SigningContext: SigningContext;
|
||||
SiLookupTypeId: SiLookupTypeId;
|
||||
@@ -2659,6 +2675,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
StoredState: StoredState;
|
||||
StrikeCount: StrikeCount;
|
||||
SubId: SubId;
|
||||
SubmissionIndicesOf: SubmissionIndicesOf;
|
||||
SyncState: SyncState;
|
||||
SystemInherentData: SystemInherentData;
|
||||
SystemOrigin: SystemOrigin;
|
||||
@@ -2766,6 +2783,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
XcmOrderInitiateReserveWithdraw: XcmOrderInitiateReserveWithdraw;
|
||||
XcmOrderInitiateTeleport: XcmOrderInitiateTeleport;
|
||||
XcmOrderQueryHolding: XcmOrderQueryHolding;
|
||||
XcmOrigin: XcmOrigin;
|
||||
XcmOriginKind: XcmOriginKind;
|
||||
XcmpMessageFormat: XcmpMessageFormat;
|
||||
XcmQueryResponse: XcmQueryResponse;
|
||||
|
||||
@@ -50,7 +50,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
/**
|
||||
* @description The length of the value
|
||||
*/
|
||||
public get length (): number {
|
||||
public override get length (): number {
|
||||
// only included here since we ignore inherited docs
|
||||
return super.length;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
// Overwrite the default toString representation of Array.
|
||||
const data = this.map((entry): string =>
|
||||
entry.toString()
|
||||
@@ -135,35 +135,35 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
/**
|
||||
* @description Concatenates two arrays
|
||||
*/
|
||||
public concat (other: T[]): T[] {
|
||||
public override concat (other: T[]): T[] {
|
||||
return this.toArray().concat(other instanceof AbstractArray ? other.toArray() : other);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Filters the array with the callback
|
||||
*/
|
||||
public filter (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: unknown): T[] {
|
||||
public override filter (callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: unknown): T[] {
|
||||
return this.toArray().filter(callbackfn, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Maps the array with the callback
|
||||
*/
|
||||
public map<U> (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): U[] {
|
||||
public override map<U> (callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: unknown): U[] {
|
||||
return this.toArray().map(callbackfn, thisArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the array includes a specific value
|
||||
*/
|
||||
public includes (check: unknown): boolean {
|
||||
public override includes (check: unknown): boolean {
|
||||
return this.some((value: T) => value.eq(check));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a slice of an array
|
||||
*/
|
||||
public slice (start?: number, end?: number): T[] {
|
||||
public override slice (start?: number, end?: number): T[] {
|
||||
return this.toArray().slice(start, end);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
/**
|
||||
* @description Returns the number of bits in the value
|
||||
*/
|
||||
public bitLength (): number {
|
||||
public override bitLength (): number {
|
||||
return this.#bitLength;
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
public eq (other?: unknown): boolean {
|
||||
public override eq (other?: unknown): boolean {
|
||||
// Here we are actually overriding the built-in .eq to take care of both
|
||||
// number and BN inputs (no `.eqn` needed) - numbers will be converted
|
||||
return super.eq(
|
||||
@@ -192,7 +192,7 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (onlyHex = false): any {
|
||||
public override toJSON (onlyHex = false): any {
|
||||
// FIXME this return type should by string | number, however BN returns string
|
||||
// Options here are
|
||||
// - super.bitLength() - the actual used bits
|
||||
@@ -218,7 +218,7 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
* @description Returns the string representation of the value
|
||||
* @param base The base to use for the conversion
|
||||
*/
|
||||
public toString (base?: number): string {
|
||||
public override toString (base?: number): string {
|
||||
// only included here since we do not inherit docs
|
||||
return super.toString(base);
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
return stringify(this.toJSON());
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ export class CodecDate extends Date implements Codec {
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): any {
|
||||
public override toJSON (): any {
|
||||
// FIXME Return type should be number, but conflicts with Date.toJSON()
|
||||
// which returns string
|
||||
return this.toNumber();
|
||||
@@ -137,7 +137,7 @@ export class CodecDate extends Date implements Codec {
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
// only included here since we do not inherit docs
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export class Int extends AbstractInt {
|
||||
super(registry, value, bitLength);
|
||||
}
|
||||
|
||||
public toRawType (): string {
|
||||
public override toRawType (): string {
|
||||
return typeName || super.toRawType();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -111,7 +111,7 @@ export class Json extends Map<string, any> implements Codec {
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
return stringify(this.toJSON());
|
||||
}
|
||||
|
||||
|
||||
@@ -44,14 +44,14 @@ export class Linkage<T extends Codec> extends Struct {
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
public override toRawType (): string {
|
||||
return `Linkage<${this.next.toRawType(true)}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Custom toU8a which with bare mode does not return the linkage if empty
|
||||
*/
|
||||
public toU8a (): Uint8Array {
|
||||
public override toU8a (): Uint8Array {
|
||||
// As part of a storage query (where these appear), in the case of empty, the values
|
||||
// are NOT populated by the node - follow the same logic, leaving it empty
|
||||
return this.isEmpty
|
||||
|
||||
@@ -182,7 +182,7 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
return stringify(this.toJSON());
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
/**
|
||||
* @description The length of the value
|
||||
*/
|
||||
public get length (): number {
|
||||
public override get length (): number {
|
||||
// only included here since we ignore inherited docs
|
||||
return super.length;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
* @param start The position to start at
|
||||
* @param end The position to end at
|
||||
*/
|
||||
public slice (start?: number, end?: number): Uint8Array {
|
||||
public override slice (start?: number, end?: number): Uint8Array {
|
||||
// Like subarray below, we have to follow this approach since we are extending the TypeArray.
|
||||
// This happens especially when it comes to further extensions, the length may be an override
|
||||
return Uint8Array.from(this).slice(start, end);
|
||||
@@ -104,7 +104,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
* @param begin The position to start at
|
||||
* @param end The position to end at
|
||||
*/
|
||||
public subarray (begin?: number, end?: number): Uint8Array {
|
||||
public override subarray (begin?: number, end?: number): Uint8Array {
|
||||
return Uint8Array.from(this).subarray(begin, end);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ export class Raw extends Uint8Array implements IU8a {
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
return this.toHex();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export class Result<O extends Codec, E extends Codec> extends Enum {
|
||||
super(registry, { Ok, Err }, value);
|
||||
}
|
||||
|
||||
public static with<O extends Codec, E extends Codec> (Types: { Ok: Constructor<O> | keyof InterfaceTypes; Err: Constructor<E> | keyof InterfaceTypes }): Constructor<Result<O, E>> {
|
||||
public static override with<O extends Codec, E extends Codec> (Types: { Ok: Constructor<O> | keyof InterfaceTypes; Err: Constructor<E> | keyof InterfaceTypes }): Constructor<Result<O, E>> {
|
||||
return class extends Result<O, E> {
|
||||
constructor (registry: Registry, value?: unknown) {
|
||||
super(registry, Types.Ok, Types.Err, value);
|
||||
@@ -55,7 +55,7 @@ export class Result<O extends Codec, E extends Codec> extends Enum {
|
||||
/**
|
||||
* @description Checks if the Result has no value
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
public override get isEmpty (): boolean {
|
||||
return this.isOk && this.value.isEmpty;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ export class Result<O extends Codec, E extends Codec> extends Enum {
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
public override toRawType (): string {
|
||||
const Types = this._toRawStruct() as { Ok: unknown; Err: unknown };
|
||||
|
||||
return `Result<${Types.Ok as string},${Types.Err as string}>`;
|
||||
|
||||
@@ -149,7 +149,7 @@ export class CodecSet extends Set<string> implements Codec {
|
||||
/**
|
||||
* @description adds a value to the Set (extended to allow for validity checking)
|
||||
*/
|
||||
public add = (key: string): this => {
|
||||
public override add = (key: string): this => {
|
||||
// ^^^ add = () property done to assign this instance's this, otherwise Set.add creates "some" chaos
|
||||
// we have the isUndefined(this._setValues) in here as well, add is used internally
|
||||
// in the Set constructor (so it is undefined at this point, and should allow)
|
||||
@@ -214,7 +214,7 @@ export class CodecSet extends Set<string> implements Codec {
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
return `[${this.strings.join(', ')}]`;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ function decodeStructFromObject <T> (registry: Registry, Types: ConstructorDef,
|
||||
*/
|
||||
function decodeStruct <T> (registry: Registry, Types: ConstructorDef, value: unknown, jsonMap: Map<any, string>): T {
|
||||
if (isHex(value)) {
|
||||
return decodeStruct(registry, Types, hexToU8a(value.toString()), jsonMap);
|
||||
return decodeStruct(registry, Types, hexToU8a(value), jsonMap);
|
||||
} else if (isU8a(value)) {
|
||||
const keys = Object.keys(Types);
|
||||
const values = decodeU8a(registry, value, Object.values(Types), keys);
|
||||
@@ -245,7 +245,7 @@ export class Struct<
|
||||
* @description Returns a specific names entry in the structure
|
||||
* @param name The name of the entry to retrieve
|
||||
*/
|
||||
public get (name: keyof S): Codec | undefined {
|
||||
public override get (name: keyof S): Codec | undefined {
|
||||
return super.get(name);
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ export class Struct<
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
return stringify(this.toJSON());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export class Tuple extends AbstractArray<Codec> {
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.reduce((total, entry) => total + entry.encodedLength, 0);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ export class Tuple extends AbstractArray<Codec> {
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
public override toString (): string {
|
||||
// Overwrite the default toString representation of Array.
|
||||
return stringify(this.toJSON());
|
||||
}
|
||||
@@ -113,7 +113,7 @@ export class Tuple extends AbstractArray<Codec> {
|
||||
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
public override toU8a (isBare?: boolean): Uint8Array {
|
||||
return u8aConcat(
|
||||
...this.map((entry): Uint8Array =>
|
||||
entry.toU8a(isBare)
|
||||
|
||||
@@ -43,7 +43,7 @@ export class U8aFixed extends Raw {
|
||||
super(registry, value, bitLength);
|
||||
}
|
||||
|
||||
public toRawType (): string {
|
||||
public override toRawType (): string {
|
||||
return typeName || super.toRawType();
|
||||
}
|
||||
};
|
||||
@@ -52,7 +52,7 @@ export class U8aFixed extends Raw {
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
public override toRawType (): string {
|
||||
return `[u8;${this.length}]`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export class UInt extends AbstractInt {
|
||||
super(registry, value, bitLength);
|
||||
}
|
||||
|
||||
public toRawType (): string {
|
||||
public override toRawType (): string {
|
||||
return typeName || super.toRawType();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ export class Vec<T extends Codec> extends AbstractArray<T> {
|
||||
/**
|
||||
* @description Finds the index of the value in the array
|
||||
*/
|
||||
public indexOf (_other?: unknown): number {
|
||||
public override indexOf (_other?: unknown): number {
|
||||
// convert type first, this removes overhead from the eq
|
||||
const other = _other instanceof this._Type
|
||||
? _other
|
||||
|
||||
@@ -62,11 +62,11 @@ export class VecFixed<T extends Codec> extends AbstractArray<T> {
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
public override get encodedLength (): number {
|
||||
return this.reduce((total, entry) => total + entry.encodedLength, 0);
|
||||
}
|
||||
|
||||
public toU8a (): Uint8Array {
|
||||
public override toU8a (): Uint8Array {
|
||||
// we override, we don't add the length prefix for ourselves, and at the same time we
|
||||
// ignore isBare on entries, since they should be properly encoded at all times
|
||||
const encoded = this.map((entry) => entry.toU8a());
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user