Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d7be67499 | ||
|
|
7804794233 | ||
|
|
c7a68a4e05 | ||
|
|
811f9f7868 | ||
|
|
d9acf1cfea | ||
|
|
0967dbba6b | ||
|
|
025a745258 | ||
|
|
88eb4fd6e5 | ||
|
|
0dcdffd59c | ||
|
|
1f39ad264a | ||
|
|
e357a08118 | ||
|
|
d6b2b4a1a3 | ||
|
|
47f2ee725f | ||
|
|
1028e14761 | ||
|
|
5fdefa9e58 | ||
|
|
80209da5c5 | ||
|
|
bbdf0e3192 | ||
|
|
9ee1c0bf13 | ||
|
|
5490947384 | ||
|
|
b1788be796 | ||
|
|
f4ec312656 | ||
|
|
e1057603fc | ||
|
|
0268e398c1 | ||
|
|
757d45b39e | ||
|
|
4f57a5a611 | ||
|
|
987896e323 |
@@ -1,5 +1,25 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 3.2.1 Dec 27, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for users of parachains.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Adjust metadata `.asV12` type signature (Thanks to https://github.com/yjhmelody)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `api.{errors, events, query, tx}.<section>.<name>.is(...)`
|
||||
- Remove support for staking pre Substrate 2.0
|
||||
- Add all frontier types & RPCs
|
||||
- Support `AccountInfo` with new provider/consumer refCount structure
|
||||
- Additional Cumulus parachain types
|
||||
- Consistently format number JSON based on bitLength
|
||||
- Cleanup metadata -> api dependencies
|
||||
- Update `@polkadot/util` to 5.2.1
|
||||
|
||||
|
||||
## 3.1.1 Dec 20, 2020
|
||||
|
||||
Upgrade priority: Low. Recommended for users of parachains.
|
||||
|
||||
+2
-2
@@ -28,11 +28,11 @@
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/register": "^7.12.10",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/dev": "^0.61.13",
|
||||
"@polkadot/dev": "^0.61.16",
|
||||
"@polkadot/ts": "^0.3.58",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.19",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "3.1.1"
|
||||
"version": "3.2.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -14,10 +14,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api": "3.1.1",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/x-rxjs": "3.1.1",
|
||||
"@polkadot/api": "3.2.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/x-rxjs": "3.2.1",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
import type { BlueprintSubmittableResult as BaseBlueprintSubmittableResult, CodeSubmittableResult as BaseCodeSubmittableResult } from '../base';
|
||||
|
||||
export type BlueprintSubmittableResult = BaseBlueprintSubmittableResult<'promise'>;
|
||||
export type CodeSubmittableResult = BaseCodeSubmittableResult<'promise'>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -14,16 +14,16 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api": "3.1.1",
|
||||
"@polkadot/rpc-core": "3.1.1",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/util-crypto": "^5.1.1",
|
||||
"@polkadot/x-rxjs": "3.1.1",
|
||||
"@polkadot/api": "3.2.1",
|
||||
"@polkadot/rpc-core": "3.2.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/util-crypto": "^5.2.2",
|
||||
"@polkadot/x-rxjs": "3.2.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.1.1",
|
||||
"@polkadot/rpc-provider": "3.1.1"
|
||||
"@polkadot/keyring": "^5.2.2",
|
||||
"@polkadot/rpc-provider": "3.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,40 +2,16 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option, Vec } from '@polkadot/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex, BalanceOf } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, startWith } from '@polkadot/x-rxjs/operators';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx, _accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
const accountIndex = _accountIndex instanceof api.registry.createClass('AccountIndex')
|
||||
? _accountIndex
|
||||
: api.registry.createType('AccountIndex', _accountIndex);
|
||||
|
||||
return api.query.indices.enumSet<Vec<AccountId>>(accountIndex.div(ENUMSET_SIZE)).pipe(
|
||||
startWith([]),
|
||||
map((accounts): AccountId | undefined =>
|
||||
(accounts || [])[accountIndex.mod(ENUMSET_SIZE).toNumber()]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// current
|
||||
function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Observable<AccountId | undefined> {
|
||||
return api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @name indexToId
|
||||
* @param {( AccountIndex | string )} accountIndex - An accounts index in different formats.
|
||||
@@ -52,9 +28,11 @@ function query (api: ApiInterfaceRx, accountIndex: AccountIndex | string): Obser
|
||||
export function indexToId (instanceId: string, api: ApiInterfaceRx): (accountIndex: AccountIndex | string) => Observable<AccountId | undefined> {
|
||||
return memo(instanceId, (accountIndex: AccountIndex | string): Observable<AccountId | undefined> =>
|
||||
api.query.indices
|
||||
? isFunction(api.query.indices.accounts)
|
||||
? query(api, accountIndex)
|
||||
: queryEnumSet(api, accountIndex)
|
||||
? api.query.indices.accounts<Option<ITuple<[AccountId, BalanceOf]>>>(accountIndex).pipe(
|
||||
map((optResult): AccountId | undefined =>
|
||||
optResult.unwrapOr([])[0]
|
||||
)
|
||||
)
|
||||
: of(undefined)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,47 +2,17 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Vec } from '@polkadot/types';
|
||||
import type { AccountId, AccountIndex } from '@polkadot/types/interfaces';
|
||||
import type { AccountIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { AccountIndexes } from '../types';
|
||||
|
||||
import { ENUMSET_SIZE } from '@polkadot/types/generic/AccountIndex';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, startWith, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
import { map, startWith } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const enumsetSize = ENUMSET_SIZE.toNumber();
|
||||
|
||||
let indicesCache: AccountIndexes | null = null;
|
||||
|
||||
function queryEnumSet (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.nextEnumSet<AccountIndex>().pipe(
|
||||
// use the nextEnumSet (which is a counter of the number of sets) to construct
|
||||
// a range of values to query [0, 1, 2, ...]. Retrieve the full enum set for the
|
||||
// specific index - each query can return up to ENUMSET_SIZE (64) records, each
|
||||
// containing an AccountId
|
||||
switchMap((next: AccountIndex): Observable<Vec<AccountId>[]> =>
|
||||
api.query.indices.enumSet.multi<Vec<AccountId>>([...Array(next.toNumber() + 1).keys()])
|
||||
),
|
||||
map((all: AccountId[][]): AccountIndexes =>
|
||||
all.reduce((indexes: AccountIndexes, list, outerIndex): AccountIndexes => {
|
||||
(list || []).forEach((accountId, innerIndex): void => {
|
||||
// re-create the index based on position 0 is [0][0] and likewise
|
||||
// 64 (0..63 in first) is [1][0] (the first index value in set 2)
|
||||
const index = (outerIndex * enumsetSize) + innerIndex;
|
||||
|
||||
indexes[accountId.toString()] = api.registry.createType('AccountIndex', index);
|
||||
});
|
||||
|
||||
return indexes;
|
||||
}, {})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
|
||||
return api.query.indices.accounts.entries().pipe(
|
||||
map((entries): AccountIndexes =>
|
||||
@@ -78,9 +48,7 @@ export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observa
|
||||
? of(indicesCache)
|
||||
: (
|
||||
api.query.indices
|
||||
? isFunction(api.query.indices.accounts)
|
||||
? queryAccounts(api).pipe(startWith({}))
|
||||
: queryEnumSet(api).pipe(startWith({}))
|
||||
? queryAccounts(api).pipe(startWith({}))
|
||||
: of({} as AccountIndexes)
|
||||
).pipe(
|
||||
map((indices): AccountIndexes => {
|
||||
|
||||
@@ -7,16 +7,11 @@ import type { ActiveEraInfo, EraIndex, Moment, SessionIndex } from '@polkadot/ty
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveSessionIndexes } from '../types';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function isEraOpt (era: Option<EraIndex> | EraIndex): era is Option<EraIndex> {
|
||||
return isFunction((era as Option<EraIndex>).unwrapOrDefault);
|
||||
}
|
||||
|
||||
// parse into Indexes
|
||||
function parse ([activeEra, activeEraStart, currentEra, currentIndex, validatorCount]: [EraIndex, Option<Moment>, EraIndex, SessionIndex, u32]): DeriveSessionIndexes {
|
||||
return {
|
||||
@@ -28,29 +23,6 @@ function parse ([activeEra, activeEraStart, currentEra, currentIndex, validatorC
|
||||
};
|
||||
}
|
||||
|
||||
// query for previous V2
|
||||
function queryNoActive (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
return api.queryMulti<[Option<EraIndex> | EraIndex, SessionIndex, u32]>([
|
||||
api.query.staking.currentEra,
|
||||
api.query.session.currentIndex,
|
||||
api.query.staking.validatorCount
|
||||
]).pipe(
|
||||
map(([currentEraOpt, currentIndex, validatorCount]): DeriveSessionIndexes => {
|
||||
const currentEra = isEraOpt(currentEraOpt)
|
||||
? currentEraOpt.unwrapOrDefault()
|
||||
: currentEraOpt;
|
||||
|
||||
return parse([
|
||||
currentEra,
|
||||
api.registry.createType('Option<Moment>'),
|
||||
currentEra,
|
||||
currentIndex,
|
||||
validatorCount
|
||||
]);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// query based on latest
|
||||
function query (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
return api.queryMulti<[Option<ActiveEraInfo>, Option<EraIndex>, SessionIndex, u32]>([
|
||||
@@ -87,9 +59,7 @@ function empty (api: ApiInterfaceRx): Observable<DeriveSessionIndexes> {
|
||||
export function indexes (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionIndexes> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionIndexes> =>
|
||||
api.query.session && api.query.staking
|
||||
? isFunction(api.query.staking.activeEra)
|
||||
? query(api)
|
||||
: queryNoActive(api)
|
||||
? query(api)
|
||||
: empty(api)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import type { SessionIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveSessionInfo, DeriveSessionProgress } from '../types';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
@@ -57,29 +56,13 @@ function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultS
|
||||
);
|
||||
}
|
||||
|
||||
function queryBabeNoHistory (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> {
|
||||
return combineLatest([
|
||||
api.derive.session.info(),
|
||||
api.queryMulti<ResultSlotsFlat>([
|
||||
api.query.babe.currentSlot,
|
||||
api.query.babe.epochIndex,
|
||||
api.query.babe.genesisSlot,
|
||||
api.query.staking.currentEraStartSessionIndex
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Retrieves all the session and era query and calculates specific values on it as the length of the session and eras
|
||||
*/
|
||||
export function progress (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveSessionProgress> {
|
||||
return memo(instanceId, (): Observable<DeriveSessionProgress> =>
|
||||
api.consts.babe
|
||||
? (
|
||||
isFunction(api.query.staking.erasStartSessionIndex)
|
||||
? queryBabe(api) // 2.x with Babe
|
||||
: queryBabeNoHistory(api)
|
||||
).pipe(
|
||||
? queryBabe(api).pipe(
|
||||
map(([info, slots]: [DeriveSessionInfo, ResultSlotsFlat]): DeriveSessionProgress =>
|
||||
createDerive(api, info, slots)
|
||||
)
|
||||
|
||||
@@ -2,41 +2,21 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, EraPoints, EraRewardPoints, RewardPoint } from '@polkadot/types/interfaces';
|
||||
import type { EraRewardPoints } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
import { switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
function retrievePointsPrev (api: ApiInterfaceRx, currentElected: AccountId[]): Observable<EraRewardPoints> {
|
||||
return api.query.staking.currentEraPointsEarned<EraPoints>().pipe(
|
||||
map(({ individual, total }): EraRewardPoints =>
|
||||
api.registry.createType('EraRewardPoints', {
|
||||
individual: new Map<AccountId, RewardPoint>(
|
||||
individual
|
||||
.map((points) => api.registry.createType('RewardPoint', points))
|
||||
.map((points, index): [AccountId, RewardPoint] => [currentElected[index], points])
|
||||
),
|
||||
total
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Retrieve the staking overview, including elected and points earned
|
||||
*/
|
||||
export function currentPoints (instanceId: string, api: ApiInterfaceRx): () => Observable<EraRewardPoints> {
|
||||
return memo(instanceId, (): Observable<EraRewardPoints> =>
|
||||
api.derive.staking.overview().pipe(
|
||||
switchMap(({ activeEra, nextElected }) =>
|
||||
api.query.staking.erasRewardPoints
|
||||
? api.query.staking.erasRewardPoints<EraRewardPoints>(activeEra)
|
||||
: api.query.staking.currentEraPointsEarned
|
||||
? retrievePointsPrev(api, nextElected)
|
||||
: of(api.registry.createType('EraRewardPoints'))
|
||||
api.derive.session.indexes().pipe(
|
||||
switchMap(({ activeEra }) =>
|
||||
api.query.staking.erasRewardPoints<EraRewardPoints>(activeEra)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -4,21 +4,24 @@
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveStakingElected } from '../types';
|
||||
import type { DeriveStakingElected, StakingQueryFlags } from '../types';
|
||||
|
||||
import { arrayFlatten } from '@polkadot/util';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
const DEFAULT_FLAGS = { withController: true, withExposure: true, withPrefs: true };
|
||||
|
||||
function combineAccounts (nextElected: AccountId[], validators: AccountId[]): AccountId[] {
|
||||
return [...nextElected].concat(...validators.filter((v) => !nextElected.find((n) => n.eq(v))));
|
||||
return arrayFlatten([nextElected, validators.filter((v) => !nextElected.find((n) => n.eq(v)))]);
|
||||
}
|
||||
|
||||
export function electedInfo (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveStakingElected> {
|
||||
return memo(instanceId, (): Observable<DeriveStakingElected> =>
|
||||
export function electedInfo (instanceId: string, api: ApiInterfaceRx): (flags?: StakingQueryFlags) => Observable<DeriveStakingElected> {
|
||||
return memo(instanceId, (flags: StakingQueryFlags = DEFAULT_FLAGS): Observable<DeriveStakingElected> =>
|
||||
api.derive.staking.validators().pipe(
|
||||
switchMap(({ nextElected, validators }): Observable<DeriveStakingElected> =>
|
||||
api.derive.staking.queryMulti(combineAccounts(nextElected, validators), { withExposure: true, withLedger: true, withPrefs: true }).pipe(
|
||||
api.derive.staking.queryMulti(combineAccounts(nextElected, validators), flags).pipe(
|
||||
map((info): DeriveStakingElected => ({
|
||||
info,
|
||||
nextElected,
|
||||
|
||||
@@ -8,36 +8,33 @@ import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function erasHistoric (instanceId: string, api: ApiInterfaceRx): (withActive: boolean) => Observable<EraIndex[]> {
|
||||
return memo(instanceId, (withActive: boolean): Observable<EraIndex[]> =>
|
||||
api.query.staking?.activeEra
|
||||
? api.queryMulti<[Option<ActiveEraInfo>, u32]>([
|
||||
api.query.staking.activeEra,
|
||||
api.query.staking.historyDepth
|
||||
]).pipe(
|
||||
map(([activeEraOpt, historyDepth]): EraIndex[] => {
|
||||
const result: EraIndex[] = [];
|
||||
const max = historyDepth.toNumber();
|
||||
const activeEra: BN = activeEraOpt.unwrapOrDefault().index;
|
||||
let lastEra = activeEra;
|
||||
api.queryMulti<[Option<ActiveEraInfo>, u32]>([
|
||||
api.query.staking.activeEra,
|
||||
api.query.staking.historyDepth
|
||||
]).pipe(
|
||||
map(([activeEraOpt, historyDepth]): EraIndex[] => {
|
||||
const result: EraIndex[] = [];
|
||||
const max = historyDepth.toNumber();
|
||||
const activeEra: BN = activeEraOpt.unwrapOrDefault().index;
|
||||
let lastEra = activeEra;
|
||||
|
||||
while (lastEra.gten(0) && (result.length < max)) {
|
||||
if ((lastEra !== activeEra) || (withActive === true)) {
|
||||
result.push(api.registry.createType('EraIndex', lastEra));
|
||||
}
|
||||
|
||||
lastEra = lastEra.subn(1);
|
||||
while (lastEra.gten(0) && (result.length < max)) {
|
||||
if ((lastEra !== activeEra) || (withActive === true)) {
|
||||
result.push(api.registry.createType('EraIndex', lastEra));
|
||||
}
|
||||
|
||||
// go from oldest to newest
|
||||
return result.reverse();
|
||||
})
|
||||
)
|
||||
: of([])
|
||||
lastEra = lastEra.subn(1);
|
||||
}
|
||||
|
||||
// go from oldest to newest
|
||||
return result.reverse();
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,71 +4,63 @@
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, EraIndex, Exposure, Nominations, RewardDestination, StakingLedger, ValidatorPrefs } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveStakingQuery } from '../types';
|
||||
import type { DeriveStakingQuery, StakingQueryFlags } from '../types';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
interface QueryFlags {
|
||||
withDestination?: boolean;
|
||||
withExposure?: boolean;
|
||||
withLedger?: boolean;
|
||||
withNominations?: boolean;
|
||||
withPrefs?: boolean;
|
||||
}
|
||||
|
||||
type MultiResult = [Option<AccountId>, Option<ITuple<[Nominations]> | Nominations>, RewardDestination, ITuple<[ValidatorPrefs]> | ValidatorPrefs, Exposure];
|
||||
|
||||
type MultiResultCombo = [Option<AccountId>, Option<Nominations>, RewardDestination, ValidatorPrefs, Exposure];
|
||||
|
||||
function parseDetails (stashId: AccountId, [controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]: MultiResult, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
|
||||
const nominators = nominatorsOpt && nominatorsOpt.unwrapOr(null);
|
||||
|
||||
function parseDetails (stashId: AccountId, controllerIdOpt: Option<AccountId> | null, nominatorsOpt: Option<Nominations>, rewardDestination: RewardDestination, validatorPrefs: ValidatorPrefs, exposure: Exposure, stakingLedgerOpt: Option<StakingLedger>): DeriveStakingQuery {
|
||||
return {
|
||||
accountId: stashId,
|
||||
controllerId: controllerIdOpt && controllerIdOpt.unwrapOr(null),
|
||||
exposure,
|
||||
nominators: nominators
|
||||
? Array.isArray(nominators)
|
||||
? nominators[0].targets
|
||||
: nominators.targets
|
||||
nominators: nominatorsOpt.isSome
|
||||
? nominatorsOpt.unwrap().targets
|
||||
: [],
|
||||
rewardDestination,
|
||||
stakingLedger: stakingLedgerOpt.unwrapOrDefault(),
|
||||
stashId,
|
||||
validatorPrefs: Array.isArray(validatorPrefs)
|
||||
? validatorPrefs[0]
|
||||
: validatorPrefs
|
||||
validatorPrefs
|
||||
};
|
||||
}
|
||||
|
||||
function retrievePrev (api: ApiInterfaceRx, stashId: AccountId): Observable<MultiResult> {
|
||||
return api.queryMulti<MultiResult>([
|
||||
[api.query.staking.bonded, stashId],
|
||||
[api.query.staking.nominators, stashId],
|
||||
[api.query.staking.payee, stashId],
|
||||
[api.query.staking.validators, stashId],
|
||||
[api.query.staking.stakers, stashId]
|
||||
]);
|
||||
function getLedgers (api: ApiInterfaceRx, optIds: (Option<AccountId> | null)[], { withLedger = false }: StakingQueryFlags): Observable<Option<StakingLedger>[]> {
|
||||
const ids = optIds
|
||||
.filter((opt): opt is Option<AccountId> => withLedger && !!opt && opt.isSome)
|
||||
.map((opt) => opt.unwrap());
|
||||
const emptyLed = api.registry.createType('Option<StakingLedger>');
|
||||
|
||||
return (
|
||||
ids.length
|
||||
? api.query.staking.ledger.multi<Option<StakingLedger>>(ids)
|
||||
: of([])
|
||||
).pipe(
|
||||
map((optLedgers): Option<StakingLedger>[] => {
|
||||
let offset = -1;
|
||||
|
||||
return optIds.map((opt): Option<StakingLedger> =>
|
||||
opt && opt.isSome
|
||||
? optLedgers[++offset] || emptyLed
|
||||
: emptyLed
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveCurr (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withDestination, withExposure, withLedger, withNominations, withPrefs }: QueryFlags): Observable<MultiResultCombo[]> {
|
||||
const emptyCont = api.registry.createType('Option<AccountId>');
|
||||
function getStashInfo (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: EraIndex, { withController, withDestination, withExposure, withLedger, withNominations, withPrefs }: StakingQueryFlags): Observable<[(Option<AccountId> | null)[], Option<Nominations>[], RewardDestination[], ValidatorPrefs[], Exposure[]]> {
|
||||
const emptyNoms = api.registry.createType('Option<Nominations>');
|
||||
const emptyRewa = api.registry.createType('RewardDestination');
|
||||
const emptyExpo = api.registry.createType('Exposure');
|
||||
const emptyPrefs = api.registry.createType('ValidatorPrefs');
|
||||
|
||||
return combineLatest([
|
||||
withLedger
|
||||
withController || withLedger
|
||||
? api.query.staking.bonded.multi<Option<AccountId>>(stashIds)
|
||||
: of(stashIds.map(() => emptyCont)),
|
||||
withNominations && api.query.staking.nominators
|
||||
: of(stashIds.map(() => null)),
|
||||
withNominations
|
||||
? api.query.staking.nominators.multi<Option<Nominations>>(stashIds)
|
||||
: of(stashIds.map(() => emptyNoms)),
|
||||
withDestination
|
||||
@@ -80,67 +72,43 @@ function retrieveCurr (api: ApiInterfaceRx, stashIds: AccountId[], activeEra: Er
|
||||
withExposure
|
||||
? api.query.staking.erasStakers.multi<Exposure>(stashIds.map((stashId) => [activeEra, stashId]))
|
||||
: of(stashIds.map(() => emptyExpo))
|
||||
]).pipe(
|
||||
map(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]): MultiResultCombo[] =>
|
||||
controllerIdOpt.map((controllerIdOpt, index): MultiResultCombo =>
|
||||
[controllerIdOpt, nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index]]
|
||||
]);
|
||||
}
|
||||
|
||||
function getBatch (api: ApiInterfaceRx, activeEra: EraIndex, stashIds: AccountId[], flags: StakingQueryFlags): Observable<DeriveStakingQuery[]> {
|
||||
return getStashInfo(api, stashIds, activeEra, flags).pipe(
|
||||
switchMap(([controllerIdOpt, nominatorsOpt, rewardDestination, validatorPrefs, exposure]): Observable<DeriveStakingQuery[]> =>
|
||||
getLedgers(api, controllerIdOpt, flags).pipe(
|
||||
map((stakingLedgerOpts) =>
|
||||
stashIds.map((stashId, index) =>
|
||||
parseDetails(stashId, controllerIdOpt[index], nominatorsOpt[index], rewardDestination[index], validatorPrefs[index], exposure[index], stakingLedgerOpts[index])
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function retrieveControllers (api: ApiInterfaceRx, optControllerIds: Option<AccountId>[]): Observable<Option<StakingLedger>[]> {
|
||||
const ids = optControllerIds.filter((opt) => opt.isSome).map((opt) => opt.unwrap());
|
||||
const emptyLed = api.registry.createType('Option<StakingLedger>');
|
||||
|
||||
if (!ids.length) {
|
||||
return of(optControllerIds.map(() => emptyLed));
|
||||
}
|
||||
|
||||
return api.query.staking.ledger.multi<Option<StakingLedger>>(ids).pipe(
|
||||
map((optLedgers): Option<StakingLedger>[] => {
|
||||
let offset = -1;
|
||||
|
||||
return optControllerIds.map((opt): Option<StakingLedger> =>
|
||||
opt.isSome
|
||||
? optLedgers[++offset]
|
||||
: emptyLed
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
/**
|
||||
* @description From a stash, retrieve the controllerId and all relevant details
|
||||
*/
|
||||
export function query (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, flags: QueryFlags) => Observable<DeriveStakingQuery> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, flags: QueryFlags): Observable<DeriveStakingQuery> =>
|
||||
export function query (instanceId: string, api: ApiInterfaceRx): (accountId: Uint8Array | string, flags: StakingQueryFlags) => Observable<DeriveStakingQuery> {
|
||||
return memo(instanceId, (accountId: Uint8Array | string, flags: StakingQueryFlags): Observable<DeriveStakingQuery> =>
|
||||
api.derive.staking.queryMulti([accountId], flags).pipe(
|
||||
map(([first]) => first)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export function queryMulti (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], flags: QueryFlags) => Observable<DeriveStakingQuery[]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], flags: QueryFlags): Observable<DeriveStakingQuery[]> =>
|
||||
export function queryMulti (instanceId: string, api: ApiInterfaceRx): (accountIds: (Uint8Array | string)[], flags: StakingQueryFlags) => Observable<DeriveStakingQuery[]> {
|
||||
return memo(instanceId, (accountIds: (Uint8Array | string)[], flags: StakingQueryFlags): Observable<DeriveStakingQuery[]> =>
|
||||
accountIds.length
|
||||
? api.derive.session.indexes().pipe(
|
||||
switchMap(({ activeEra }): Observable<DeriveStakingQuery[]> => {
|
||||
const stashIds = accountIds.map((accountId) => api.registry.createType('AccountId', accountId));
|
||||
|
||||
return (
|
||||
isFunction(api.query.staking.erasStakers)
|
||||
? retrieveCurr(api, stashIds, activeEra, flags)
|
||||
: combineLatest(stashIds.map((stashId) => retrievePrev(api, stashId)))
|
||||
).pipe(
|
||||
switchMap((results): Observable<DeriveStakingQuery[]> =>
|
||||
retrieveControllers(api, results.map(([optController]) => optController)).pipe(
|
||||
map((stakingLedgerOpts) =>
|
||||
stashIds.map((stashId, index) => parseDetails(stashId, results[index], stakingLedgerOpts[index]))
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return getBatch(api, activeEra, stashIds, flags);
|
||||
})
|
||||
)
|
||||
: of([])
|
||||
|
||||
@@ -21,7 +21,6 @@ type ErasResult = [{ unwrapOr: (value: BN) => BN }, DeriveEraPoints[], DeriveEra
|
||||
const ZERO = new BN(0);
|
||||
const MIN_ONE = new BN(-1);
|
||||
const COMM_DIV = new BN(1_000_000_000);
|
||||
const MAX_ERAS = new BN(1_000_000_000);
|
||||
|
||||
function parseRewards (api: ApiInterfaceRx, stashId: AccountId, [, erasPoints, erasPrefs, erasRewards]: ErasResult, exposures: DeriveStakerExposure[]): DeriveStakerReward[] {
|
||||
return exposures.map(({ era, isEmpty, isValidator, nominating, validators: eraValidators }): DeriveStakerReward => {
|
||||
@@ -126,11 +125,7 @@ function filterRewards (api: ApiInterfaceRx, eras: EraIndex[], { migrateEra, rew
|
||||
const validators = uniqValidators(rewards);
|
||||
const filter = filterEras(eras, stakingLedger);
|
||||
|
||||
return (
|
||||
isFunction(api.tx.staking.payoutStakers)
|
||||
? api.derive.staking.queryMulti(validators, { withLedger: true })
|
||||
: of([])
|
||||
).pipe(
|
||||
return api.derive.staking.queryMulti(validators, { withLedger: true }).pipe(
|
||||
map((queryValidators): DeriveStakerReward[] =>
|
||||
rewards
|
||||
.filter(({ isEmpty }) => !isEmpty)
|
||||
@@ -162,7 +157,7 @@ export function _stakerRewardsEras (instanceId: string, api: ApiInterfaceRx): (e
|
||||
combineLatest([
|
||||
isFunction(api.query.staking.migrateEra)
|
||||
? api.query.staking.migrateEra<Option<EraIndex>>()
|
||||
: of({ unwrapOr: () => isFunction(api.tx.staking.payoutStakers) ? ZERO : MAX_ERAS }),
|
||||
: of(api.registry.createType('Option<EraIndex>')),
|
||||
api.derive.staking._erasPoints(eras, withActive),
|
||||
api.derive.staking._erasPrefs(eras, withActive),
|
||||
api.derive.staking._erasRewards(eras, withActive)
|
||||
|
||||
@@ -144,3 +144,12 @@ export interface DeriveStakingOverview extends DeriveSessionIndexes {
|
||||
nextElected: AccountId[];
|
||||
validators: AccountId[];
|
||||
}
|
||||
|
||||
export interface StakingQueryFlags {
|
||||
withController?: boolean;
|
||||
withDestination?: boolean;
|
||||
withExposure?: boolean;
|
||||
withLedger?: boolean;
|
||||
withNominations?: boolean;
|
||||
withPrefs?: boolean;
|
||||
}
|
||||
|
||||
@@ -3,15 +3,17 @@
|
||||
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveStakingWaiting } from '../types';
|
||||
import type { DeriveStakingWaiting, StakingQueryFlags } from '../types';
|
||||
|
||||
import { combineLatest } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function waitingInfo (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveStakingWaiting> {
|
||||
return memo(instanceId, (): Observable<DeriveStakingWaiting> =>
|
||||
const DEFAULT_FLAGS = { withController: true, withPrefs: true };
|
||||
|
||||
export function waitingInfo (instanceId: string, api: ApiInterfaceRx): (flags?: StakingQueryFlags) => Observable<DeriveStakingWaiting> {
|
||||
return memo(instanceId, (flags: StakingQueryFlags = DEFAULT_FLAGS): Observable<DeriveStakingWaiting> =>
|
||||
combineLatest([
|
||||
api.derive.staking.validators(),
|
||||
api.derive.staking.stashes()
|
||||
@@ -20,7 +22,7 @@ export function waitingInfo (instanceId: string, api: ApiInterfaceRx): () => Obs
|
||||
const elected = nextElected.map((a) => a.toString());
|
||||
const waiting = stashes.filter((v) => !elected.includes(v.toString()));
|
||||
|
||||
return api.derive.staking.queryMulti(waiting, { withLedger: true, withPrefs: true }).pipe(
|
||||
return api.derive.staking.queryMulti(waiting, flags).pipe(
|
||||
map((info): DeriveStakingWaiting => ({
|
||||
info,
|
||||
waiting
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -17,16 +17,16 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api-derive": "3.1.1",
|
||||
"@polkadot/keyring": "^5.1.1",
|
||||
"@polkadot/metadata": "3.1.1",
|
||||
"@polkadot/rpc-core": "3.1.1",
|
||||
"@polkadot/rpc-provider": "3.1.1",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/types-known": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/util-crypto": "^5.1.1",
|
||||
"@polkadot/x-rxjs": "3.1.1",
|
||||
"@polkadot/api-derive": "3.2.1",
|
||||
"@polkadot/keyring": "^5.2.2",
|
||||
"@polkadot/metadata": "3.2.1",
|
||||
"@polkadot/rpc-core": "3.2.1",
|
||||
"@polkadot/rpc-provider": "3.2.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/types-known": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/util-crypto": "^5.2.2",
|
||||
"@polkadot/x-rxjs": "3.2.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,842 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Bytes, Option, Vec, bool, u16, u32 } from '@polkadot/types';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { BalanceStatus } from '@polkadot/types/interfaces/balances';
|
||||
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { PropIndex, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
||||
import type { VoteThreshold } from '@polkadot/types/interfaces/elections';
|
||||
import type { AuthorityList } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
||||
import type { Kind, OpaqueTimeSlot } from '@polkadot/types/interfaces/offences';
|
||||
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BlockNumber, CallHash, Hash, PhantomData } from '@polkadot/types/interfaces/runtime';
|
||||
import type { TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { IdentificationTuple, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { ElectionCompute, EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
import type { DispatchError, DispatchInfo, DispatchResult } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
|
||||
declare module '@polkadot/api/types/events' {
|
||||
export interface AugmentedEvents<ApiType> {
|
||||
assets: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Some assets were destroyed. \[asset_id, owner, balance\]
|
||||
**/
|
||||
Burned: AugmentedEvent<ApiType, [AssetId, AccountId, Balance]>;
|
||||
/**
|
||||
* Some asset class was created. \[asset_id, creator, owner\]
|
||||
**/
|
||||
Created: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId]>;
|
||||
/**
|
||||
* An asset class was destroyed.
|
||||
**/
|
||||
Destroyed: AugmentedEvent<ApiType, [AssetId]>;
|
||||
/**
|
||||
* Some asset class was force-created. \[asset_id, owner\]
|
||||
**/
|
||||
ForceCreated: AugmentedEvent<ApiType, [AssetId, AccountId]>;
|
||||
/**
|
||||
* Some assets was transferred by an admin. \[asset_id, from, to, amount\]
|
||||
**/
|
||||
ForceTransferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, Balance]>;
|
||||
/**
|
||||
* Some account `who` was frozen. \[asset_id, who\]
|
||||
**/
|
||||
Frozen: AugmentedEvent<ApiType, [AssetId, AccountId]>;
|
||||
/**
|
||||
* Some assets were issued. \[asset_id, owner, total_supply\]
|
||||
**/
|
||||
Issued: AugmentedEvent<ApiType, [AssetId, AccountId, Balance]>;
|
||||
/**
|
||||
* The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\]
|
||||
**/
|
||||
MaxZombiesChanged: AugmentedEvent<ApiType, [AssetId, u32]>;
|
||||
/**
|
||||
* The owner changed \[asset_id, owner\]
|
||||
**/
|
||||
OwnerChanged: AugmentedEvent<ApiType, [AssetId, AccountId]>;
|
||||
/**
|
||||
* The management team changed \[asset_id, issuer, admin, freezer\]
|
||||
**/
|
||||
TeamChanged: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, AccountId]>;
|
||||
/**
|
||||
* Some account `who` was thawed. \[asset_id, who\]
|
||||
**/
|
||||
Thawed: AugmentedEvent<ApiType, [AssetId, AccountId]>;
|
||||
/**
|
||||
* Some assets were transferred. \[asset_id, from, to, amount\]
|
||||
**/
|
||||
Transferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, Balance]>;
|
||||
};
|
||||
balances: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A balance was set by root. \[who, free, reserved\]
|
||||
**/
|
||||
BalanceSet: AugmentedEvent<ApiType, [AccountId, Balance, Balance]>;
|
||||
/**
|
||||
* Some amount was deposited (e.g. for transaction fees). \[who, deposit\]
|
||||
**/
|
||||
Deposit: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* An account was removed whose balance was non-zero but below ExistentialDeposit,
|
||||
* resulting in an outright loss. \[account, balance\]
|
||||
**/
|
||||
DustLost: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* An account was created with some free balance. \[account, free_balance\]
|
||||
**/
|
||||
Endowed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Some balance was reserved (moved from free to reserved). \[who, value\]
|
||||
**/
|
||||
Reserved: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Some balance was moved from the reserve of the first account to the second account.
|
||||
* Final argument indicates the destination balance type.
|
||||
* \[from, to, balance, destination_status\]
|
||||
**/
|
||||
ReserveRepatriated: AugmentedEvent<ApiType, [AccountId, AccountId, Balance, BalanceStatus]>;
|
||||
/**
|
||||
* Transfer succeeded. \[from, to, value\]
|
||||
**/
|
||||
Transfer: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
|
||||
/**
|
||||
* Some balance was unreserved (moved from reserved to free). \[who, value\]
|
||||
**/
|
||||
Unreserved: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
};
|
||||
bounties: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A bounty is awarded to a beneficiary. \[index, beneficiary\]
|
||||
**/
|
||||
BountyAwarded: AugmentedEvent<ApiType, [BountyIndex, AccountId]>;
|
||||
/**
|
||||
* A bounty proposal is funded and became active. \[index\]
|
||||
**/
|
||||
BountyBecameActive: AugmentedEvent<ApiType, [BountyIndex]>;
|
||||
/**
|
||||
* A bounty is cancelled. \[index\]
|
||||
**/
|
||||
BountyCanceled: AugmentedEvent<ApiType, [BountyIndex]>;
|
||||
/**
|
||||
* A bounty is claimed by beneficiary. \[index, payout, beneficiary\]
|
||||
**/
|
||||
BountyClaimed: AugmentedEvent<ApiType, [BountyIndex, Balance, AccountId]>;
|
||||
/**
|
||||
* A bounty expiry is extended. \[index\]
|
||||
**/
|
||||
BountyExtended: AugmentedEvent<ApiType, [BountyIndex]>;
|
||||
/**
|
||||
* New bounty proposal. \[index\]
|
||||
**/
|
||||
BountyProposed: AugmentedEvent<ApiType, [BountyIndex]>;
|
||||
/**
|
||||
* A bounty proposal was rejected; funds were slashed. \[index, bond\]
|
||||
**/
|
||||
BountyRejected: AugmentedEvent<ApiType, [BountyIndex, Balance]>;
|
||||
};
|
||||
contracts: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Code with the specified hash has been stored.
|
||||
* \[code_hash\]
|
||||
**/
|
||||
CodeStored: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* An event deposited upon execution of a contract from the account.
|
||||
* \[account, data\]
|
||||
**/
|
||||
ContractExecution: AugmentedEvent<ApiType, [AccountId, Bytes]>;
|
||||
/**
|
||||
* Contract has been evicted and is now in tombstone state.
|
||||
* \[contract, tombstone\]
|
||||
*
|
||||
* # Params
|
||||
*
|
||||
* - `contract`: `AccountId`: The account ID of the evicted contract.
|
||||
* - `tombstone`: `bool`: True if the evicted contract left behind a tombstone.
|
||||
**/
|
||||
Evicted: AugmentedEvent<ApiType, [AccountId, bool]>;
|
||||
/**
|
||||
* Contract deployed by address at the specified address. \[owner, contract\]
|
||||
**/
|
||||
Instantiated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* Restoration for a contract has been successful.
|
||||
* \[donor, dest, code_hash, rent_allowance\]
|
||||
*
|
||||
* # Params
|
||||
*
|
||||
* - `donor`: `AccountId`: Account ID of the restoring contract
|
||||
* - `dest`: `AccountId`: Account ID of the restored contract
|
||||
* - `code_hash`: `Hash`: Code hash of the restored contract
|
||||
* - `rent_allowance: `Balance`: Rent allowance of the restored contract
|
||||
**/
|
||||
Restored: AugmentedEvent<ApiType, [AccountId, AccountId, Hash, Balance]>;
|
||||
/**
|
||||
* Triggered when the current \[schedule\] is updated.
|
||||
**/
|
||||
ScheduleUpdated: AugmentedEvent<ApiType, [u32]>;
|
||||
};
|
||||
council: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A motion was approved by the required threshold.
|
||||
* \[proposal_hash\]
|
||||
**/
|
||||
Approved: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A proposal was closed because its threshold was reached or after its duration was up.
|
||||
* \[proposal_hash, yes, no\]
|
||||
**/
|
||||
Closed: AugmentedEvent<ApiType, [Hash, MemberCount, MemberCount]>;
|
||||
/**
|
||||
* A motion was not approved by the required threshold.
|
||||
* \[proposal_hash\]
|
||||
**/
|
||||
Disapproved: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A motion was executed; result will be `Ok` if it returned without error.
|
||||
* \[proposal_hash, result\]
|
||||
**/
|
||||
Executed: AugmentedEvent<ApiType, [Hash, DispatchResult]>;
|
||||
/**
|
||||
* A single member did some action; result will be `Ok` if it returned without error.
|
||||
* \[proposal_hash, result\]
|
||||
**/
|
||||
MemberExecuted: AugmentedEvent<ApiType, [Hash, DispatchResult]>;
|
||||
/**
|
||||
* A motion (given hash) has been proposed (by given account) with a threshold (given
|
||||
* `MemberCount`).
|
||||
* \[account, proposal_index, proposal_hash, threshold\]
|
||||
**/
|
||||
Proposed: AugmentedEvent<ApiType, [AccountId, ProposalIndex, Hash, MemberCount]>;
|
||||
/**
|
||||
* A motion (given hash) has been voted on by given account, leaving
|
||||
* a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
* \[account, proposal_hash, voted, yes, no\]
|
||||
**/
|
||||
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
|
||||
};
|
||||
democracy: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A proposal \[hash\] has been blacklisted permanently.
|
||||
**/
|
||||
Blacklisted: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A referendum has been cancelled. \[ref_index\]
|
||||
**/
|
||||
Cancelled: AugmentedEvent<ApiType, [ReferendumIndex]>;
|
||||
/**
|
||||
* An account has delegated their vote to another account. \[who, target\]
|
||||
**/
|
||||
Delegated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* A proposal has been enacted. \[ref_index, is_ok\]
|
||||
**/
|
||||
Executed: AugmentedEvent<ApiType, [ReferendumIndex, bool]>;
|
||||
/**
|
||||
* An external proposal has been tabled.
|
||||
**/
|
||||
ExternalTabled: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* A proposal has been rejected by referendum. \[ref_index\]
|
||||
**/
|
||||
NotPassed: AugmentedEvent<ApiType, [ReferendumIndex]>;
|
||||
/**
|
||||
* A proposal has been approved by referendum. \[ref_index\]
|
||||
**/
|
||||
Passed: AugmentedEvent<ApiType, [ReferendumIndex]>;
|
||||
/**
|
||||
* A proposal could not be executed because its preimage was invalid.
|
||||
* \[proposal_hash, ref_index\]
|
||||
**/
|
||||
PreimageInvalid: AugmentedEvent<ApiType, [Hash, ReferendumIndex]>;
|
||||
/**
|
||||
* A proposal could not be executed because its preimage was missing.
|
||||
* \[proposal_hash, ref_index\]
|
||||
**/
|
||||
PreimageMissing: AugmentedEvent<ApiType, [Hash, ReferendumIndex]>;
|
||||
/**
|
||||
* A proposal's preimage was noted, and the deposit taken. \[proposal_hash, who, deposit\]
|
||||
**/
|
||||
PreimageNoted: AugmentedEvent<ApiType, [Hash, AccountId, Balance]>;
|
||||
/**
|
||||
* A registered preimage was removed and the deposit collected by the reaper.
|
||||
* \[proposal_hash, provider, deposit, reaper\]
|
||||
**/
|
||||
PreimageReaped: AugmentedEvent<ApiType, [Hash, AccountId, Balance, AccountId]>;
|
||||
/**
|
||||
* A proposal preimage was removed and used (the deposit was returned).
|
||||
* \[proposal_hash, provider, deposit\]
|
||||
**/
|
||||
PreimageUsed: AugmentedEvent<ApiType, [Hash, AccountId, Balance]>;
|
||||
/**
|
||||
* A motion has been proposed by a public account. \[proposal_index, deposit\]
|
||||
**/
|
||||
Proposed: AugmentedEvent<ApiType, [PropIndex, Balance]>;
|
||||
/**
|
||||
* A referendum has begun. \[ref_index, threshold\]
|
||||
**/
|
||||
Started: AugmentedEvent<ApiType, [ReferendumIndex, VoteThreshold]>;
|
||||
/**
|
||||
* A public proposal has been tabled for referendum vote. \[proposal_index, deposit, depositors\]
|
||||
**/
|
||||
Tabled: AugmentedEvent<ApiType, [PropIndex, Balance, Vec<AccountId>]>;
|
||||
/**
|
||||
* An \[account\] has cancelled a previous delegation operation.
|
||||
**/
|
||||
Undelegated: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* An \[account\] has been unlocked successfully.
|
||||
**/
|
||||
Unlocked: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* An external proposal has been vetoed. \[who, proposal_hash, until\]
|
||||
**/
|
||||
Vetoed: AugmentedEvent<ApiType, [AccountId, Hash, BlockNumber]>;
|
||||
};
|
||||
elections: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A candidate was slashed due to failing to obtain a seat as member or runner-up
|
||||
**/
|
||||
CandidateSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* Internal error happened while trying to perform election.
|
||||
**/
|
||||
ElectionError: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* No (or not enough) candidates existed for this round. This is different from
|
||||
* `NewTerm(\[\])`. See the description of `NewTerm`.
|
||||
**/
|
||||
EmptyTerm: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* A \[member\] has been removed. This should always be followed by either `NewTerm` or
|
||||
* `EmptyTerm`.
|
||||
**/
|
||||
MemberKicked: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A \[member\] has renounced their candidacy.
|
||||
**/
|
||||
MemberRenounced: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A new term with \[new_members\]. This indicates that enough candidates existed to run the
|
||||
* election, not that enough have has been elected. The inner value must be examined for
|
||||
* this purpose. A `NewTerm(\[\])` indicates that some candidates got their bond slashed and
|
||||
* none were elected, whilst `EmptyTerm` means that no candidates existed to begin with.
|
||||
**/
|
||||
NewTerm: AugmentedEvent<ApiType, [Vec<ITuple<[AccountId, Balance]>>]>;
|
||||
/**
|
||||
* A seat holder (member or runner-up) was slashed due to failing to retaining their position.
|
||||
**/
|
||||
SeatHolderSlashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A voter was reported with the the report being successful or not.
|
||||
* \[voter, reporter, success\]
|
||||
**/
|
||||
VoterReported: AugmentedEvent<ApiType, [AccountId, AccountId, bool]>;
|
||||
};
|
||||
grandpa: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* New authority set has been applied. \[authority_set\]
|
||||
**/
|
||||
NewAuthorities: AugmentedEvent<ApiType, [AuthorityList]>;
|
||||
/**
|
||||
* Current authority set has been paused.
|
||||
**/
|
||||
Paused: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Current authority set has been resumed.
|
||||
**/
|
||||
Resumed: AugmentedEvent<ApiType, []>;
|
||||
};
|
||||
identity: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A name was cleared, and the given balance returned. \[who, deposit\]
|
||||
**/
|
||||
IdentityCleared: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A name was removed and the given balance slashed. \[who, deposit\]
|
||||
**/
|
||||
IdentityKilled: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A name was set or reset (which will remove all judgements). \[who\]
|
||||
**/
|
||||
IdentitySet: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A judgement was given by a registrar. \[target, registrar_index\]
|
||||
**/
|
||||
JudgementGiven: AugmentedEvent<ApiType, [AccountId, RegistrarIndex]>;
|
||||
/**
|
||||
* A judgement was asked from a registrar. \[who, registrar_index\]
|
||||
**/
|
||||
JudgementRequested: AugmentedEvent<ApiType, [AccountId, RegistrarIndex]>;
|
||||
/**
|
||||
* A judgement request was retracted. \[who, registrar_index\]
|
||||
**/
|
||||
JudgementUnrequested: AugmentedEvent<ApiType, [AccountId, RegistrarIndex]>;
|
||||
/**
|
||||
* A registrar was added. \[registrar_index\]
|
||||
**/
|
||||
RegistrarAdded: AugmentedEvent<ApiType, [RegistrarIndex]>;
|
||||
/**
|
||||
* A sub-identity was added to an identity and the deposit paid. \[sub, main, deposit\]
|
||||
**/
|
||||
SubIdentityAdded: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
|
||||
/**
|
||||
* A sub-identity was removed from an identity and the deposit freed.
|
||||
* \[sub, main, deposit\]
|
||||
**/
|
||||
SubIdentityRemoved: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
|
||||
/**
|
||||
* A sub-identity was cleared, and the given deposit repatriated from the
|
||||
* main identity account to the sub-identity account. \[sub, main, deposit\]
|
||||
**/
|
||||
SubIdentityRevoked: AugmentedEvent<ApiType, [AccountId, AccountId, Balance]>;
|
||||
};
|
||||
imOnline: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* At the end of the session, no offence was committed.
|
||||
**/
|
||||
AllGood: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* A new heartbeat was received from `AuthorityId` \[authority_id\]
|
||||
**/
|
||||
HeartbeatReceived: AugmentedEvent<ApiType, [AuthorityId]>;
|
||||
/**
|
||||
* At the end of the session, at least one validator was found to be \[offline\].
|
||||
**/
|
||||
SomeOffline: AugmentedEvent<ApiType, [Vec<IdentificationTuple>]>;
|
||||
};
|
||||
indices: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A account index was assigned. \[index, who\]
|
||||
**/
|
||||
IndexAssigned: AugmentedEvent<ApiType, [AccountId, AccountIndex]>;
|
||||
/**
|
||||
* A account index has been freed up (unassigned). \[index\]
|
||||
**/
|
||||
IndexFreed: AugmentedEvent<ApiType, [AccountIndex]>;
|
||||
/**
|
||||
* A account index has been frozen to its current account ID. \[index, who\]
|
||||
**/
|
||||
IndexFrozen: AugmentedEvent<ApiType, [AccountIndex, AccountId]>;
|
||||
};
|
||||
multisig: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A multisig operation has been approved by someone.
|
||||
* \[approving, timepoint, multisig, call_hash\]
|
||||
**/
|
||||
MultisigApproval: AugmentedEvent<ApiType, [AccountId, Timepoint, AccountId, CallHash]>;
|
||||
/**
|
||||
* A multisig operation has been cancelled. \[cancelling, timepoint, multisig, call_hash\]
|
||||
**/
|
||||
MultisigCancelled: AugmentedEvent<ApiType, [AccountId, Timepoint, AccountId, CallHash]>;
|
||||
/**
|
||||
* A multisig operation has been executed. \[approving, timepoint, multisig, call_hash\]
|
||||
**/
|
||||
MultisigExecuted: AugmentedEvent<ApiType, [AccountId, Timepoint, AccountId, CallHash, DispatchResult]>;
|
||||
/**
|
||||
* A new multisig operation has begun. \[approving, multisig, call_hash\]
|
||||
**/
|
||||
NewMultisig: AugmentedEvent<ApiType, [AccountId, AccountId, CallHash]>;
|
||||
};
|
||||
offences: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* There is an offence reported of the given `kind` happened at the `session_index` and
|
||||
* (kind-specific) time slot. This event is not deposited for duplicate slashes. last
|
||||
* element indicates of the offence was applied (true) or queued (false)
|
||||
* \[kind, timeslot, applied\].
|
||||
**/
|
||||
Offence: AugmentedEvent<ApiType, [Kind, OpaqueTimeSlot, bool]>;
|
||||
};
|
||||
proxy: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An announcement was placed to make a call in the future. \[real, proxy, call_hash\]
|
||||
**/
|
||||
Announced: AugmentedEvent<ApiType, [AccountId, AccountId, Hash]>;
|
||||
/**
|
||||
* Anonymous account has been created by new proxy with given
|
||||
* disambiguation index and proxy type. \[anonymous, who, proxy_type, disambiguation_index\]
|
||||
**/
|
||||
AnonymousCreated: AugmentedEvent<ApiType, [AccountId, AccountId, ProxyType, u16]>;
|
||||
/**
|
||||
* A proxy was executed correctly, with the given \[result\].
|
||||
**/
|
||||
ProxyExecuted: AugmentedEvent<ApiType, [DispatchResult]>;
|
||||
};
|
||||
recovery: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Lost account has been successfully recovered by rescuer account.
|
||||
* \[lost, rescuer\]
|
||||
**/
|
||||
AccountRecovered: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* A recovery process for lost account by rescuer account has been closed.
|
||||
* \[lost, rescuer\]
|
||||
**/
|
||||
RecoveryClosed: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* A recovery process has been set up for an \[account\].
|
||||
**/
|
||||
RecoveryCreated: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A recovery process has been initiated for lost account by rescuer account.
|
||||
* \[lost, rescuer\]
|
||||
**/
|
||||
RecoveryInitiated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* A recovery process has been removed for an \[account\].
|
||||
**/
|
||||
RecoveryRemoved: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A recovery process for lost account by rescuer account has been vouched for by sender.
|
||||
* \[lost, rescuer, sender\]
|
||||
**/
|
||||
RecoveryVouched: AugmentedEvent<ApiType, [AccountId, AccountId, AccountId]>;
|
||||
};
|
||||
scheduler: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Canceled some task. \[when, index\]
|
||||
**/
|
||||
Canceled: AugmentedEvent<ApiType, [BlockNumber, u32]>;
|
||||
/**
|
||||
* Dispatched some task. \[task, id, result\]
|
||||
**/
|
||||
Dispatched: AugmentedEvent<ApiType, [TaskAddress, Option<Bytes>, DispatchResult]>;
|
||||
/**
|
||||
* Scheduled some task. \[when, index\]
|
||||
**/
|
||||
Scheduled: AugmentedEvent<ApiType, [BlockNumber, u32]>;
|
||||
};
|
||||
session: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* New session has happened. Note that the argument is the \[session_index\], not the block
|
||||
* number as the type might suggest.
|
||||
**/
|
||||
NewSession: AugmentedEvent<ApiType, [SessionIndex]>;
|
||||
};
|
||||
society: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A \[candidate\] was dropped (due to an excess of bids in the system).
|
||||
**/
|
||||
AutoUnbid: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A membership bid just happened. The given account is the candidate's ID and their offer
|
||||
* is the second. \[candidate_id, offer\]
|
||||
**/
|
||||
Bid: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A \[candidate\] has been suspended
|
||||
**/
|
||||
CandidateSuspended: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A \[member\] has been challenged
|
||||
**/
|
||||
Challenged: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A vote has been placed for a defending member \[voter, vote\]
|
||||
**/
|
||||
DefenderVote: AugmentedEvent<ApiType, [AccountId, bool]>;
|
||||
/**
|
||||
* Some funds were deposited into the society account. \[value\]
|
||||
**/
|
||||
Deposit: AugmentedEvent<ApiType, [Balance]>;
|
||||
/**
|
||||
* The society is founded by the given identity. \[founder\]
|
||||
**/
|
||||
Founded: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A group of candidates have been inducted. The batch's primary is the first value, the
|
||||
* batch in full is the second. \[primary, candidates\]
|
||||
**/
|
||||
Inducted: AugmentedEvent<ApiType, [AccountId, Vec<AccountId>]>;
|
||||
/**
|
||||
* A \[member\] has been suspended
|
||||
**/
|
||||
MemberSuspended: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A new \[max\] member count has been set
|
||||
**/
|
||||
NewMaxMembers: AugmentedEvent<ApiType, [u32]>;
|
||||
/**
|
||||
* A suspended member has been judged. \[who, judged\]
|
||||
**/
|
||||
SuspendedMemberJudgement: AugmentedEvent<ApiType, [AccountId, bool]>;
|
||||
/**
|
||||
* A \[candidate\] was dropped (by their request).
|
||||
**/
|
||||
Unbid: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Society is unfounded. \[founder\]
|
||||
**/
|
||||
Unfounded: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A \[candidate\] was dropped (by request of who vouched for them).
|
||||
**/
|
||||
Unvouch: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A vote has been placed \[candidate, voter, vote\]
|
||||
**/
|
||||
Vote: AugmentedEvent<ApiType, [AccountId, AccountId, bool]>;
|
||||
/**
|
||||
* A membership bid just happened by vouching. The given account is the candidate's ID and
|
||||
* their offer is the second. The vouching party is the third. \[candidate_id, offer, vouching\]
|
||||
**/
|
||||
Vouch: AugmentedEvent<ApiType, [AccountId, Balance, AccountId]>;
|
||||
};
|
||||
staking: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An account has bonded this amount. \[stash, amount\]
|
||||
*
|
||||
* NOTE: This event is only emitted when funds are bonded via a dispatchable. Notably,
|
||||
* it will not be emitted for staking rewards when they are added to stake.
|
||||
**/
|
||||
Bonded: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* The era payout has been set; the first balance is the validator-payout; the second is
|
||||
* the remainder from the maximum amount of reward.
|
||||
* \[era_index, validator_payout, remainder\]
|
||||
**/
|
||||
EraPayout: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>;
|
||||
/**
|
||||
* An old slashing report from a prior era was discarded because it could
|
||||
* not be processed. \[session_index\]
|
||||
**/
|
||||
OldSlashingReportDiscarded: AugmentedEvent<ApiType, [SessionIndex]>;
|
||||
/**
|
||||
* The staker has been rewarded by this amount. \[stash, amount\]
|
||||
**/
|
||||
Reward: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* One validator (and its nominators) has been slashed by the given amount.
|
||||
* \[validator, amount\]
|
||||
**/
|
||||
Slash: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A new solution for the upcoming election has been stored. \[compute\]
|
||||
**/
|
||||
SolutionStored: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
/**
|
||||
* A new set of stakers was elected with the given \[compute\].
|
||||
**/
|
||||
StakingElection: AugmentedEvent<ApiType, [ElectionCompute]>;
|
||||
/**
|
||||
* An account has unbonded this amount. \[stash, amount\]
|
||||
**/
|
||||
Unbonded: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* An account has called `withdraw_unbonded` and removed unbonding chunks worth `Balance`
|
||||
* from the unlocking queue. \[stash, amount\]
|
||||
**/
|
||||
Withdrawn: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
};
|
||||
sudo: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* The \[sudoer\] just switched identity; the old key is supplied.
|
||||
**/
|
||||
KeyChanged: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A sudo just took place. \[result\]
|
||||
**/
|
||||
Sudid: AugmentedEvent<ApiType, [DispatchResult]>;
|
||||
/**
|
||||
* A sudo just took place. \[result\]
|
||||
**/
|
||||
SudoAsDone: AugmentedEvent<ApiType, [DispatchResult]>;
|
||||
};
|
||||
system: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* `:code` was updated.
|
||||
**/
|
||||
CodeUpdated: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* An extrinsic failed. \[error, info\]
|
||||
**/
|
||||
ExtrinsicFailed: AugmentedEvent<ApiType, [DispatchError, DispatchInfo]>;
|
||||
/**
|
||||
* An extrinsic completed successfully. \[info\]
|
||||
**/
|
||||
ExtrinsicSuccess: AugmentedEvent<ApiType, [DispatchInfo]>;
|
||||
/**
|
||||
* An \[account\] was reaped.
|
||||
**/
|
||||
KilledAccount: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* A new \[account\] was created.
|
||||
**/
|
||||
NewAccount: AugmentedEvent<ApiType, [AccountId]>;
|
||||
};
|
||||
technicalCommittee: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A motion was approved by the required threshold.
|
||||
* \[proposal_hash\]
|
||||
**/
|
||||
Approved: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A proposal was closed because its threshold was reached or after its duration was up.
|
||||
* \[proposal_hash, yes, no\]
|
||||
**/
|
||||
Closed: AugmentedEvent<ApiType, [Hash, MemberCount, MemberCount]>;
|
||||
/**
|
||||
* A motion was not approved by the required threshold.
|
||||
* \[proposal_hash\]
|
||||
**/
|
||||
Disapproved: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A motion was executed; result will be `Ok` if it returned without error.
|
||||
* \[proposal_hash, result\]
|
||||
**/
|
||||
Executed: AugmentedEvent<ApiType, [Hash, DispatchResult]>;
|
||||
/**
|
||||
* A single member did some action; result will be `Ok` if it returned without error.
|
||||
* \[proposal_hash, result\]
|
||||
**/
|
||||
MemberExecuted: AugmentedEvent<ApiType, [Hash, DispatchResult]>;
|
||||
/**
|
||||
* A motion (given hash) has been proposed (by given account) with a threshold (given
|
||||
* `MemberCount`).
|
||||
* \[account, proposal_index, proposal_hash, threshold\]
|
||||
**/
|
||||
Proposed: AugmentedEvent<ApiType, [AccountId, ProposalIndex, Hash, MemberCount]>;
|
||||
/**
|
||||
* A motion (given hash) has been voted on by given account, leaving
|
||||
* a tally (yes votes and no votes given respectively as `MemberCount`).
|
||||
* \[account, proposal_hash, voted, yes, no\]
|
||||
**/
|
||||
Voted: AugmentedEvent<ApiType, [AccountId, Hash, bool, MemberCount, MemberCount]>;
|
||||
};
|
||||
technicalMembership: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Phantom member, never used.
|
||||
**/
|
||||
Dummy: AugmentedEvent<ApiType, [PhantomData]>;
|
||||
/**
|
||||
* One of the members' keys changed.
|
||||
**/
|
||||
KeyChanged: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* The given member was added; see the transaction for who.
|
||||
**/
|
||||
MemberAdded: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* The given member was removed; see the transaction for who.
|
||||
**/
|
||||
MemberRemoved: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* The membership was reset; see the transaction for who the new set is.
|
||||
**/
|
||||
MembersReset: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Two members were swapped; see the transaction for who.
|
||||
**/
|
||||
MembersSwapped: AugmentedEvent<ApiType, []>;
|
||||
};
|
||||
tips: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* A new tip suggestion has been opened. \[tip_hash\]
|
||||
**/
|
||||
NewTip: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A tip suggestion has been closed. \[tip_hash, who, payout\]
|
||||
**/
|
||||
TipClosed: AugmentedEvent<ApiType, [Hash, AccountId, Balance]>;
|
||||
/**
|
||||
* A tip suggestion has reached threshold and is closing. \[tip_hash\]
|
||||
**/
|
||||
TipClosing: AugmentedEvent<ApiType, [Hash]>;
|
||||
/**
|
||||
* A tip suggestion has been retracted. \[tip_hash\]
|
||||
**/
|
||||
TipRetracted: AugmentedEvent<ApiType, [Hash]>;
|
||||
};
|
||||
treasury: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Some funds have been allocated. \[proposal_index, award, beneficiary\]
|
||||
**/
|
||||
Awarded: AugmentedEvent<ApiType, [ProposalIndex, Balance, AccountId]>;
|
||||
/**
|
||||
* Some of our funds have been burnt. \[burn\]
|
||||
**/
|
||||
Burnt: AugmentedEvent<ApiType, [Balance]>;
|
||||
/**
|
||||
* Some funds have been deposited. \[deposit\]
|
||||
**/
|
||||
Deposit: AugmentedEvent<ApiType, [Balance]>;
|
||||
/**
|
||||
* New proposal. \[proposal_index\]
|
||||
**/
|
||||
Proposed: AugmentedEvent<ApiType, [ProposalIndex]>;
|
||||
/**
|
||||
* A proposal was rejected; funds were slashed. \[proposal_index, slashed\]
|
||||
**/
|
||||
Rejected: AugmentedEvent<ApiType, [ProposalIndex, Balance]>;
|
||||
/**
|
||||
* Spending has finished; this is the amount that rolls over until next spend.
|
||||
* \[budget_remaining\]
|
||||
**/
|
||||
Rollover: AugmentedEvent<ApiType, [Balance]>;
|
||||
/**
|
||||
* We have ended a spend period and will now allocate funds. \[budget_remaining\]
|
||||
**/
|
||||
Spending: AugmentedEvent<ApiType, [Balance]>;
|
||||
};
|
||||
utility: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* Batch of dispatches completed fully with no error.
|
||||
**/
|
||||
BatchCompleted: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Batch of dispatches did not complete fully. Index of first failing dispatch given, as
|
||||
* well as the error. \[index, error\]
|
||||
**/
|
||||
BatchInterrupted: AugmentedEvent<ApiType, [u32, DispatchError]>;
|
||||
};
|
||||
vesting: {
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
/**
|
||||
* An \[account\] has become fully vested. No further vesting can happen.
|
||||
**/
|
||||
VestingCompleted: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* The amount vested has been updated. This could indicate more funds are available. The
|
||||
* balance given is the amount which is left unvested (and thus locked).
|
||||
* \[account, unvested\]
|
||||
**/
|
||||
VestingUpdated: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
};
|
||||
}
|
||||
|
||||
export interface DecoratedEvents<ApiType extends ApiTypes> extends AugmentedEvents<ApiType> {
|
||||
[key: string]: ModuleEvents<ApiType>;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './consts';
|
||||
import './errors';
|
||||
import './events';
|
||||
import './query';
|
||||
import './rpc';
|
||||
import './tx';
|
||||
|
||||
+181
-181
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Metadata } from '@polkadot/metadata';
|
||||
import type { Bytes, HashMap, Json, Null, Option, StorageKey, Text, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||
import type { Bytes, HashMap, Json, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
|
||||
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
|
||||
import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
|
||||
@@ -11,12 +11,13 @@ import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { ContractCallRequest, ContractExecResult } from '@polkadot/types/interfaces/contracts';
|
||||
import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
|
||||
import type { EthAccount, EthCallRequest, EthFilter, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
|
||||
import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, BlockNumber, H256, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||
import type { ReadProof, RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
|
||||
|
||||
@@ -134,6 +135,160 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
**/
|
||||
finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification | string | Uint8Array) => Observable<bool>>;
|
||||
};
|
||||
eth: {
|
||||
/**
|
||||
* Returns accounts list.
|
||||
**/
|
||||
accounts: AugmentedRpc<() => Observable<Vec<H160>>>;
|
||||
/**
|
||||
* Returns balance of the given account.
|
||||
**/
|
||||
blockNumber: AugmentedRpc<() => Observable<U256>>;
|
||||
/**
|
||||
* Call contract, returning the output data.
|
||||
**/
|
||||
call: AugmentedRpc<(request: EthCallRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<Bytes>>;
|
||||
/**
|
||||
* Returns the chain ID used for transaction signing at the current best block. None is returned if not available.
|
||||
**/
|
||||
chainId: AugmentedRpc<() => Observable<U64>>;
|
||||
/**
|
||||
* Returns block author.
|
||||
**/
|
||||
coinbase: AugmentedRpc<() => Observable<H160>>;
|
||||
/**
|
||||
* Estimate gas needed for execution of given contract.
|
||||
**/
|
||||
estimateGas: AugmentedRpc<(request: EthCallRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns current gas price.
|
||||
**/
|
||||
gasPrice: AugmentedRpc<() => Observable<U256>>;
|
||||
/**
|
||||
* Returns balance of the given account.
|
||||
**/
|
||||
getBalance: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns block with given hash.
|
||||
**/
|
||||
getBlockByHash: AugmentedRpc<(hash: H256 | string | Uint8Array, full: bool | boolean | Uint8Array) => Observable<Option<EthRichBlock>>>;
|
||||
/**
|
||||
* Returns block with given number.
|
||||
**/
|
||||
getBlockByNumber: AugmentedRpc<(block: BlockNumber | AnyNumber | Uint8Array, full: bool | boolean | Uint8Array) => Observable<Option<EthRichBlock>>>;
|
||||
/**
|
||||
* Returns the number of transactions in a block with given hash.
|
||||
**/
|
||||
getBlockTransactionCountByHash: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns the number of transactions in a block with given block number.
|
||||
**/
|
||||
getBlockTransactionCountByNumber: AugmentedRpc<(block: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns the code at given address at given time (block number).
|
||||
**/
|
||||
getCode: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<Bytes>>;
|
||||
/**
|
||||
* Returns logs matching given filter object.
|
||||
**/
|
||||
getLogs: AugmentedRpc<(filter: EthFilter | { fromBlock?: any; toBlock?: any; blockHash?: any; address?: any; topics?: any } | string | Uint8Array) => Observable<Vec<EthLog>>>;
|
||||
/**
|
||||
* Returns proof for account and storage.
|
||||
**/
|
||||
getProof: AugmentedRpc<(address: H160 | string | Uint8Array, storageKeys: Vec<H256> | (H256 | string | Uint8Array)[], number: BlockNumber | AnyNumber | Uint8Array) => Observable<EthAccount>>;
|
||||
/**
|
||||
* Returns content of the storage at given address.
|
||||
**/
|
||||
getStorageAt: AugmentedRpc<(address: H160 | string | Uint8Array, index: U256 | AnyNumber | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<H256>>;
|
||||
/**
|
||||
* Returns transaction at given block hash and index.
|
||||
**/
|
||||
getTransactionByBlockHashAndIndex: AugmentedRpc<(hash: H256 | string | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthTransaction>>;
|
||||
/**
|
||||
* Returns transaction by given block number and index.
|
||||
**/
|
||||
getTransactionByBlockNumberAndIndex: AugmentedRpc<(number: BlockNumber | AnyNumber | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthTransaction>>;
|
||||
/**
|
||||
* Get transaction by its hash.
|
||||
**/
|
||||
getTransactionByHash: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<EthTransaction>>;
|
||||
/**
|
||||
* Returns the number of transactions sent from given address at given time (block number).
|
||||
**/
|
||||
getTransactionCount: AugmentedRpc<(hash: H256 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns transaction receipt by transaction hash.
|
||||
**/
|
||||
getTransactionReceipt: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<EthReceipt>>;
|
||||
/**
|
||||
* Returns an uncles at given block and index.
|
||||
**/
|
||||
getUncleByBlockHashAndIndex: AugmentedRpc<(hash: H256 | string | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthRichBlock>>;
|
||||
/**
|
||||
* Returns an uncles at given block and index.
|
||||
**/
|
||||
getUncleByBlockNumberAndIndex: AugmentedRpc<(number: BlockNumber | AnyNumber | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthRichBlock>>;
|
||||
/**
|
||||
* Returns the number of uncles in a block with given hash.
|
||||
**/
|
||||
getUncleCountByBlockHash: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns the number of uncles in a block with given block number.
|
||||
**/
|
||||
getUncleCountByBlockNumber: AugmentedRpc<(number: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
|
||||
/**
|
||||
* Returns the hash of the current block, the seedHash, and the boundary condition to be met.
|
||||
**/
|
||||
getWork: AugmentedRpc<() => Observable<EthWork>>;
|
||||
/**
|
||||
* Returns the number of hashes per second that the node is mining with.
|
||||
**/
|
||||
hashrate: AugmentedRpc<() => Observable<U256>>;
|
||||
/**
|
||||
* Returns true if client is actively listening for network connections. Otherwise false.
|
||||
**/
|
||||
listening: AugmentedRpc<() => Observable<bool>>;
|
||||
/**
|
||||
* Returns true if client is actively mining new blocks.
|
||||
**/
|
||||
mining: AugmentedRpc<() => Observable<bool>>;
|
||||
/**
|
||||
* Returns number of peers connected to node.
|
||||
**/
|
||||
peerCount: AugmentedRpc<() => Observable<Text>>;
|
||||
/**
|
||||
* Returns protocol version encoded as a string (quotes are necessary).
|
||||
**/
|
||||
protocolVersion: AugmentedRpc<() => Observable<u64>>;
|
||||
/**
|
||||
* Sends signed transaction, returning its hash.
|
||||
**/
|
||||
sendRawTransaction: AugmentedRpc<(bytes: Bytes | string | Uint8Array) => Observable<H256>>;
|
||||
/**
|
||||
* Sends transaction; will block waiting for signer to return the transaction hash
|
||||
**/
|
||||
sendTransaction: AugmentedRpc<(tx: EthTransactionRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array) => Observable<H256>>;
|
||||
/**
|
||||
* Used for submitting mining hashrate.
|
||||
**/
|
||||
submitHashrate: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array, hash: H256 | string | Uint8Array) => Observable<bool>>;
|
||||
/**
|
||||
* Used for submitting a proof-of-work solution.
|
||||
**/
|
||||
submitWork: AugmentedRpc<(nonce: H64 | string | Uint8Array, headerHash: H256 | string | Uint8Array, mixDigest: H256 | string | Uint8Array) => Observable<bool>>;
|
||||
/**
|
||||
* Subscribe to Eth subscription.
|
||||
**/
|
||||
subscribe: AugmentedRpc<(kind: EthSubKind | 'newHeads' | 'logs' | 'newPendingTransactions' | 'syncing' | number | Uint8Array, params?: EthSubParams | { None: any } | { Logs: any } | string | Uint8Array) => Observable<Null>>;
|
||||
/**
|
||||
* Returns an object with data about the sync status or false.
|
||||
**/
|
||||
syncing: AugmentedRpc<() => Observable<EthSyncStatus>>;
|
||||
/**
|
||||
* Returns protocol version.
|
||||
**/
|
||||
version: AugmentedRpc<() => Observable<Text>>;
|
||||
};
|
||||
grandpa: {
|
||||
/**
|
||||
* Prove finality for the range (begin; end] hash.
|
||||
|
||||
+205
-205
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,18 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constants, DecoratedMeta } from '@polkadot/metadata/decorate/types';
|
||||
import type { DecoratedMeta } from '@polkadot/metadata/decorate/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, InterfaceTypes, Registry, RegistryTypes } from '@polkadot/types/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, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
import type { ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableStorage, QueryableStorageEntry, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { decorateDerive, DeriveCustom, ExactDerive } from '@polkadot/api-derive';
|
||||
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
|
||||
import { memo } from '@polkadot/api-derive/util';
|
||||
import { expandMetadata, Metadata } from '@polkadot/metadata';
|
||||
import { RpcCore } from '@polkadot/rpc-core';
|
||||
@@ -20,9 +20,9 @@ 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 { assert, compactStripLength, logger, u8aToHex } from '@polkadot/util';
|
||||
import { arrayChunk, arrayFlatten, assert, compactStripLength, logger, u8aToHex } from '@polkadot/util';
|
||||
import { BehaviorSubject, combineLatest, Observable, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap, take, tap, toArray } from '@polkadot/x-rxjs/operators';
|
||||
import { map, switchMap, tap, toArray } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { createSubmittable } from '../submittable';
|
||||
import { augmentObject } from '../util/augmentObject';
|
||||
@@ -38,8 +38,8 @@ interface MetaDecoration {
|
||||
toJSON: () => any;
|
||||
}
|
||||
|
||||
const PAGE_SIZE_KEYS = 384;
|
||||
const PAGE_SIZE_VALS = PAGE_SIZE_KEYS;
|
||||
// the max amount of keys/values that we will retrieve at once
|
||||
const PAGE_SIZE = 384;
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
@@ -57,6 +57,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
protected _derive?: ReturnType<Decorate<ApiType>['_decorateDerive']>;
|
||||
|
||||
protected _errors: DecoratedErrors<ApiType> = {} as DecoratedErrors<ApiType>;
|
||||
|
||||
protected _events: DecoratedEvents<ApiType> = {} as DecoratedEvents<ApiType>;
|
||||
|
||||
protected _extrinsics?: SubmittableExtrinsics<ApiType>;
|
||||
|
||||
protected _extrinsicType: number = EXTRINSIC_DEFAULT_VERSION;
|
||||
@@ -84,7 +88,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
protected _runtimeVersion?: RuntimeVersion;
|
||||
|
||||
protected _rx: ApiInterfaceRx = {
|
||||
consts: {} as Constants,
|
||||
consts: {} as QueryableConsts<'rxjs'>,
|
||||
query: {} as QueryableStorage<'rxjs'>,
|
||||
tx: {} as SubmittableExtrinsics<'rxjs'>
|
||||
} as ApiInterfaceRx;
|
||||
@@ -195,6 +199,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
// 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);
|
||||
@@ -338,6 +344,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
const decorated = (...params: Arg[]): SubmittableExtrinsic<ApiType> =>
|
||||
creator(method(...params));
|
||||
|
||||
// pass through the `.is`
|
||||
decorated.is = (other: IMethod<AnyTuple>) =>
|
||||
method.is(other);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return this._decorateFunctionMeta(method as any, decorated as any) as unknown as SubmittableExtrinsicFunction<ApiType>;
|
||||
}
|
||||
@@ -371,6 +381,9 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decorated.hash = decorateMethod((arg1?: Arg, arg2?: Arg): Observable<Hash> =>
|
||||
this._rpcCore.state.getStorageHash(getArgs(arg1, arg2)));
|
||||
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section && key.method === creator.method;
|
||||
|
||||
decorated.key = (arg1?: Arg, arg2?: Arg): string =>
|
||||
u8aToHex(compactStripLength(creator(creator.meta.type.isDoubleMap ? [arg1, arg2] : arg1))[1]);
|
||||
|
||||
@@ -453,25 +466,21 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
));
|
||||
}
|
||||
|
||||
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE_VALS sizes
|
||||
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
||||
private _retrieveMulti (keys: [StorageEntry, Arg | Arg[]][]): Observable<Codec[]> {
|
||||
if (!keys.length) {
|
||||
return of([]);
|
||||
}
|
||||
|
||||
return combineLatest(
|
||||
...Array(Math.ceil(keys.length / PAGE_SIZE_VALS))
|
||||
.fill(0)
|
||||
.map((_, index): Observable<Codec[]> =>
|
||||
(this.hasSubscriptions
|
||||
? this._rpcCore.state.subscribeStorage
|
||||
: this._rpcCore.state.queryStorageAt
|
||||
)(keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS))
|
||||
)
|
||||
).pipe(
|
||||
map((valsArr): Codec[] =>
|
||||
valsArr.reduce((result: Codec[], vals) => result.concat(vals), [])
|
||||
arrayChunk(keys, PAGE_SIZE).map((keys) =>
|
||||
(this.hasSubscriptions
|
||||
? this._rpcCore.state.subscribeStorage
|
||||
: this._rpcCore.state.queryStorageAt
|
||||
)(keys)
|
||||
)
|
||||
).pipe(
|
||||
map((valsArr): Codec[] => arrayFlatten(valsArr))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -481,8 +490,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
const headKey = iterKey(arg).toHex();
|
||||
const startSubject = new BehaviorSubject<string>(headKey);
|
||||
const query = at
|
||||
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_KEYS, startKey, at)
|
||||
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_KEYS, startKey);
|
||||
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey, at)
|
||||
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey);
|
||||
|
||||
return startSubject.pipe(
|
||||
switchMap((startKey) =>
|
||||
@@ -491,12 +500,12 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
)
|
||||
),
|
||||
tap((keys): void => {
|
||||
keys.length === PAGE_SIZE_KEYS
|
||||
? startSubject.next(keys[PAGE_SIZE_KEYS - 1].toHex())
|
||||
keys.length === PAGE_SIZE
|
||||
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
|
||||
: startSubject.complete();
|
||||
}),
|
||||
toArray(), // toArray since we want to startSubject to be completed
|
||||
map((keysArr: StorageKey[][]) => keysArr.reduce((result: StorageKey[], keys) => result.concat(keys), []))
|
||||
map((keysArr: StorageKey[][]) => arrayFlatten(keysArr))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -511,28 +520,19 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, arg?: Arg): Observable<[StorageKey, Codec][]> {
|
||||
const query = this._rpcCore.state.queryStorageAt
|
||||
? at
|
||||
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
|
||||
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset)
|
||||
// this is horrible, but need older support (which now doesn't work with at)
|
||||
: (keyset: StorageKey[]) => this._rpcCore.state.subscribeStorage(keyset).pipe(take(1));
|
||||
const query = at
|
||||
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
|
||||
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
|
||||
|
||||
return this._retrieveMapKeys(entry, at, arg).pipe(
|
||||
switchMap((keys) =>
|
||||
combineLatest<[StorageKey[], ...Codec[][]]>([
|
||||
of(keys),
|
||||
...Array(Math.ceil(keys.length / PAGE_SIZE_VALS))
|
||||
.fill(0)
|
||||
.map((_, index): Observable<Codec[]> =>
|
||||
query(keys.slice(index * PAGE_SIZE_VALS, (index * PAGE_SIZE_VALS) + PAGE_SIZE_VALS))
|
||||
)
|
||||
])
|
||||
),
|
||||
map(([keys, ...valsArr]): [StorageKey, Codec][] =>
|
||||
valsArr
|
||||
.reduce((result: Codec[], vals) => result.concat(vals), [])
|
||||
.map((value, index) => [keys[index], value])
|
||||
combineLatest(
|
||||
arrayChunk(keys, PAGE_SIZE).map((keys) => query(keys))
|
||||
).pipe(
|
||||
map((valsArr) =>
|
||||
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -540,24 +540,21 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
private _retrieveMapEntriesPaged (entry: StorageEntry, opts: PaginationOptions): Observable<[StorageKey, Codec][]> {
|
||||
return this._retrieveMapKeysPaged(entry, opts).pipe(
|
||||
switchMap((keys) =>
|
||||
combineLatest<[StorageKey[], ...Codec[][]]>([
|
||||
of(keys),
|
||||
this._rpcCore.state.queryStorageAt<Codec[]>(keys)
|
||||
])
|
||||
),
|
||||
map(([keys, ...valsArr]): [StorageKey, Codec][] =>
|
||||
valsArr
|
||||
.reduce((result: Codec[], vals) => result.concat(vals), [])
|
||||
.map((value, index) => [keys[index], value])
|
||||
this._rpcCore.state.queryStorageAt(keys).pipe(
|
||||
map((valsArr) =>
|
||||
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected _decorateDeriveRx (decorateMethod: DecorateMethod<ApiType>): DeriveAllSections<'rxjs', ExactDerive> {
|
||||
const specName = this._runtimeVersion?.specName.toString();
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
const derives = { ...this._options.derives, ...(this._options.typesBundle?.spec?.[specName ?? '']?.derives as DeriveCustom) }; // use typesBundle
|
||||
const derives = {
|
||||
...this._options.derives,
|
||||
...(this._options.typesBundle?.spec?.[specName ?? '']?.derives || {})
|
||||
};
|
||||
|
||||
// Pull in derive from api-derive
|
||||
const derive = decorateDerive(this.#instanceId, this._rx, derives);
|
||||
|
||||
@@ -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, DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types';
|
||||
import type { ApiInterfaceRx, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '../types';
|
||||
|
||||
import { assertReturn } from '@polkadot/util';
|
||||
|
||||
@@ -54,6 +54,20 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> {
|
||||
return assertResult(this._derive);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Errors from metadata
|
||||
*/
|
||||
public get errors (): DecoratedErrors<ApiType> {
|
||||
return assertResult(this._errors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Events from metadata
|
||||
*/
|
||||
public get events (): DecoratedEvents<ApiType> {
|
||||
return assertResult(this._events);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the version of extrinsics in-use on this chain
|
||||
*/
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
|
||||
// Simple non-runnable checks to test type definitions in the editor itself
|
||||
|
||||
import type { AccountId, Balance, Header, Index } from '@polkadot/types/interfaces';
|
||||
import type { IExtrinsic, IMethod } from '@polkadot/types/types';
|
||||
import type { StorageKey } from '@polkadot/types';
|
||||
import type { AccountId, Balance, DispatchError, EventRecord, Header, Index } from '@polkadot/types/interfaces';
|
||||
import type { AnyTuple, IExtrinsic, IMethod } from '@polkadot/types/types';
|
||||
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { HeaderExtended } from '@polkadot/api-derive';
|
||||
@@ -34,6 +35,39 @@ async function derive (api: ApiPromise): Promise<void> {
|
||||
console.log('fees', fees);
|
||||
}
|
||||
|
||||
function errors (api: ApiPromise): void {
|
||||
const someError = {} as DispatchError;
|
||||
|
||||
// existing
|
||||
console.log(api.errors.vesting.AmountLow.is(someError));
|
||||
|
||||
// non-existing error, existing module
|
||||
console.log(api.errors.vesting.Something.is(someError));
|
||||
|
||||
// something random
|
||||
console.log(api.errors.something.Random.is(someError));
|
||||
}
|
||||
|
||||
function events (api: ApiPromise): void {
|
||||
const eventRecord = {} as EventRecord;
|
||||
|
||||
// existing
|
||||
if (api.events.balances.Transfer.is(eventRecord)) {
|
||||
// the types are correctly expanded
|
||||
const [from, to, amount] = eventRecord.event.data;
|
||||
|
||||
console.log(from.toHuman(), to.toHuman(), amount.toBn());
|
||||
}
|
||||
|
||||
// something random
|
||||
if (api.events.something.Random.is(eventRecord)) {
|
||||
// the types are just codec
|
||||
const [a, b] = eventRecord.event.data;
|
||||
|
||||
console.log(a.toHuman(), b.toHuman());
|
||||
}
|
||||
}
|
||||
|
||||
async function query (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
const intentions = await api.query.staking.bonded();
|
||||
|
||||
@@ -102,6 +136,16 @@ async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void
|
||||
const entries = await api.query.system.events.range(['0x12345', '0x7890']);
|
||||
|
||||
console.log(`Received ${entries.length} entries, ${entries.map(([hash, events]) => `${hash.toHex()}: ${events.length} events`).join(', ')}`);
|
||||
|
||||
// is
|
||||
const key = {} as StorageKey;
|
||||
|
||||
if (api.query.balances.account.is(key)) {
|
||||
const [accountId] = key.args;
|
||||
|
||||
// should be AccountId type
|
||||
console.log(accountId.toHuman());
|
||||
}
|
||||
}
|
||||
|
||||
async function rpc (api: ApiPromise): Promise<void> {
|
||||
@@ -143,7 +187,7 @@ async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
// transfer, also allows for BigInt inputs here
|
||||
const transfer = api.tx.balances.transfer(pairs.bob.address, 123456789n);
|
||||
|
||||
console.log('transfer casted', transfer as IMethod, transfer as IExtrinsic);
|
||||
console.log('transfer casted', transfer as IMethod<AnyTuple>, transfer as IExtrinsic<AnyTuple>);
|
||||
|
||||
// simple "return the hash" variant
|
||||
console.log('hash:', (await transfer.signAndSend(pairs.alice)).toHex());
|
||||
@@ -179,6 +223,14 @@ async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
|
||||
// it handles enum inputs correctly
|
||||
await api.tx.democracy.proxyVote(123, { Split: { nay: 456, yay: 123 } }).signAndSend(pairs.alice);
|
||||
|
||||
// is
|
||||
if (api.tx.balances.transfer.is(second)) {
|
||||
const [recipientId, balance] = second.args;
|
||||
|
||||
// should be LookupSource & Balance types
|
||||
console.log(recipientId.toHuman(), balance.toNumber());
|
||||
}
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
@@ -189,6 +241,8 @@ async function main (): Promise<void> {
|
||||
Promise.all([
|
||||
consts(api),
|
||||
derive(api),
|
||||
errors(api),
|
||||
events(api),
|
||||
query(api, pairs),
|
||||
queryExtra(api, pairs),
|
||||
rpc(api),
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { IsError } from '@polkadot/metadata/decorate/types';
|
||||
import type { ApiTypes } from './base';
|
||||
|
||||
// In errors we don't need the ApiType, however add it for consistency
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
|
||||
export interface AugmentedErrors<ApiType extends ApiTypes> { }
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export type AugmentedError<ApiType extends ApiTypes> = IsError;
|
||||
|
||||
export interface ModuleErrors<ApiType extends ApiTypes> {
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { IsEvent } from '@polkadot/metadata/decorate/types';
|
||||
import type { AnyTuple } from '@polkadot/types/types';
|
||||
import type { ApiTypes } from './base';
|
||||
|
||||
// In events we don't need the ApiType, however add it for consistency
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
|
||||
export interface AugmentedEvents<ApiType extends ApiTypes> { }
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export type AugmentedEvent<ApiType extends ApiTypes, T extends AnyTuple = AnyTuple> = IsEvent<T>;
|
||||
|
||||
export interface ModuleEvents<ApiType extends ApiTypes> {
|
||||
[key: string]: AugmentedEvent<ApiType, AnyTuple>;
|
||||
}
|
||||
@@ -23,6 +23,8 @@ export { ApiBase } from '../base';
|
||||
export * from '../submittable/types';
|
||||
export * from './base';
|
||||
export * from './consts';
|
||||
export * from './errors';
|
||||
export * from './events';
|
||||
export * from './rpc';
|
||||
export * from './storage';
|
||||
export * from './submittable';
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { StorageKey, u64 } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { AnyFunction, AnyTuple, Callback, Codec, CodecArg, IStorageKey } from '@polkadot/types/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { ApiTypes, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
|
||||
|
||||
@@ -28,20 +28,21 @@ export interface StorageEntryPromiseOverloads {
|
||||
// This is the most generic typings we can have for a storage entry function
|
||||
type GenericStorageEntryFunction = (arg1?: CodecArg, arg2?: CodecArg) => Observable<Codec>
|
||||
|
||||
export type QueryableStorageEntry<ApiType extends ApiTypes> =
|
||||
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||
ApiType extends 'rxjs'
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
? AugmentedQuery<'rxjs', GenericStorageEntryFunction>
|
||||
? AugmentedQuery<'rxjs', GenericStorageEntryFunction, A>
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
: AugmentedQuery<'promise', GenericStorageEntryFunction> & StorageEntryPromiseOverloads;
|
||||
: AugmentedQuery<'promise', GenericStorageEntryFunction, A> & StorageEntryPromiseOverloads;
|
||||
|
||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction> {
|
||||
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> {
|
||||
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
|
||||
creator: StorageEntry;
|
||||
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>;
|
||||
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>;
|
||||
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey, T][]>;
|
||||
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
|
||||
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
|
||||
key: (...args: Parameters<F>) => string;
|
||||
keyPrefix: () => string;
|
||||
keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey[]>;
|
||||
@@ -55,7 +56,7 @@ export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunctio
|
||||
}
|
||||
|
||||
export interface QueryableModuleStorage<ApiType extends ApiTypes> {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
[index: string]: QueryableStorageEntry<ApiType, AnyTuple>;
|
||||
}
|
||||
|
||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||
@@ -79,10 +80,10 @@ export type QueryableStorageMulti<ApiType extends ApiTypes> =
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
|
||||
export interface AugmentedQueries<ApiType extends ApiTypes> { }
|
||||
|
||||
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction> extends StorageEntryBase<ApiType, F> {
|
||||
export interface StorageEntryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> extends StorageEntryBase<ApiType, F, A> {
|
||||
keyPrefix: (key1?: Parameters<F>[0]) => string;
|
||||
}
|
||||
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F>
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
|
||||
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F>
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryDoubleMap<ApiType, F, A>;
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
// Copyright 2017-2020 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyFunction, CallBase } from '@polkadot/types/types';
|
||||
import type { AnyFunction, AnyTuple, CallBase } from '@polkadot/types/types';
|
||||
import type { SubmittableExtrinsic } from '../submittable/types';
|
||||
import type { ApiTypes } from './base';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface,@typescript-eslint/no-unused-vars
|
||||
export interface AugmentedSubmittables<ApiType extends ApiTypes> { }
|
||||
|
||||
export type AugmentedSubmittable<T extends AnyFunction> = T & CallBase;
|
||||
export type AugmentedSubmittable<T extends AnyFunction, A extends AnyTuple = AnyTuple> = T & CallBase<A>;
|
||||
|
||||
export interface SubmittableExtrinsicFunction<ApiType extends ApiTypes> extends CallBase {
|
||||
export interface SubmittableExtrinsicFunction<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> extends CallBase<A> {
|
||||
(...params: any[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface SubmittableModuleExtrinsics<ApiType extends ApiTypes> {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
// only with is<Type> augmentation
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>; // | AugmentedIsSubmittable<ApiType, AnyTuple>;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Metadata, storageFromMeta } from '@polkadot/metadata';
|
||||
import { decorateStorage, Metadata } from '@polkadot/metadata';
|
||||
import { Storage } from '@polkadot/metadata/decorate/types';
|
||||
import metaStatic from '@polkadot/metadata/static';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
@@ -15,7 +15,7 @@ describe('extractStorageArgs', (): void => {
|
||||
beforeEach((): void => {
|
||||
const metadata = new Metadata(registry, metaStatic);
|
||||
|
||||
storage = storageFromMeta(registry, metadata);
|
||||
storage = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
});
|
||||
|
||||
it('validates no-arg plain', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -17,13 +17,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/types-known": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/util-crypto": "^5.1.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/types-known": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/util-crypto": "^5.2.2",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.1.1"
|
||||
"@polkadot/keyring": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped metadata as a V1 object
|
||||
* @description Returns the wrapped metadata as a V9 object
|
||||
*/
|
||||
public get asV9 (): MetadataV9 {
|
||||
this._assertVersion(9);
|
||||
@@ -81,16 +81,16 @@ export class MetadataVersioned extends Struct {
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V10 object
|
||||
* @description Returns the wrapped values as a V11 object
|
||||
*/
|
||||
public get asV11 (): MetadataV11 {
|
||||
return this._getVersion(11, toV11);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped values as a V10 object
|
||||
* @description Returns the wrapped values as a V12 object
|
||||
*/
|
||||
public get asV12 (): MetadataV11 {
|
||||
public get asV12 (): MetadataV12 {
|
||||
return this._getVersion(12, toV12);
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BlockNumber } from '@polkadot/types/interfaces';
|
||||
import type { Constants } from '../types';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
@@ -8,7 +9,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { Metadata } from '../../Metadata';
|
||||
import rpcMetadata from '../../static';
|
||||
import rpcMetadataV10 from '../../v10/static';
|
||||
import { constantsFromMeta } from './fromMetadata';
|
||||
import { decorateConstants } from '..';
|
||||
|
||||
function init (meta: string): [Constants, TypeRegistry] {
|
||||
const registry = new TypeRegistry();
|
||||
@@ -16,16 +17,16 @@ function init (meta: string): [Constants, TypeRegistry] {
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
return [constantsFromMeta(registry, metadata), registry];
|
||||
return [decorateConstants(registry, metadata.asLatest), registry];
|
||||
}
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
describe('decorateConstants', (): void => {
|
||||
it('should return constants with the correct type and value', (): void => {
|
||||
const [consts, registry] = init(rpcMetadata);
|
||||
|
||||
expect(consts.democracy.cooloffPeriod).toBeInstanceOf(registry.createClass('BlockNumber'));
|
||||
// 3 second blocks, 28 days
|
||||
expect(consts.democracy.cooloffPeriod.toNumber()).toEqual(28 * 24 * 60 * (60 / 3));
|
||||
expect((consts.democracy.cooloffPeriod as unknown as BlockNumber).toNumber()).toEqual(28 * 24 * 60 * (60 / 3));
|
||||
});
|
||||
|
||||
// removed from session
|
||||
+8
-11
@@ -1,30 +1,27 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ConstantCodec, Constants, ModuleConstants } from '../types';
|
||||
|
||||
import { hexToU8a, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
|
||||
/** @internal */
|
||||
export function constantsFromMeta (registry: Registry, metadata: Metadata): Constants {
|
||||
return metadata.asLatest.modules.reduce((result: Constants, moduleMetadata): Constants => {
|
||||
if (moduleMetadata.constants.isEmpty) {
|
||||
export function decorateConstants (registry: Registry, { modules }: MetadataLatest): Constants {
|
||||
return modules.reduce((result: Constants, { constants, name }): Constants => {
|
||||
if (constants.isEmpty) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const { name } = moduleMetadata;
|
||||
|
||||
// For access, we change the index names, i.e. Democracy.EnactmentPeriod -> democracy.enactmentPeriod
|
||||
result[stringCamelCase(name)] = moduleMetadata.constants.reduce((newModule: ModuleConstants, meta): ModuleConstants => {
|
||||
result[stringCamelCase(name)] = constants.reduce((newModule: ModuleConstants, meta): ModuleConstants => {
|
||||
// convert to the natural type as received
|
||||
const type = meta.type.toString();
|
||||
const codec = registry.createType(type as 'Raw', hexToU8a(meta.value.toHex())) as unknown as ConstantCodec;
|
||||
const codec = registry.createType(type as 'Raw', hexToU8a(meta.value.toHex())) as unknown;
|
||||
|
||||
codec.meta = meta;
|
||||
newModule[stringCamelCase(meta.name)] = codec;
|
||||
(codec as Record<string, unknown>).meta = meta;
|
||||
newModule[stringCamelCase(meta.name)] = codec as ConstantCodec;
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleConstants);
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { DispatchError, MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { Errors, ModuleErrors } from '../types';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
function isError (dispatchError: DispatchError, sectionIndex: number, errorIndex: number): boolean {
|
||||
if (!dispatchError.isModule) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const { error, index } = dispatchError.asModule;
|
||||
|
||||
return index.eq(sectionIndex) && error.eq(errorIndex);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function decorateErrors (_: Registry, { modules }: MetadataLatest, metaVersion: number): Errors {
|
||||
return modules.reduce((result: Errors, { errors, index, name }, _sectionIndex): Errors => {
|
||||
if (!errors.length) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const sectionIndex = metaVersion === 12 ? index.toNumber() : _sectionIndex;
|
||||
|
||||
result[stringCamelCase(name)] = errors.reduce((newModule: ModuleErrors, meta, errorIndex): ModuleErrors => {
|
||||
// we don't camelCase the error name
|
||||
newModule[meta.name.toString()] = {
|
||||
is: (dispatchError: DispatchError): boolean =>
|
||||
isError(dispatchError, sectionIndex, errorIndex),
|
||||
meta
|
||||
};
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleErrors);
|
||||
|
||||
return result;
|
||||
}, {} as Errors);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { AnyTuple, IEventRecord, Registry } from '@polkadot/types/types';
|
||||
import type { Events, ModuleEvents } from '../types';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
function isEvent <T extends AnyTuple> (eventRecord: IEventRecord<AnyTuple>, sectionIndex: number, eventIndex: number): eventRecord is IEventRecord<T> {
|
||||
return eventRecord.event.index[0] === sectionIndex && eventRecord.event.index[0] === eventIndex;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function decorateEvents (_: Registry, { modules }: MetadataLatest, metaVersion: number): Events {
|
||||
return modules.reduce((result: Events, { events, index, name }, _sectionIndex): Events => {
|
||||
if (!events.isSome) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const sectionIndex = metaVersion === 12 ? index.toNumber() : _sectionIndex;
|
||||
|
||||
result[stringCamelCase(name)] = events.unwrap().reduce((newModule: ModuleEvents, meta, eventIndex): ModuleEvents => {
|
||||
// we don't camelCase the event name
|
||||
newModule[meta.name.toString()] = {
|
||||
is: <T extends AnyTuple> (eventRecord: IEventRecord<AnyTuple>): eventRecord is IEventRecord<T> =>
|
||||
isEvent(eventRecord, sectionIndex, eventIndex),
|
||||
meta
|
||||
};
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleEvents);
|
||||
|
||||
return result;
|
||||
}, {} as Events);
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Call } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CallFunction, Registry, RegistryMetadataCall } from '@polkadot/types/types';
|
||||
import type { Call, FunctionMetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, AnyTuple, CallFunction, IMethod, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { assert, stringCamelCase } from '@polkadot/util';
|
||||
|
||||
function isTx <A extends AnyTuple> (tx: IMethod<AnyTuple>, callIndex: Uint8Array): tx is IMethod<A> {
|
||||
return tx.callIndex[0] === callIndex[0] && tx.callIndex[1] === callIndex[1];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export function createUnchecked (registry: Registry, section: string, callIndex: Uint8Array, callMetadata: RegistryMetadataCall): CallFunction {
|
||||
export function createUnchecked (registry: Registry, section: string, callIndex: Uint8Array, callMetadata: FunctionMetadataLatest): CallFunction {
|
||||
const expectedArgs = callMetadata.args;
|
||||
const funcName = stringCamelCase(callMetadata.name);
|
||||
|
||||
@@ -20,6 +24,9 @@ export function createUnchecked (registry: Registry, section: string, callIndex:
|
||||
}, callMetadata);
|
||||
};
|
||||
|
||||
extrinsicFn.is = <A extends AnyTuple> (tx: IMethod<AnyTuple>): tx is IMethod<A> =>
|
||||
isTx(tx, callIndex);
|
||||
|
||||
extrinsicFn.callIndex = callIndex;
|
||||
extrinsicFn.meta = callMetadata;
|
||||
extrinsicFn.method = funcName;
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import json from '../../static';
|
||||
import { extrinsicsFromMeta } from './fromMetadata';
|
||||
|
||||
// Use the pre-generated metadata
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, json);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const newExtrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
it('should throw if an incorrect number of args is supplied', (): void => {
|
||||
expect((): any => newExtrinsics.balances.setBalance()).toThrowError(/expects 3 arguments/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect((): any => newExtrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', 2, 3)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
expect(
|
||||
registry.createType('Extrinsic', newExtrinsics.timestamp.set([10101])).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
4,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
116
|
||||
])
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,34 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Calls, ModulesWithCalls, Registry, RegistryMetadata, RegistryMetadataModule } from '@polkadot/types/types';
|
||||
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { createUnchecked } from './createUnchecked';
|
||||
import extrinsics from '.';
|
||||
|
||||
/** @internal */
|
||||
export function extrinsicsFromMeta (registry: Registry, metadata: RegistryMetadata): ModulesWithCalls {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
return modules
|
||||
.filter(({ calls }) => calls.isSome)
|
||||
.reduce((result, { calls, index, name }: RegistryMetadataModule, _sectionIndex): ModulesWithCalls => {
|
||||
const sectionIndex = isIndexed
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const section = stringCamelCase(name);
|
||||
|
||||
result[section] = calls.unwrap().reduce((newModule: Calls, callMetadata, methodIndex): Calls => {
|
||||
const method = stringCamelCase(callMetadata.name);
|
||||
|
||||
newModule[method] = createUnchecked(registry, section, new Uint8Array([sectionIndex, methodIndex]), callMetadata);
|
||||
|
||||
return newModule;
|
||||
}, {});
|
||||
|
||||
return result;
|
||||
}, { ...extrinsics });
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import metadataStatic from '../../static';
|
||||
import { extrinsicsFromMeta } from './fromMetadata';
|
||||
import { decorateExtrinsics } from '..';
|
||||
|
||||
const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
const registry = new TypeRegistry();
|
||||
@@ -16,7 +16,7 @@ const metadata = new Metadata(registry, metadataStatic);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const extrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
const extrinsics = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
describe('extrinsics', (): void => {
|
||||
it('encodes an actual transfer (actual data)', (): void => {
|
||||
@@ -52,3 +52,37 @@ describe('extrinsics', (): void => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decorateExtrinsics', (): void => {
|
||||
it('should throw if an incorrect number of args is supplied', (): void => {
|
||||
expect(() => extrinsics.balances.setBalance()).toThrowError(/expects 3 arguments/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect(() => extrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', 2, 3)).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
expect(
|
||||
registry.createType('Extrinsic', extrinsics.timestamp.set([10101])).toU8a()
|
||||
).toEqual(
|
||||
new Uint8Array([
|
||||
// length (encoded)
|
||||
4 << 2,
|
||||
// version, no signature
|
||||
4,
|
||||
// index
|
||||
3, 0,
|
||||
// values, Compact<Moment>
|
||||
116
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
it('has working .is', (): void => {
|
||||
const tx = extrinsics.balances.setBalance('5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF', 2, 3);
|
||||
|
||||
expect(extrinsics.balances.setBalance.is(tx)).toBe(true);
|
||||
expect(extrinsics.balances.transfer.is(tx)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,30 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ModulesWithCalls } from '@polkadot/types/types';
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { Extrinsics, ModuleExtrinsics } from '../types';
|
||||
|
||||
const extrinsics: ModulesWithCalls = {};
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
export default extrinsics;
|
||||
import { createUnchecked } from './createUnchecked';
|
||||
|
||||
/** @internal */
|
||||
export function decorateExtrinsics (registry: Registry, { modules }: MetadataLatest, metaVersion: number): Extrinsics {
|
||||
return modules
|
||||
.filter(({ calls }) => calls.isSome)
|
||||
.reduce((result: Extrinsics, { calls, index, name }, _sectionIndex): Extrinsics => {
|
||||
const sectionIndex = metaVersion === 12
|
||||
? index.toNumber()
|
||||
: _sectionIndex;
|
||||
const section = stringCamelCase(name);
|
||||
|
||||
result[section] = calls.unwrap().reduce((newModule: ModuleExtrinsics, callMetadata, methodIndex): ModuleExtrinsics => {
|
||||
newModule[stringCamelCase(callMetadata.name)] = createUnchecked(registry, section, new Uint8Array([sectionIndex, methodIndex]), callMetadata);
|
||||
|
||||
return newModule;
|
||||
}, {});
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../Metadata';
|
||||
import json from '../static';
|
||||
import { constantsFromMeta, extrinsicsFromMeta, storageFromMeta } from './';
|
||||
import { decorateConstants, decorateExtrinsics, decorateStorage } from './';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, json);
|
||||
@@ -15,7 +15,7 @@ registry.setMetadata(metadata);
|
||||
|
||||
describe('Decorated', () => {
|
||||
it('should correctly get Alice\'s nonce storage key (u8a)', (): void => {
|
||||
const query = storageFromMeta(registry, metadata);
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
expect(
|
||||
u8aToHex(
|
||||
@@ -27,7 +27,7 @@ describe('Decorated', () => {
|
||||
});
|
||||
|
||||
it('should return properly-encoded transactions', (): void => {
|
||||
const tx = extrinsicsFromMeta(registry, metadata);
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
expect(
|
||||
registry.createType('Extrinsic', tx.timestamp.set([10101])).toU8a()
|
||||
@@ -46,7 +46,7 @@ describe('Decorated', () => {
|
||||
});
|
||||
|
||||
it('should return constants with the correct type and value', (): void => {
|
||||
const consts = constantsFromMeta(registry, metadata);
|
||||
const consts = decorateConstants(registry, metadata.asLatest);
|
||||
|
||||
expect(consts.democracy.cooloffPeriod).toBeInstanceOf(registry.createClass('BlockNumber'));
|
||||
expect(consts.democracy.cooloffPeriod.toHex()).toEqual('0x000c4e00');
|
||||
|
||||
@@ -7,21 +7,27 @@ import type { DecoratedMeta } from './types';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../Metadata';
|
||||
import { constantsFromMeta } from './consts/fromMetadata';
|
||||
import { extrinsicsFromMeta } from './extrinsics/fromMetadata';
|
||||
import { storageFromMeta } from './storage/fromMetadata';
|
||||
import { decorateConstants } from './constants';
|
||||
import { decorateErrors } from './errors';
|
||||
import { decorateEvents } from './events';
|
||||
import { decorateExtrinsics } from './extrinsics';
|
||||
import { decorateStorage } from './storage';
|
||||
|
||||
/**
|
||||
* Expands the metadata by decoration int consts, query and tx sections
|
||||
* Expands the metadata by decoration into consts, query and tx sections
|
||||
*/
|
||||
export function expandMetadata (registry: Registry, value: Metadata): DecoratedMeta {
|
||||
assert(value instanceof Metadata, 'You need to pass a valid Metadata instance to Decorated');
|
||||
export function expandMetadata (registry: Registry, metadata: Metadata): DecoratedMeta {
|
||||
assert(metadata instanceof Metadata, 'You need to pass a valid Metadata instance to Decorated');
|
||||
|
||||
const latest = metadata.asLatest;
|
||||
|
||||
return {
|
||||
consts: constantsFromMeta(registry, value),
|
||||
query: storageFromMeta(registry, value),
|
||||
tx: extrinsicsFromMeta(registry, value)
|
||||
consts: decorateConstants(registry, latest),
|
||||
errors: decorateErrors(registry, latest, metadata.version),
|
||||
events: decorateEvents(registry, latest, metadata.version),
|
||||
query: decorateStorage(registry, latest, metadata.version),
|
||||
tx: decorateExtrinsics(registry, latest, metadata.version)
|
||||
};
|
||||
}
|
||||
|
||||
export { constantsFromMeta, extrinsicsFromMeta, storageFromMeta };
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage };
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ModuleStorage, Storage } from '../types';
|
||||
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../Metadata';
|
||||
import { createFunction } from './createFunction';
|
||||
import { getStorage } from './storage';
|
||||
|
||||
/** @internal */
|
||||
export function storageFromMeta (registry: Registry, metadata: Metadata): Storage {
|
||||
return metadata.asLatest.modules.reduce((result: Storage, moduleMetadata): Storage => {
|
||||
if (moduleMetadata.storage.isNone) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const { name } = moduleMetadata;
|
||||
const section = stringCamelCase(name);
|
||||
const unwrapped = moduleMetadata.storage.unwrap();
|
||||
const prefix = unwrapped.prefix.toString();
|
||||
|
||||
// For access, we change the index names, i.e. System.Account -> system.account
|
||||
result[section] = unwrapped.items.reduce((newModule, meta): ModuleStorage => {
|
||||
const method = meta.name.toString();
|
||||
|
||||
newModule[stringLowerFirst(method)] = createFunction(registry, {
|
||||
meta,
|
||||
method,
|
||||
prefix,
|
||||
section
|
||||
}, { metaVersion: metadata.version });
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleStorage);
|
||||
|
||||
return result;
|
||||
}, { ...getStorage(registry, metadata.version) });
|
||||
}
|
||||
+2
-2
@@ -3,9 +3,9 @@
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
|
||||
import { getStorage } from './storage';
|
||||
import { getStorage } from './getStorage';
|
||||
|
||||
describe('storage', (): void => {
|
||||
describe('getSorage', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const storage = getStorage(registry, 8);
|
||||
|
||||
+5
-5
@@ -7,25 +7,25 @@ import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
import { Metadata } from '../../';
|
||||
import rpcMetadata from '../../static';
|
||||
import { storageFromMeta } from '../';
|
||||
import { decorateStorage } from '..';
|
||||
|
||||
const keyring = createTestPairs({ type: 'ed25519' });
|
||||
|
||||
describe('fromMetadata', (): void => {
|
||||
describe('decorateStorage', (): void => {
|
||||
describe('latest', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const query = storageFromMeta(registry, metadata);
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect((): any => query.balances.account()).toThrowError(/requires one argument/);
|
||||
expect(() => query.balances.account()).toThrowError(/requires one argument/);
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect((): any => query.timestamp.now()).not.toThrow();
|
||||
expect(() => query.timestamp.now()).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
@@ -1,6 +1,41 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { getStorage } from './storage';
|
||||
import type { MetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ModuleStorage, Storage } from '../types';
|
||||
|
||||
export default getStorage;
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
import { createFunction } from './createFunction';
|
||||
import { getStorage } from './getStorage';
|
||||
|
||||
/** @internal */
|
||||
export function decorateStorage (registry: Registry, { modules }: MetadataLatest, metaVersion: number): Storage {
|
||||
return modules.reduce((result: Storage, moduleMetadata): Storage => {
|
||||
if (moduleMetadata.storage.isNone) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const { name } = moduleMetadata;
|
||||
const section = stringCamelCase(name);
|
||||
const unwrapped = moduleMetadata.storage.unwrap();
|
||||
const prefix = unwrapped.prefix.toString();
|
||||
|
||||
// For access, we change the index names, i.e. System.Account -> system.account
|
||||
result[section] = unwrapped.items.reduce((newModule, meta): ModuleStorage => {
|
||||
const method = meta.name.toString();
|
||||
|
||||
newModule[stringLowerFirst(method)] = createFunction(registry, {
|
||||
meta,
|
||||
method,
|
||||
prefix,
|
||||
section
|
||||
}, { metaVersion });
|
||||
|
||||
return newModule;
|
||||
}, {} as ModuleStorage);
|
||||
|
||||
return result;
|
||||
}, { ...getStorage(registry, metaVersion) });
|
||||
}
|
||||
|
||||
@@ -1,27 +1,50 @@
|
||||
// Copyright 2017-2020 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AugmentedConst, QueryableConsts, QueryableModuleConsts } from '@polkadot/api/types/consts';
|
||||
import type { DispatchError, ErrorMetadataLatest, EventMetadataLatest, ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { Codec, ModulesWithCalls } from '@polkadot/types/types';
|
||||
import type { AnyTuple, CallFunction, Codec, IEventRecord } from '@polkadot/types/types';
|
||||
|
||||
export interface ModuleStorage {
|
||||
[key: string]: StorageEntry;
|
||||
export interface ConstantCodec extends Codec {
|
||||
readonly meta: ModuleConstantMetadataLatest;
|
||||
}
|
||||
|
||||
export type Constants = QueryableConsts<'rxjs'>;
|
||||
export interface IsError {
|
||||
readonly meta: ErrorMetadataLatest;
|
||||
|
||||
export type ConstantCodec = Codec & AugmentedConst<'rxjs'>;
|
||||
|
||||
export type ModuleConstants = QueryableModuleConsts;
|
||||
|
||||
export interface Storage {
|
||||
[key: string]: ModuleStorage;
|
||||
substrate: ModuleStorage;
|
||||
is: (dispatchError: DispatchError) => boolean;
|
||||
}
|
||||
|
||||
export interface IsEvent <T extends AnyTuple> {
|
||||
readonly meta: EventMetadataLatest;
|
||||
|
||||
is: (record: IEventRecord<AnyTuple>) => record is IEventRecord<T>;
|
||||
}
|
||||
|
||||
export type ModuleConstants = Record<string, ConstantCodec>;
|
||||
|
||||
export type ModuleErrors = Record<string, IsError>;
|
||||
|
||||
export type ModuleEvents = Record<string, IsEvent<AnyTuple>>;
|
||||
|
||||
export type ModuleExtrinsics = Record<string, CallFunction>;
|
||||
|
||||
export type ModuleStorage = Record<string, StorageEntry>
|
||||
|
||||
export type Constants = Record<string, ModuleConstants>;
|
||||
|
||||
export type Errors = Record<string, ModuleErrors>;
|
||||
|
||||
export type Events = Record<string, ModuleEvents>;
|
||||
|
||||
export type Extrinsics = Record<string, ModuleExtrinsics>
|
||||
|
||||
export type Storage = Record<string, ModuleStorage>;
|
||||
|
||||
export interface DecoratedMeta {
|
||||
consts: Constants;
|
||||
query: Storage;
|
||||
tx: ModulesWithCalls
|
||||
readonly consts: Constants;
|
||||
readonly errors: Errors;
|
||||
readonly events: Events;
|
||||
readonly query: Storage;
|
||||
readonly tx: Extrinsics
|
||||
}
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
import './detectPackage';
|
||||
|
||||
export { Metadata } from './Metadata';
|
||||
export { constantsFromMeta, expandMetadata, extrinsicsFromMeta, storageFromMeta } from './decorate';
|
||||
export { decorateConstants, decorateExtrinsics, decorateStorage, expandMetadata } from './decorate';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -14,13 +14,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/metadata": "3.1.1",
|
||||
"@polkadot/rpc-provider": "3.1.1",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/x-rxjs": "3.1.1"
|
||||
"@polkadot/metadata": "3.2.1",
|
||||
"@polkadot/rpc-provider": "3.2.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/x-rxjs": "3.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.1.1"
|
||||
"@polkadot/keyring": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,8 @@ export class RpcCore implements RpcInterface {
|
||||
|
||||
public readonly engine!: RpcInterface['engine'];
|
||||
|
||||
public readonly eth!: RpcInterface['eth'];
|
||||
|
||||
public readonly grandpa!: RpcInterface['grandpa'];
|
||||
|
||||
public readonly offchain!: RpcInterface['offchain'];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -14,17 +14,17 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/util-crypto": "^5.1.1",
|
||||
"@polkadot/x-fetch": "^5.1.1",
|
||||
"@polkadot/x-ws": "^5.1.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/util-crypto": "^5.2.2",
|
||||
"@polkadot/x-fetch": "^5.2.2",
|
||||
"@polkadot/x-ws": "^5.2.2",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.1.1",
|
||||
"@polkadot/metadata": "3.1.1",
|
||||
"@polkadot/keyring": "^5.2.2",
|
||||
"@polkadot/metadata": "3.2.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.5"
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import BN from 'bn.js';
|
||||
import EventEmitter from 'eventemitter3';
|
||||
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
import { Metadata, storageFromMeta } from '@polkadot/metadata';
|
||||
import { decorateStorage, Metadata } from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/static';
|
||||
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
||||
import rpcHeader from '@polkadot/types/json/Header.004.json';
|
||||
@@ -168,7 +168,7 @@ export class MockProvider implements ProviderInterface {
|
||||
|
||||
this.registry.setMetadata(metadata);
|
||||
|
||||
const query = storageFromMeta(this.registry, metadata);
|
||||
const query = decorateStorage(this.registry, metadata.asLatest, metadata.version);
|
||||
|
||||
// Do something every 1 seconds
|
||||
setInterval((): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -23,11 +23,11 @@
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/register": "^7.12.10",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/api": "3.1.1",
|
||||
"@polkadot/metadata": "3.1.1",
|
||||
"@polkadot/rpc-provider": "3.1.1",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/api": "3.2.1",
|
||||
"@polkadot/metadata": "3.2.1",
|
||||
"@polkadot/rpc-provider": "3.2.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"handlebars": "^4.7.6",
|
||||
"websocket": "^1.0.33",
|
||||
"yargs": "^16.2.0"
|
||||
|
||||
@@ -7,7 +7,7 @@ import yargs from 'yargs';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
import { WebSocket } from '@polkadot/x-ws';
|
||||
|
||||
import { generateDefaultConsts, generateDefaultQuery, generateDefaultRpc, generateDefaultTx } from './generate';
|
||||
import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultQuery, generateDefaultRpc, generateDefaultTx } from './generate';
|
||||
import { HEADER, writeFile } from './util';
|
||||
|
||||
function generate (metaHex: string, pkg: string | undefined, output: string, isStrict?: boolean): void {
|
||||
@@ -19,6 +19,8 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS
|
||||
: {};
|
||||
|
||||
generateDefaultConsts(path.join(process.cwd(), output, 'augment-api-consts.ts'), metaHex, extraTypes, isStrict);
|
||||
generateDefaultErrors(path.join(process.cwd(), output, 'augment-api-errors.ts'), metaHex, isStrict);
|
||||
generateDefaultEvents(path.join(process.cwd(), output, 'augment-api-events.ts'), metaHex, extraTypes, isStrict);
|
||||
generateDefaultQuery(path.join(process.cwd(), output, 'augment-api-query.ts'), metaHex, extraTypes, isStrict);
|
||||
generateDefaultRpc(path.join(process.cwd(), output, 'augment-api-rpc.ts'), extraTypes);
|
||||
generateDefaultTx(path.join(process.cwd(), output, 'augment-api-tx.ts'), metaHex, extraTypes, isStrict);
|
||||
@@ -28,7 +30,7 @@ function generate (metaHex: string, pkg: string | undefined, output: string, isS
|
||||
HEADER('chain'),
|
||||
...[
|
||||
'@polkadot/api/augment/rpc',
|
||||
...['consts', 'query', 'tx', 'rpc'].filter((key) => !!key).map((key) => `./augment-api-${key}`)
|
||||
...['consts', 'errors', 'events', 'query', 'tx', 'rpc'].filter((key) => !!key).map((key) => `./augment-api-${key}`)
|
||||
].map((path) => `import '${path}';\n`)
|
||||
].join('')
|
||||
);
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Handlebars from 'handlebars';
|
||||
|
||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
||||
import staticData from '@polkadot/metadata/static';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { compareName, createImports, readTemplate, writeFile } from '../util';
|
||||
|
||||
const template = readTemplate('errors');
|
||||
const generateForMetaTemplate = Handlebars.compile(template);
|
||||
|
||||
/** @internal */
|
||||
function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void {
|
||||
writeFile(dest, (): string => {
|
||||
const imports = createImports({});
|
||||
|
||||
const modules = meta.asLatest.modules
|
||||
.sort(compareName)
|
||||
.filter((mod) => mod.errors.length > 0)
|
||||
.map(({ errors, name }) => ({
|
||||
items: errors
|
||||
.sort(compareName)
|
||||
.map(({ documentation, name }) => ({
|
||||
docs: documentation,
|
||||
name: name.toString()
|
||||
})),
|
||||
name: stringCamelCase(name)
|
||||
}));
|
||||
|
||||
const types = [
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
];
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Call `generateForMeta()` with current static metadata
|
||||
/** @internal */
|
||||
export function generateDefaultErrors (dest = 'packages/api/src/augment/errors.ts', data = staticData, isStrict = false): void {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, data);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
return generateForMeta(metadata, dest, isStrict);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Handlebars from 'handlebars';
|
||||
|
||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
||||
import staticData from '@polkadot/metadata/static';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { compareName, createImports, formatType, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
||||
|
||||
const template = readTemplate('events');
|
||||
const generateForMetaTemplate = Handlebars.compile(template);
|
||||
|
||||
/** @internal */
|
||||
function generateForMeta (meta: Metadata, dest: string, extraTypes: Record<string, Record<string, { types: Record<string, any> }>>, isStrict: boolean): void {
|
||||
writeFile(dest, (): string => {
|
||||
const allTypes: Record<string, Record<string, { types: Record<string, unknown> }>> = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
||||
const imports = createImports(allTypes);
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
|
||||
const modules = meta.asLatest.modules
|
||||
.sort(compareName)
|
||||
.filter((mod) => mod.events.isSome)
|
||||
.map(({ events, name }) => ({
|
||||
items: events
|
||||
.unwrap()
|
||||
.sort(compareName)
|
||||
.map(({ args, documentation, name }) => {
|
||||
const types = args.map((type) => formatType(allDefs, type.toString(), imports));
|
||||
|
||||
setImports(allDefs, imports, types);
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
name: name.toString(),
|
||||
type: types.join(', ')
|
||||
};
|
||||
}),
|
||||
name: stringCamelCase(name)
|
||||
}));
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
];
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Call `generateForMeta()` with current static metadata
|
||||
/** @internal */
|
||||
export function generateDefaultEvents (dest = 'packages/api/src/augment/events.ts', data = staticData, extraTypes: Record<string, Record<string, { types: Record<string, any> }>> = {}, isStrict = false): void {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
registerDefinitions(registry, extraTypes);
|
||||
|
||||
const metadata = new Metadata(registry, data);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
return generateForMeta(metadata, dest, extraTypes, isStrict);
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { generateDefaultConsts } from './consts';
|
||||
export { generateDefaultErrors } from './errors';
|
||||
export { generateDefaultEvents } from './events';
|
||||
export { generateDefaultInterface } from './interfaceRegistry';
|
||||
export { generateDefaultQuery } from './query';
|
||||
export { generateDefaultRpc } from './rpc';
|
||||
|
||||
@@ -18,13 +18,13 @@ import { ModuleTypes } from '../util/imports';
|
||||
|
||||
// From a storage entry metadata, we return [args, returnType]
|
||||
/** @internal */
|
||||
function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [string, string] {
|
||||
function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [string, string, string] {
|
||||
const outputType = unwrapStorageType(storageEntry.type, storageEntry.modifier.isOptional);
|
||||
|
||||
if (storageEntry.type.isPlain) {
|
||||
setImports(allDefs, imports, [storageEntry.type.asPlain.toString()]);
|
||||
|
||||
return ['', formatType(allDefs, outputType, imports)];
|
||||
return ['', '', formatType(allDefs, outputType, imports)];
|
||||
} else if (storageEntry.type.isMap) {
|
||||
// Find similar types of the `key` type
|
||||
const similarTypes = getSimilarTypes(registry, allDefs, storageEntry.type.asMap.key.toString(), imports);
|
||||
@@ -35,6 +35,7 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
]);
|
||||
|
||||
return [
|
||||
formatType(allDefs, storageEntry.type.asMap.key.toString(), imports),
|
||||
`arg: ${similarTypes.join(' | ')}`,
|
||||
formatType(allDefs, outputType, imports)
|
||||
];
|
||||
@@ -53,6 +54,7 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
const key2Types = similarTypes2.join(' | ');
|
||||
|
||||
return [
|
||||
[formatType(allDefs, storageEntry.type.asDoubleMap.key1.toString(), imports), formatType(allDefs, storageEntry.type.asDoubleMap.key2.toString(), imports)].join(', '),
|
||||
`key1: ${key1Types}, key2: ${key2Types}`,
|
||||
formatType(allDefs, outputType, imports)
|
||||
];
|
||||
@@ -80,7 +82,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
const items = storage.unwrap().items
|
||||
.sort(compareName)
|
||||
.map((storageEntry) => {
|
||||
const [args, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
|
||||
const [args, params, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
|
||||
let entryType = 'AugmentedQuery';
|
||||
|
||||
if (storageEntry.type.isDoubleMap) {
|
||||
@@ -92,6 +94,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
docs: storageEntry.documentation,
|
||||
entryType,
|
||||
name: stringCamelCase(storageEntry.name),
|
||||
params,
|
||||
returnType
|
||||
};
|
||||
});
|
||||
|
||||
@@ -12,7 +12,7 @@ import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { stringCamelCase } from '@polkadot/util';
|
||||
|
||||
import { compareName, createImports, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
||||
import { compareName, createImports, formatType, getSimilarTypes, readTemplate, registerDefinitions, setImports, writeFile } from '../util';
|
||||
|
||||
const MAPPED_NAMES: Record<string, string> = {
|
||||
new: 'updated'
|
||||
@@ -57,6 +57,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
.join(', ');
|
||||
|
||||
return {
|
||||
args: args.map(({ type }) => formatType(allDefs, type.toString(), imports)).join(', '),
|
||||
docs: documentation,
|
||||
name: stringCamelCase(name),
|
||||
params
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Copyright 2017-2020 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { generateDefaultConsts, generateDefaultInterface, generateDefaultQuery, generateDefaultRpc, generateDefaultTsDef, generateDefaultTx } from './generate';
|
||||
import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultInterface, generateDefaultQuery, generateDefaultRpc, generateDefaultTsDef, generateDefaultTx } from './generate';
|
||||
|
||||
export function main (): void {
|
||||
generateDefaultInterface();
|
||||
|
||||
generateDefaultConsts();
|
||||
generateDefaultErrors();
|
||||
generateDefaultEvents();
|
||||
generateDefaultQuery();
|
||||
generateDefaultTx();
|
||||
generateDefaultRpc();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{{> header }}
|
||||
|
||||
{{{ imports }}}
|
||||
|
||||
declare module '@polkadot/api/types/errors' {
|
||||
export interface AugmentedErrors<ApiType> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#unless @root.isStrict}}
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
{{/unless}}
|
||||
{{~#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedError<ApiType>;
|
||||
{{/each}}
|
||||
};
|
||||
{{/each}}
|
||||
}
|
||||
|
||||
export interface DecoratedErrors<ApiType extends ApiTypes> extends AugmentedErrors<ApiType> {
|
||||
{{#unless isStrict}}
|
||||
[key: string]: ModuleErrors<ApiType>;
|
||||
{{/unless}}
|
||||
}
|
||||
}
|
||||
{{> footer }}
|
||||
@@ -0,0 +1,26 @@
|
||||
{{> header }}
|
||||
|
||||
{{{ imports }}}
|
||||
|
||||
declare module '@polkadot/api/types/events' {
|
||||
export interface AugmentedEvents<ApiType> {
|
||||
{{#each modules}}
|
||||
{{{name}}}: {
|
||||
{{#unless @root.isStrict}}
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
{{/unless}}
|
||||
{{~#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedEvent<ApiType, [{{{type}}}]>;
|
||||
{{/each}}
|
||||
};
|
||||
{{/each}}
|
||||
}
|
||||
|
||||
export interface DecoratedEvents<ApiType extends ApiTypes> extends AugmentedEvents<ApiType> {
|
||||
{{#unless isStrict}}
|
||||
[key: string]: ModuleEvents<ApiType>;
|
||||
{{/unless}}
|
||||
}
|
||||
}
|
||||
{{> footer }}
|
||||
@@ -11,7 +11,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
{{/unless}}
|
||||
{{~#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: {{{entryType}}}<ApiType, ({{{args}}}) => Observable<{{{returnType}}}>>{{#unless @root.isStrict}} & QueryableStorageEntry<ApiType>{{/unless}};
|
||||
{{{name}}}: {{{entryType}}}<ApiType, ({{{params}}}) => Observable<{{{returnType}}}>, [{{{args}}}]>{{#unless @root.isStrict}} & QueryableStorageEntry<ApiType, [{{{args}}}]>{{/unless}};
|
||||
{{/each}}
|
||||
};
|
||||
{{/each}}
|
||||
|
||||
@@ -11,7 +11,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
{{/unless}}
|
||||
{{~#each items}}
|
||||
{{> docs}}
|
||||
{{{name}}}: AugmentedSubmittable<({{{params}}}) => SubmittableExtrinsic<ApiType>>;
|
||||
{{{name}}}: AugmentedSubmittable<({{{params}}}) => SubmittableExtrinsic<ApiType>, [{{{args}}}]>;
|
||||
{{/each}}
|
||||
};
|
||||
{{/each}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -14,8 +14,8 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/types": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/types": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -14,6 +14,13 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
contracts: {
|
||||
StorageKey: 'ContractStorageKey'
|
||||
},
|
||||
ethereum: {
|
||||
Block: 'EthBlock',
|
||||
Header: 'EthHeader',
|
||||
Receipt: 'EthReceipt',
|
||||
Transaction: 'EthTransaction',
|
||||
TransactionStatus: 'EthTransactionStatus'
|
||||
},
|
||||
grandpa: {
|
||||
Equivocation: 'GrandpaEquivocation',
|
||||
EquivocationProof: 'GrandpaEquivocationProof'
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
// substrate
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'LookupSource',
|
||||
LookupSource: 'IndicesLookupSource',
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
@@ -14,18 +15,23 @@ const sharedTypes = {
|
||||
}
|
||||
};
|
||||
|
||||
const indicesTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'LookupSource',
|
||||
LookupSource: 'IndicesLookupSource'
|
||||
};
|
||||
|
||||
const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
// 1020 is first CC3
|
||||
minmax: [1019, 1031],
|
||||
types: {
|
||||
Address: 'LookupSource',
|
||||
...indicesTypes,
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchError: 'DispatchErrorTo198',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'IndicesLookupSource',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
@@ -40,12 +46,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [1032, 1042],
|
||||
types: {
|
||||
Address: 'LookupSource',
|
||||
...indicesTypes,
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'IndicesLookupSource',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
@@ -61,12 +66,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
// actual at 1045 (1043-1044 is dev)
|
||||
minmax: [1043, 1045],
|
||||
types: {
|
||||
Address: 'LookupSource',
|
||||
...indicesTypes,
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'IndicesLookupSource',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
RefCount: 'RefCountTo259',
|
||||
|
||||
@@ -10,6 +10,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [0, 259],
|
||||
types: {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'LookupSource',
|
||||
LookupSource: 'IndicesLookupSource'
|
||||
}
|
||||
@@ -17,6 +18,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [260, undefined],
|
||||
types: {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'MultiAddress',
|
||||
LookupSource: 'MultiAddress'
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId'
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
AccountInfo: 'AccountInfoWithRefCount',
|
||||
Address: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"module": "index.mjs",
|
||||
@@ -17,14 +17,14 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/metadata": "3.1.1",
|
||||
"@polkadot/util": "^5.1.1",
|
||||
"@polkadot/util-crypto": "^5.1.1",
|
||||
"@polkadot/x-rxjs": "3.1.1",
|
||||
"@polkadot/metadata": "3.2.1",
|
||||
"@polkadot/util": "^5.2.2",
|
||||
"@polkadot/util-crypto": "^5.2.2",
|
||||
"@polkadot/x-rxjs": "3.2.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^5.1.1"
|
||||
"@polkadot/keyring": "^5.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,24 +19,24 @@ import type { ContractConstructorSpec, ContractContractSpec, ContractCryptoHashe
|
||||
import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
|
||||
import type { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
|
||||
import type { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import type { EthereumAccountId, EthereumLookupSource } from '@polkadot/types/interfaces/ethereum';
|
||||
import type { EthAccount, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilterAddress, EthFilterTopic, EthFilterTopicEntry, EthFilterTopicInner, EthHeader, EthLog, EthReceipt, EthRichBlock, EthRichHeader, EthStorageProof, EthSubKind, EthSubParams, EthSubResult, EthSyncInfo, EthSyncStatus, EthTransaction, EthTransactionCondition, EthTransactionRequest, EthTransactionStatus, EthWork, EthereumAccountId, EthereumLookupSource, EthereumSignature } from '@polkadot/types/interfaces/eth';
|
||||
import type { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
|
||||
import type { AnySignature, EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
import type { AuthorityIndex, AuthorityList, AuthorityWeight, EncodedFinalityProofs, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaPrevote, JustificationNotification, KeyOwnerProof, NextAuthority, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement } from '@polkadot/types/interfaces/identity';
|
||||
import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV12, DoubleMapTypeV9, ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV9, MapTypeLatest, MapTypeV10, MapTypeV11, MapTypeV12, MapTypeV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV9, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV9, StorageMetadataLatest, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import type { AbridgedCandidateReceipt, AbstractFungible, AbstractNonFungible, AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Balances, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, ConcreteFungible, ConcreteNonFungible, CoreAssignment, CoreIndex, CoreOccupied, DepositAsset, DepositReserveAsset, DoubleVoteReport, DownwardMessage, ExchangeAsset, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InitiateReserveWithdraw, InitiateTeleport, Junction, LeasePeriod, LeasePeriodOf, LocalValidationData, MultiAsset, MultiLocation, NetworkId, NewBidder, Order, OriginKind, OutboundHrmpMessage, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, ParachainProposal, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueryHolding, QueuedParathread, RegisteredParachainInfo, RelayChainBlockNumber, RelayTo, RelayedFrom, Remark, ReserveAssetDeposit, Retriable, Scheduling, SessionInfo, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, TeleportAsset, Transact, TransientValidationData, UpwardMessage, ValidationCode, ValidationData, ValidationFunctionParams, ValidatorGroup, ValidatorSignature, ValidityAttestation, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, WinningData, WinningDataEntry, WithdrawAsset, Xcm, XcmError, XcmResult } from '@polkadot/types/interfaces/parachains';
|
||||
import type { AbridgedCandidateReceipt, AbstractFungible, AbstractNonFungible, AccountId32Junction, AccountIndex64Junction, AccountKey20Junction, AssetInstance, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Balances, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, ConcreteFungible, ConcreteNonFungible, CoreAssignment, CoreIndex, CoreOccupied, DepositAsset, DepositReserveAsset, DoubleVoteReport, DownwardMessage, ExchangeAsset, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InitiateReserveWithdraw, InitiateTeleport, Junction, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MultiAsset, MultiLocation, NetworkId, NewBidder, Order, OriginKind, OutboundHrmpMessage, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, ParachainProposal, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueryHolding, QueuedParathread, RegisteredParachainInfo, RelayChainBlockNumber, RelayTo, RelayedFrom, Remark, ReserveAssetDeposit, Retriable, Scheduling, SessionInfo, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, TeleportAsset, Transact, TransientValidationData, UpwardMessage, ValidationCode, ValidationData, ValidationFunctionParams, ValidatorGroup, ValidatorSignature, ValidityAttestation, VersionedMultiAsset, VersionedMultiLocation, VersionedXcm, WinningData, WinningDataEntry, WithdrawAsset, Xcm, XcmError, XcmResult } from '@polkadot/types/interfaces/parachains';
|
||||
import type { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { Approvals } from '@polkadot/types/interfaces/poll';
|
||||
import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H160, H256, H512, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, TransactionPriority, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H512, H64, Hash, Header, I32F32, Index, IndicesLookupSource, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, OpaqueCall, Origin, OriginCaller, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, TransactionPriority, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
|
||||
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
@@ -44,7 +44,7 @@ import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, Vouching
|
||||
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardDestinationTo257, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { AccountInfo, ApplyExtrinsicResult, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { AccountInfo, AccountInfoWithProviders, AccountInfoWithRefCount, ApplyExtrinsicResult, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
@@ -284,6 +284,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExtrinsicsWeight: ExtrinsicsWeight;
|
||||
'Option<ExtrinsicsWeight>': Option<ExtrinsicsWeight>;
|
||||
'Vec<ExtrinsicsWeight>': Vec<ExtrinsicsWeight>;
|
||||
H64: H64;
|
||||
'Option<H64>': Option<H64>;
|
||||
'Vec<H64>': Vec<H64>;
|
||||
H128: H128;
|
||||
'Option<H128>': Option<H128>;
|
||||
'Vec<H128>': Vec<H128>;
|
||||
H160: H160;
|
||||
'Option<H160>': Option<H160>;
|
||||
'Vec<H160>': Vec<H160>;
|
||||
@@ -293,6 +299,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
H512: H512;
|
||||
'Option<H512>': Option<H512>;
|
||||
'Vec<H512>': Vec<H512>;
|
||||
H1024: H1024;
|
||||
'Option<H1024>': Option<H1024>;
|
||||
'Vec<H1024>': Vec<H1024>;
|
||||
H2048: H2048;
|
||||
'Option<H2048>': Option<H2048>;
|
||||
'Vec<H2048>': Vec<H2048>;
|
||||
Hash: Hash;
|
||||
'Option<Hash>': Option<Hash>;
|
||||
'Vec<Hash>': Vec<Hash>;
|
||||
@@ -1173,6 +1185,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
AccountInfo: AccountInfo;
|
||||
'Option<AccountInfo>': Option<AccountInfo>;
|
||||
'Vec<AccountInfo>': Vec<AccountInfo>;
|
||||
AccountInfoWithRefCount: AccountInfoWithRefCount;
|
||||
'Option<AccountInfoWithRefCount>': Option<AccountInfoWithRefCount>;
|
||||
'Vec<AccountInfoWithRefCount>': Vec<AccountInfoWithRefCount>;
|
||||
AccountInfoWithProviders: AccountInfoWithProviders;
|
||||
'Option<AccountInfoWithProviders>': Option<AccountInfoWithProviders>;
|
||||
'Vec<AccountInfoWithProviders>': Vec<AccountInfoWithProviders>;
|
||||
ApplyExtrinsicResult: ApplyExtrinsicResult;
|
||||
'Option<ApplyExtrinsicResult>': Option<ApplyExtrinsicResult>;
|
||||
'Vec<ApplyExtrinsicResult>': Vec<ApplyExtrinsicResult>;
|
||||
@@ -1480,6 +1498,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
InboundHrmpMessage: InboundHrmpMessage;
|
||||
'Option<InboundHrmpMessage>': Option<InboundHrmpMessage>;
|
||||
'Vec<InboundHrmpMessage>': Vec<InboundHrmpMessage>;
|
||||
InboundHrmpMessages: InboundHrmpMessages;
|
||||
'Option<InboundHrmpMessages>': Option<InboundHrmpMessages>;
|
||||
'Vec<InboundHrmpMessages>': Vec<InboundHrmpMessages>;
|
||||
IncomingParachain: IncomingParachain;
|
||||
'Option<IncomingParachain>': Option<IncomingParachain>;
|
||||
'Vec<IncomingParachain>': Vec<IncomingParachain>;
|
||||
@@ -1500,6 +1521,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
LocalValidationData: LocalValidationData;
|
||||
'Option<LocalValidationData>': Option<LocalValidationData>;
|
||||
'Vec<LocalValidationData>': Vec<LocalValidationData>;
|
||||
MessageIngestionType: MessageIngestionType;
|
||||
'Option<MessageIngestionType>': Option<MessageIngestionType>;
|
||||
'Vec<MessageIngestionType>': Vec<MessageIngestionType>;
|
||||
NewBidder: NewBidder;
|
||||
'Option<NewBidder>': Option<NewBidder>;
|
||||
'Vec<NewBidder>': Vec<NewBidder>;
|
||||
@@ -1823,6 +1847,84 @@ declare module '@polkadot/types/types/registry' {
|
||||
EthereumLookupSource: EthereumLookupSource;
|
||||
'Option<EthereumLookupSource>': Option<EthereumLookupSource>;
|
||||
'Vec<EthereumLookupSource>': Vec<EthereumLookupSource>;
|
||||
EthereumSignature: EthereumSignature;
|
||||
'Option<EthereumSignature>': Option<EthereumSignature>;
|
||||
'Vec<EthereumSignature>': Vec<EthereumSignature>;
|
||||
EthAccount: EthAccount;
|
||||
'Option<EthAccount>': Option<EthAccount>;
|
||||
'Vec<EthAccount>': Vec<EthAccount>;
|
||||
EthBlock: EthBlock;
|
||||
'Option<EthBlock>': Option<EthBlock>;
|
||||
'Vec<EthBlock>': Vec<EthBlock>;
|
||||
EthBloom: EthBloom;
|
||||
'Option<EthBloom>': Option<EthBloom>;
|
||||
'Vec<EthBloom>': Vec<EthBloom>;
|
||||
EthCallRequest: EthCallRequest;
|
||||
'Option<EthCallRequest>': Option<EthCallRequest>;
|
||||
'Vec<EthCallRequest>': Vec<EthCallRequest>;
|
||||
EthFilter: EthFilter;
|
||||
'Option<EthFilter>': Option<EthFilter>;
|
||||
'Vec<EthFilter>': Vec<EthFilter>;
|
||||
EthFilterAddress: EthFilterAddress;
|
||||
'Option<EthFilterAddress>': Option<EthFilterAddress>;
|
||||
'Vec<EthFilterAddress>': Vec<EthFilterAddress>;
|
||||
EthFilterTopic: EthFilterTopic;
|
||||
'Option<EthFilterTopic>': Option<EthFilterTopic>;
|
||||
'Vec<EthFilterTopic>': Vec<EthFilterTopic>;
|
||||
EthFilterTopicEntry: EthFilterTopicEntry;
|
||||
'Option<EthFilterTopicEntry>': Option<EthFilterTopicEntry>;
|
||||
'Vec<EthFilterTopicEntry>': Vec<EthFilterTopicEntry>;
|
||||
EthFilterTopicInner: EthFilterTopicInner;
|
||||
'Option<EthFilterTopicInner>': Option<EthFilterTopicInner>;
|
||||
'Vec<EthFilterTopicInner>': Vec<EthFilterTopicInner>;
|
||||
EthHeader: EthHeader;
|
||||
'Option<EthHeader>': Option<EthHeader>;
|
||||
'Vec<EthHeader>': Vec<EthHeader>;
|
||||
EthLog: EthLog;
|
||||
'Option<EthLog>': Option<EthLog>;
|
||||
'Vec<EthLog>': Vec<EthLog>;
|
||||
EthReceipt: EthReceipt;
|
||||
'Option<EthReceipt>': Option<EthReceipt>;
|
||||
'Vec<EthReceipt>': Vec<EthReceipt>;
|
||||
EthRichBlock: EthRichBlock;
|
||||
'Option<EthRichBlock>': Option<EthRichBlock>;
|
||||
'Vec<EthRichBlock>': Vec<EthRichBlock>;
|
||||
EthRichHeader: EthRichHeader;
|
||||
'Option<EthRichHeader>': Option<EthRichHeader>;
|
||||
'Vec<EthRichHeader>': Vec<EthRichHeader>;
|
||||
EthStorageProof: EthStorageProof;
|
||||
'Option<EthStorageProof>': Option<EthStorageProof>;
|
||||
'Vec<EthStorageProof>': Vec<EthStorageProof>;
|
||||
EthSubKind: EthSubKind;
|
||||
'Option<EthSubKind>': Option<EthSubKind>;
|
||||
'Vec<EthSubKind>': Vec<EthSubKind>;
|
||||
EthSubParams: EthSubParams;
|
||||
'Option<EthSubParams>': Option<EthSubParams>;
|
||||
'Vec<EthSubParams>': Vec<EthSubParams>;
|
||||
EthSubResult: EthSubResult;
|
||||
'Option<EthSubResult>': Option<EthSubResult>;
|
||||
'Vec<EthSubResult>': Vec<EthSubResult>;
|
||||
EthSyncInfo: EthSyncInfo;
|
||||
'Option<EthSyncInfo>': Option<EthSyncInfo>;
|
||||
'Vec<EthSyncInfo>': Vec<EthSyncInfo>;
|
||||
EthSyncStatus: EthSyncStatus;
|
||||
'Option<EthSyncStatus>': Option<EthSyncStatus>;
|
||||
'Vec<EthSyncStatus>': Vec<EthSyncStatus>;
|
||||
EthTransaction: EthTransaction;
|
||||
'Option<EthTransaction>': Option<EthTransaction>;
|
||||
'Vec<EthTransaction>': Vec<EthTransaction>;
|
||||
EthTransactionCondition: EthTransactionCondition;
|
||||
'Option<EthTransactionCondition>': Option<EthTransactionCondition>;
|
||||
'Vec<EthTransactionCondition>': Vec<EthTransactionCondition>;
|
||||
EthTransactionRequest: EthTransactionRequest;
|
||||
'Option<EthTransactionRequest>': Option<EthTransactionRequest>;
|
||||
'Vec<EthTransactionRequest>': Vec<EthTransactionRequest>;
|
||||
EthTransactionStatus: EthTransactionStatus;
|
||||
'Option<EthTransactionStatus>': Option<EthTransactionStatus>;
|
||||
'Vec<EthTransactionStatus>': Vec<EthTransactionStatus>;
|
||||
EthWork: EthWork;
|
||||
'Option<EthWork>': Option<EthWork>;
|
||||
'Vec<EthWork>': Vec<EthWork>;
|
||||
DoubleMapTypeV9: DoubleMapTypeV9;
|
||||
'Option<DoubleMapTypeV9>': Option<DoubleMapTypeV9>;
|
||||
'Vec<DoubleMapTypeV9>': Vec<DoubleMapTypeV9>;
|
||||
@@ -2000,6 +2102,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
DoubleMapTypeLatest: DoubleMapTypeLatest;
|
||||
'Option<DoubleMapTypeLatest>': Option<DoubleMapTypeLatest>;
|
||||
'Vec<DoubleMapTypeLatest>': Vec<DoubleMapTypeLatest>;
|
||||
ErrorMetadataLatest: ErrorMetadataLatest;
|
||||
'Option<ErrorMetadataLatest>': Option<ErrorMetadataLatest>;
|
||||
'Vec<ErrorMetadataLatest>': Vec<ErrorMetadataLatest>;
|
||||
EventMetadataLatest: EventMetadataLatest;
|
||||
'Option<EventMetadataLatest>': Option<EventMetadataLatest>;
|
||||
'Vec<EventMetadataLatest>': Vec<EventMetadataLatest>;
|
||||
|
||||
@@ -11,6 +11,9 @@ import { assert, BN_ZERO, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber,
|
||||
|
||||
export const DEFAULT_UINT_BITS = 64;
|
||||
|
||||
// Maximum allowed integer for JS is 2^53 - 1, set limit at 52
|
||||
// In this case however, we always print any >32 as hex
|
||||
const MAX_NUMBER_BITS = 32;
|
||||
const MUL_P = new BN(1_00_00);
|
||||
|
||||
const FORMATTERS: [string, BN][] = [
|
||||
@@ -186,11 +189,10 @@ export abstract class AbstractInt extends BN implements Codec {
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): any {
|
||||
// FIXME this return type should by string | number, but BN's return type
|
||||
// is string.
|
||||
// Maximum allowed integer for JS is 2^53 - 1, set limit at 52
|
||||
return super.bitLength() > 52
|
||||
public toJSON (onlyHex = false): any {
|
||||
// FIXME this return type should by string | number, however BN returns string
|
||||
// Here if we want to have the actual used bits, it is super.bitLength()
|
||||
return onlyHex || (this.#bitLength > MAX_NUMBER_BITS)
|
||||
? this.toHex()
|
||||
: this.toNumber();
|
||||
}
|
||||
|
||||
@@ -73,8 +73,8 @@ describe('UInt', (): void => {
|
||||
});
|
||||
|
||||
it('converts to JSON representation based on size', (): void => {
|
||||
expect(new UInt(registry, '0x12345678', 64).toJSON()).toEqual(0x12345678);
|
||||
expect(new UInt(registry, '0x1234567890', 64).toJSON()).toEqual(0x1234567890);
|
||||
expect(new UInt(registry, '0x12345678', 32).toJSON()).toEqual(0x12345678);
|
||||
expect(new UInt(registry, '0x1234567890', 64).toJSON()).toEqual('0x0000001234567890');
|
||||
expect(new UInt(registry, '0x1234567890abcdef', 64).toJSON()).toEqual('0x1234567890abcdef');
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
import type { Codec, Constructor, Registry } from '../../types';
|
||||
|
||||
import { arrayFlatten } from '@polkadot/util';
|
||||
|
||||
/**
|
||||
* Given an u8a, and an array of Type constructors, decode the u8a against the
|
||||
* types, and return an array of decoded values.
|
||||
@@ -22,5 +24,5 @@ export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Construc
|
||||
const Type = types[0];
|
||||
const value = new Type(registry, u8a);
|
||||
|
||||
return [value].concat(decodeU8a(registry, u8a.subarray(value.encodedLength), types.slice(1)));
|
||||
return arrayFlatten([[value], decodeU8a(registry, u8a.subarray(value.encodedLength), types.slice(1))]);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('createType', (): void => {
|
||||
}]);
|
||||
|
||||
expect(struct.toJSON()).toEqual({
|
||||
balance: 1234,
|
||||
balance: '0x000000000000000000000000000004d2',
|
||||
index: 16
|
||||
});
|
||||
expect(struct.toRawType()).toEqual(raw);
|
||||
@@ -78,7 +78,7 @@ describe('createType', (): void => {
|
||||
it('allows creation of a Tuple', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '(Balance,u32)', [[1234, 5678]]).toJSON()
|
||||
).toEqual([1234, 5678]);
|
||||
).toEqual(['0x000000000000000000000000000004d2', 5678]);
|
||||
});
|
||||
|
||||
it('allows creation for a UInt<bitLength>', (): void => {
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
|
||||
import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types';
|
||||
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryMetadata, RegistryTypes } from '../types';
|
||||
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
|
||||
|
||||
// we are attempting to avoid circular refs, hence the Metadata path import
|
||||
import { extrinsicsFromMeta } from '@polkadot/metadata/decorate/extrinsics/fromMetadata';
|
||||
import { decorateExtrinsics } from '@polkadot/metadata/decorate/extrinsics';
|
||||
import { Metadata } from '@polkadot/metadata/Metadata';
|
||||
import { assert, assertReturn, BN_ZERO, formatBalance, isFunction, isString, isU8a, logger, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
@@ -26,7 +26,7 @@ import { getTypeDef } from './getTypeDef';
|
||||
const l = logger('registry');
|
||||
|
||||
// create error mapping from metadata
|
||||
function decorateErrors (_: Registry, metadata: RegistryMetadata, metadataErrors: Record<string, RegistryError>): void {
|
||||
function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<string, RegistryError>): void {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
@@ -51,7 +51,7 @@ function decorateErrors (_: Registry, metadata: RegistryMetadata, metadataErrors
|
||||
}
|
||||
|
||||
// create event classes from metadata
|
||||
function decorateEvents (registry: Registry, metadata: RegistryMetadata, metadataEvents: Record<string, Constructor<GenericEventData>>): void {
|
||||
function injectEvents (registry: Registry, metadata: Metadata, metadataEvents: Record<string, Constructor<GenericEventData>>): void {
|
||||
const modules = metadata.asLatest.modules;
|
||||
const isIndexed = modules.some(({ index }) => !index.eqn(255));
|
||||
|
||||
@@ -87,8 +87,8 @@ function decorateEvents (registry: Registry, metadata: RegistryMetadata, metadat
|
||||
}
|
||||
|
||||
// create extrinsic mapping from metadata
|
||||
function decorateExtrinsics (registry: Registry, metadata: RegistryMetadata, metadataCalls: Record<string, CallFunction>): void {
|
||||
const extrinsics = extrinsicsFromMeta(registry, metadata);
|
||||
function injectExtrinsics (registry: Registry, metadata: Metadata, metadataCalls: Record<string, CallFunction>): void {
|
||||
const extrinsics = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
// decorate the extrinsics
|
||||
Object.values(extrinsics).forEach((methods): void =>
|
||||
@@ -345,10 +345,10 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
|
||||
// sets the metadata
|
||||
public setMetadata (metadata: RegistryMetadata, signedExtensions?: string[]): void {
|
||||
decorateExtrinsics(this, metadata, this.#metadataCalls);
|
||||
decorateErrors(this, metadata, this.#metadataErrors);
|
||||
decorateEvents(this, metadata, this.#metadataEvents);
|
||||
public setMetadata (metadata: Metadata, signedExtensions?: string[]): void {
|
||||
injectExtrinsics(this, metadata, this.#metadataCalls);
|
||||
injectErrors(this, metadata, this.#metadataErrors);
|
||||
injectEvents(this, metadata, this.#metadataEvents);
|
||||
|
||||
// setup the available extensions
|
||||
this.setSignedExtensions(
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { EcdsaSignature, Ed25519Signature, ExtrinsicUnknown, ExtrinsicV4, Sr25519Signature } from '../interfaces/extrinsics';
|
||||
import type { FunctionMetadataLatest } from '../interfaces/metadata/types';
|
||||
import type { Address, Balance, Call, Index } from '../interfaces/runtime';
|
||||
import type { AnyJson, AnyU8a, ArgsDef, Codec, ExtrinsicPayloadValue, IExtrinsic, IKeyringPair, InterfaceTypes, Registry, SignatureOptions } from '../types';
|
||||
import type { AnyJson, AnyTuple, AnyU8a, ArgsDef, ExtrinsicPayloadValue, IExtrinsic, IKeyringPair, IMethod, InterfaceTypes, Registry, SignatureOptions } from '../types';
|
||||
import type { GenericExtrinsicEra } from './ExtrinsicEra';
|
||||
import type { ExtrinsicValueV4 } from './v4/Extrinsic';
|
||||
|
||||
@@ -34,11 +34,11 @@ const VERSIONS: (keyof InterfaceTypes)[] = [
|
||||
|
||||
export { EXTRINSIC_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic';
|
||||
|
||||
abstract class ExtrinsicBase extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
abstract class ExtrinsicBase<A extends AnyTuple> extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
/**
|
||||
* @description The arguments passed to for the call, exposes args so it is compatible with [[Call]]
|
||||
*/
|
||||
public get args (): Codec[] {
|
||||
public get args (): A {
|
||||
return this.method.args;
|
||||
}
|
||||
|
||||
@@ -77,13 +77,6 @@ abstract class ExtrinsicBase extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` is method has `Origin` argument (compatibility with [Call])
|
||||
*/
|
||||
public get hasOrigin (): boolean {
|
||||
return this.method.hasOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` id the extrinsic is signed
|
||||
*/
|
||||
@@ -108,8 +101,8 @@ abstract class ExtrinsicBase extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
/**
|
||||
* @description The [[Call]] this extrinsic wraps
|
||||
*/
|
||||
public get method (): Call {
|
||||
return (this._raw as ExtrinsicVx).method;
|
||||
public get method (): IMethod<A> {
|
||||
return (this._raw as ExtrinsicVx).method as unknown as IMethod<A>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,6 +146,13 @@ abstract class ExtrinsicBase extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
public get version (): number {
|
||||
return this.type | (this.isSigned ? BIT_SIGNED : BIT_UNSIGNED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the source matches this in type
|
||||
*/
|
||||
public is (other: IMethod<AnyTuple>): other is IMethod<A> {
|
||||
return this.method.is(other);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +167,7 @@ abstract class ExtrinsicBase extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
* - signed, to create a transaction
|
||||
* - left as is, to create an inherent
|
||||
*/
|
||||
export class GenericExtrinsic extends ExtrinsicBase implements IExtrinsic {
|
||||
export class GenericExtrinsic<A extends AnyTuple = AnyTuple> extends ExtrinsicBase<A> implements IExtrinsic<A> {
|
||||
constructor (registry: Registry, value: GenericExtrinsic | ExtrinsicValue | AnyU8a | Call | undefined, { version }: CreateOptions = {}) {
|
||||
super(registry, GenericExtrinsic._decodeExtrinsic(registry, value, version));
|
||||
}
|
||||
@@ -216,7 +216,7 @@ export class GenericExtrinsic extends ExtrinsicBase implements IExtrinsic {
|
||||
/**
|
||||
* @description Injects an already-generated signature into the extrinsic
|
||||
*/
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): GenericExtrinsic {
|
||||
public addSignature (signer: Address | Uint8Array | string, signature: Uint8Array | string, payload: ExtrinsicPayloadValue | Uint8Array | string): GenericExtrinsic<A> {
|
||||
(this._raw as ExtrinsicVx).addSignature(signer, signature, payload);
|
||||
|
||||
return this;
|
||||
@@ -225,7 +225,7 @@ export class GenericExtrinsic extends ExtrinsicBase implements IExtrinsic {
|
||||
/**
|
||||
* @description Sign the extrinsic with a specific keypair
|
||||
*/
|
||||
public sign (account: IKeyringPair, options: SignatureOptions): GenericExtrinsic {
|
||||
public sign (account: IKeyringPair, options: SignatureOptions): GenericExtrinsic<A> {
|
||||
(this._raw as ExtrinsicVx).sign(account, options);
|
||||
|
||||
return this;
|
||||
@@ -234,7 +234,7 @@ export class GenericExtrinsic extends ExtrinsicBase implements IExtrinsic {
|
||||
/**
|
||||
* @describe Adds a fake signature to the extrinsic
|
||||
*/
|
||||
public signFake (signer: Address | Uint8Array | string, options: SignatureOptions): GenericExtrinsic {
|
||||
public signFake (signer: Address | Uint8Array | string, options: SignatureOptions): GenericExtrinsic<A> {
|
||||
(this._raw as ExtrinsicVx).signFake(signer, options);
|
||||
|
||||
return this;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { extrinsicsFromMeta, Metadata } from '@polkadot/metadata';
|
||||
import { decorateExtrinsics, Metadata } from '@polkadot/metadata';
|
||||
import rpcMetadata from '@polkadot/metadata/static';
|
||||
|
||||
import { TypeRegistry } from '../../create';
|
||||
@@ -16,7 +16,7 @@ const keyring = createTestPairs({ type: 'ed25519' }, false);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const tx = extrinsicsFromMeta(registry, metadata);
|
||||
const tx = decorateExtrinsics(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
describe('ExtrinsicV4', (): void => {
|
||||
it.only('constructs a sane Uint8Array (default)', (): void => {
|
||||
|
||||
@@ -10,8 +10,6 @@ import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
import { u32 } from '../primitive/U32';
|
||||
|
||||
export const ENUMSET_SIZE = new BN(64);
|
||||
|
||||
const PREFIX_1BYTE = 0xef;
|
||||
const PREFIX_2BYTE = 0xfc;
|
||||
const PREFIX_4BYTE = 0xfd;
|
||||
|
||||
@@ -27,29 +27,4 @@ describe('Call', (): void => {
|
||||
new Call(registry, '0x0601').toU8a()
|
||||
).toEqual(new Uint8Array([6, 1, 0, 0, 0])); // balances.setBalance
|
||||
});
|
||||
|
||||
describe('hasOrigin', (): void => {
|
||||
const test = {
|
||||
args: [],
|
||||
callIndex: [2, 2] // timestamp
|
||||
};
|
||||
|
||||
it('is false with no arguments', (): void => {
|
||||
expect(
|
||||
new Call(registry, test, { args: [] } as any).hasOrigin
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('is false with first argument as non-Origin', (): void => {
|
||||
expect(
|
||||
new Call(registry, test, { args: [{ name: 'a', type: 'u32' }] } as any).hasOrigin
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('is false with first argument as non-Origin', (): void => {
|
||||
expect(
|
||||
new Call(registry, test, { args: [{ name: 'a', type: 'Origin' }] } as any).hasOrigin
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { FunctionArgumentMetadataLatest, FunctionMetadataLatest } from '../interfaces/metadata';
|
||||
import type { AnyJson, AnyU8a, ArgsDef, CallFunction, Codec, IMethod, Registry } from '../types';
|
||||
import type { AnyJson, AnyTuple, AnyU8a, ArgsDef, CallFunction, IMethod, Registry } from '../types';
|
||||
|
||||
import { isHex, isObject, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
@@ -117,7 +117,7 @@ export class GenericCallIndex extends U8aFixed {
|
||||
* @description
|
||||
* Extrinsic function descriptor
|
||||
*/
|
||||
export class GenericCall extends Struct implements IMethod {
|
||||
export class GenericCall<A extends AnyTuple = AnyTuple> extends Struct implements IMethod<A> {
|
||||
protected _meta: FunctionMetadataLatest;
|
||||
|
||||
constructor (registry: Registry, value: unknown, meta?: FunctionMetadataLatest) {
|
||||
@@ -159,9 +159,9 @@ export class GenericCall extends Struct implements IMethod {
|
||||
/**
|
||||
* @description The arguments for the function call
|
||||
*/
|
||||
public get args (): Codec[] {
|
||||
public get args (): A {
|
||||
// FIXME This should return a Struct instead of an Array
|
||||
return [...(this.get('args') as Struct).values()];
|
||||
return [...(this.get('args') as Struct).values()] as A;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,15 +185,6 @@ export class GenericCall extends Struct implements IMethod {
|
||||
return (this.get('args') as Struct).toU8a();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description `true` if the `Origin` type is on the method (extrinsic method)
|
||||
*/
|
||||
public get hasOrigin (): boolean {
|
||||
const firstArg = this.meta.args[0];
|
||||
|
||||
return !!firstArg && firstArg.type.toString() === 'Origin';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The [[FunctionMetadata]]
|
||||
*/
|
||||
@@ -229,6 +220,13 @@ export class GenericCall extends Struct implements IMethod {
|
||||
return this.sectionName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the source matches this in type
|
||||
*/
|
||||
public is (other: IMethod<AnyTuple>): other is IMethod<A> {
|
||||
return other.callIndex[0] === this.callIndex[0] && other.callIndex[1] === this.callIndex[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { TypeDef } from '../create/types';
|
||||
import type { EventMetadataLatest } from '../interfaces/metadata';
|
||||
import type { EventId } from '../interfaces/system';
|
||||
import type { AnyJson, Constructor, Registry, RegistryMetadataEvent } from '../types';
|
||||
import type { AnyJson, Codec, Constructor, IEvent, IEventData, Registry } from '../types';
|
||||
|
||||
import { Struct } from '../codec/Struct';
|
||||
import { Tuple } from '../codec/Tuple';
|
||||
@@ -15,7 +15,7 @@ import { Null } from '../primitive/Null';
|
||||
* @description
|
||||
* Wrapper for the actual data that forms part of an [[Event]]
|
||||
*/
|
||||
export class GenericEventData extends Tuple {
|
||||
export class GenericEventData extends Tuple implements IEventData {
|
||||
readonly #meta: EventMetadataLatest;
|
||||
|
||||
readonly #method: string;
|
||||
@@ -24,10 +24,10 @@ export class GenericEventData extends Tuple {
|
||||
|
||||
readonly #typeDef: TypeDef[];
|
||||
|
||||
constructor (registry: Registry, value: Uint8Array, Types: Constructor[] = [], typeDef: TypeDef[] = [], meta: RegistryMetadataEvent, section = '<unknown>', method = '<unknown>') {
|
||||
constructor (registry: Registry, value: Uint8Array, Types: Constructor[] = [], typeDef: TypeDef[] = [], meta: EventMetadataLatest, section = '<unknown>', method = '<unknown>') {
|
||||
super(registry, Types, value);
|
||||
|
||||
this.#meta = meta as EventMetadataLatest;
|
||||
this.#meta = meta;
|
||||
this.#method = method;
|
||||
this.#section = section;
|
||||
this.#typeDef = typeDef;
|
||||
@@ -68,7 +68,7 @@ export class GenericEventData extends Tuple {
|
||||
* A representation of a system event. These are generated via the [[Metadata]] interfaces and
|
||||
* specific to a specific Substrate runtime
|
||||
*/
|
||||
export class GenericEvent extends Struct {
|
||||
export class GenericEvent extends Struct implements IEvent<Codec[]> {
|
||||
// Currently we _only_ decode from Uint8Array, since we expect it to
|
||||
// be used via EventRecord
|
||||
constructor (registry: Registry, _value?: Uint8Array) {
|
||||
|
||||
@@ -49,7 +49,7 @@ export { default as contractsAbi } from './contractsAbi/definitions';
|
||||
export { default as scaleInfo } from './scaleInfo/definitions';
|
||||
|
||||
// other useful types
|
||||
export { default as ethereum } from './ethereum/definitions';
|
||||
export { default as eth } from './eth/definitions';
|
||||
|
||||
// pull in metadata & rpc last, assuming that is uses info from above
|
||||
export { default as metadata } from './metadata/definitions';
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
// As per frontier
|
||||
|
||||
import type { DefinitionsTypes } from '../../types';
|
||||
|
||||
import { rpc } from './rpc';
|
||||
|
||||
const types: DefinitionsTypes = {
|
||||
EthereumAccountId: 'GenericEthereumAccountId',
|
||||
EthereumLookupSource: 'GenericEthereumLookupSource',
|
||||
EthereumSignature: '[u8; 65]',
|
||||
EthAccount: {
|
||||
address: 'H160',
|
||||
balance: 'U256',
|
||||
nonce: 'U256',
|
||||
codeHash: 'H256',
|
||||
storageHash: 'H256',
|
||||
accountProof: 'Vec<Bytes>',
|
||||
storageProof: 'Vec<EthStorageProof>'
|
||||
},
|
||||
EthBlock: {
|
||||
_alias: {
|
||||
blockHash: 'hash',
|
||||
blockSize: 'size'
|
||||
},
|
||||
blockHash: 'Option<H256>',
|
||||
parentHash: 'H256',
|
||||
sha3Uncles: 'H256',
|
||||
author: 'H160',
|
||||
miner: 'H160',
|
||||
stateRoot: 'H256',
|
||||
transactionsRoot: 'H256',
|
||||
receiptsRoot: 'H256',
|
||||
number: 'Option<U256>',
|
||||
gasUsed: 'U256',
|
||||
gasLimit: 'U256',
|
||||
extraData: 'Bytes',
|
||||
logsBloom: 'H2048',
|
||||
timestamp: 'U256',
|
||||
difficulty: 'U256',
|
||||
totalDifficulty: 'Option<U256>',
|
||||
sealFields: 'Vec<Bytes>',
|
||||
uncles: 'Vec<H256>',
|
||||
transactions: 'Vec<EthTransaction>',
|
||||
blockSize: 'Option<U256>'
|
||||
},
|
||||
EthBloom: 'H2048',
|
||||
EthCallRequest: {
|
||||
from: 'Option<H160>',
|
||||
to: 'Option<H160>',
|
||||
gasPrice: 'Option<U256>',
|
||||
gas: 'Option<U256>',
|
||||
value: 'Option<U256>',
|
||||
data: 'Option<Bytes>',
|
||||
nonce: 'Option<U256>'
|
||||
},
|
||||
EthFilter: {
|
||||
fromBlock: 'Option<BlockNumber>',
|
||||
toBlock: 'Option<BlockNumber>',
|
||||
blockHash: 'Option<H256>',
|
||||
address: 'Option<EthFilterAddress>',
|
||||
topics: 'Option<EthFilterTopic>'
|
||||
},
|
||||
EthFilterAddress: {
|
||||
_enum: {
|
||||
Single: 'H160',
|
||||
Multiple: 'Vec<H160>',
|
||||
Null: 'Null'
|
||||
}
|
||||
},
|
||||
EthFilterTopic: {
|
||||
_enum: {
|
||||
Single: 'EthFilterTopicInner',
|
||||
Multiple: 'Vec<EthFilterTopicInner>',
|
||||
Null: 'Null'
|
||||
}
|
||||
},
|
||||
EthFilterTopicEntry: 'Option<H256>',
|
||||
EthFilterTopicInner: {
|
||||
_enum: {
|
||||
Single: 'EthFilterTopicEntry',
|
||||
Multiple: 'Vec<EthFilterTopicEntry>',
|
||||
Null: 'Null'
|
||||
}
|
||||
},
|
||||
EthHeader: {
|
||||
_alias: {
|
||||
blockHash: 'hash',
|
||||
blockSize: 'size'
|
||||
},
|
||||
blockHash: 'Option<H256>',
|
||||
parentHash: 'H256',
|
||||
sha3Uncles: 'H256',
|
||||
author: 'H160',
|
||||
miner: 'H160',
|
||||
stateRoot: 'H256',
|
||||
transactionsRoot: 'H256',
|
||||
receiptsRoot: 'H256',
|
||||
number: 'Option<U256>',
|
||||
gasUsed: 'U256',
|
||||
gasLimit: 'U256',
|
||||
extraData: 'Bytes',
|
||||
logsBloom: 'H2048',
|
||||
timestamp: 'U256',
|
||||
difficulty: 'U256',
|
||||
sealFields: 'Vec<Bytes>',
|
||||
blockSize: 'Option<U256>'
|
||||
},
|
||||
EthLog: {
|
||||
address: 'H160',
|
||||
topics: 'Vec<H256>',
|
||||
data: 'Bytes',
|
||||
blockHash: 'Option<H256>',
|
||||
blockNumber: 'Option<U256>',
|
||||
transactionHash: 'Option<H256>',
|
||||
transactionIndex: 'Option<U256>',
|
||||
logIndex: 'Option<U256>',
|
||||
transactionLogIndex: 'Option<U256>',
|
||||
removed: 'bool'
|
||||
},
|
||||
EthReceipt: {
|
||||
transactionHash: 'Option<H256>',
|
||||
transactionIndex: 'Option<U256>',
|
||||
blockHash: 'Option<H256>',
|
||||
from: 'Option<H160>',
|
||||
to: 'Option<H160>',
|
||||
blockNumber: 'Option<U256>',
|
||||
cumulativeGasUsed: 'U256',
|
||||
gasUsed: 'Option<U256>',
|
||||
contractAddress: 'Option<H160>',
|
||||
logs: 'Vec<EthLog>',
|
||||
root: 'Option<H256>',
|
||||
logsBloom: 'H2048',
|
||||
statusCode: 'Option<U64>'
|
||||
},
|
||||
EthRichBlock: 'EthBlock',
|
||||
EthRichHeader: 'EthHeader',
|
||||
EthStorageProof: {
|
||||
key: 'U256',
|
||||
value: 'U256',
|
||||
proof: 'Vec<Bytes>'
|
||||
},
|
||||
EthSubKind: {
|
||||
_enum: ['newHeads', 'logs', 'newPendingTransactions', 'syncing']
|
||||
},
|
||||
EthSubParams: {
|
||||
_enum: {
|
||||
None: 'Null',
|
||||
Logs: 'EthFilter'
|
||||
}
|
||||
},
|
||||
EthSubResult: {
|
||||
_enum: {
|
||||
Header: 'EthRichHeader',
|
||||
Log: 'EthLog',
|
||||
TransactionHash: 'H256',
|
||||
SyncState: 'EthSyncStatus'
|
||||
}
|
||||
},
|
||||
EthSyncInfo: {
|
||||
startingBlock: 'U256',
|
||||
currentBlock: 'U256',
|
||||
highestBlock: 'U256',
|
||||
warpChunksAmount: 'Option<U256>',
|
||||
warpChunksProcessed: 'Option<U256>'
|
||||
},
|
||||
EthSyncStatus: {
|
||||
_enum: {
|
||||
Info: 'EthSyncInfo',
|
||||
None: 'Null'
|
||||
}
|
||||
},
|
||||
EthTransaction: {
|
||||
blockHash: 'Option<H256>',
|
||||
blockNumber: 'Option<U256>',
|
||||
chainId: 'Option<u64>',
|
||||
condition: 'Option<EthTransactionCondition>',
|
||||
creates: 'Option<H160>',
|
||||
from: 'H160',
|
||||
gas: 'U256',
|
||||
gasPrice: 'U256',
|
||||
hash: 'H256',
|
||||
input: 'Bytes',
|
||||
nonce: 'U256',
|
||||
publicKey: 'Option<H512>',
|
||||
r: 'U256',
|
||||
raw: 'Bytes',
|
||||
s: 'U256',
|
||||
standardV: 'U256',
|
||||
to: 'Option<H160>',
|
||||
transactionIndex: 'Option<U256>',
|
||||
v: 'U256',
|
||||
value: 'U256'
|
||||
},
|
||||
EthTransactionCondition: {
|
||||
_enum: {
|
||||
block: 'u64',
|
||||
time: 'u64'
|
||||
}
|
||||
},
|
||||
EthTransactionRequest: {
|
||||
from: 'Option<H160>',
|
||||
to: 'Option<H160>',
|
||||
gasPrice: 'Option<U256>',
|
||||
gas: 'Option<U256>',
|
||||
value: 'Option<U256>',
|
||||
data: 'Option<Bytes>',
|
||||
nonce: 'Option<U256>'
|
||||
},
|
||||
EthTransactionStatus: {
|
||||
transactionHash: 'H256',
|
||||
transactionIndex: 'u32',
|
||||
from: 'H160',
|
||||
to: 'Option<H160>',
|
||||
contractAddress: 'Option<H160>',
|
||||
logs: 'Vec<EthLog>',
|
||||
logsBloom: 'EthBloom'
|
||||
},
|
||||
EthWork: {
|
||||
powHash: 'H256',
|
||||
seedHash: 'H256',
|
||||
target: 'H256',
|
||||
number: 'Option<u64>'
|
||||
}
|
||||
};
|
||||
|
||||
export default { rpc, types };
|
||||
@@ -0,0 +1,281 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// As per frontier
|
||||
|
||||
import type { DefinitionsRpc } from '../../types';
|
||||
|
||||
// We use aliasSection here to override since these are in another namespace
|
||||
const netRpc: DefinitionsRpc = {
|
||||
listening: {
|
||||
aliasSection: 'net',
|
||||
description: 'Returns true if client is actively listening for network connections. Otherwise false.',
|
||||
params: [],
|
||||
type: 'bool'
|
||||
},
|
||||
peerCount: {
|
||||
aliasSection: 'net',
|
||||
description: 'Returns number of peers connected to node.',
|
||||
params: [],
|
||||
type: 'String'
|
||||
},
|
||||
version: {
|
||||
aliasSection: 'net',
|
||||
description: 'Returns protocol version.',
|
||||
params: [],
|
||||
type: 'String'
|
||||
}
|
||||
};
|
||||
|
||||
export const rpc: DefinitionsRpc = {
|
||||
...netRpc,
|
||||
accounts: {
|
||||
description: 'Returns accounts list.',
|
||||
params: [],
|
||||
type: 'Vec<H160>'
|
||||
},
|
||||
blockNumber: {
|
||||
description: 'Returns balance of the given account.',
|
||||
params: [],
|
||||
type: 'U256'
|
||||
},
|
||||
call: {
|
||||
description: 'Call contract, returning the output data.',
|
||||
params: [
|
||||
{ name: 'request', type: 'EthCallRequest' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'Bytes'
|
||||
},
|
||||
chainId: {
|
||||
description: 'Returns the chain ID used for transaction signing at the current best block. None is returned if not available.',
|
||||
params: [],
|
||||
type: 'U64'
|
||||
},
|
||||
coinbase: {
|
||||
description: 'Returns block author.',
|
||||
params: [],
|
||||
type: 'H160'
|
||||
},
|
||||
estimateGas: {
|
||||
description: 'Estimate gas needed for execution of given contract.',
|
||||
params: [
|
||||
{ name: 'request', type: 'EthCallRequest' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
gasPrice: {
|
||||
description: 'Returns current gas price.',
|
||||
params: [],
|
||||
type: 'U256'
|
||||
},
|
||||
getBalance: {
|
||||
description: 'Returns balance of the given account.',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getBlockByHash: {
|
||||
description: 'Returns block with given hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ name: 'full', type: 'bool' }
|
||||
],
|
||||
type: 'Option<EthRichBlock>'
|
||||
},
|
||||
getBlockByNumber: {
|
||||
description: 'Returns block with given number.',
|
||||
params: [
|
||||
{ name: 'block', type: 'BlockNumber' },
|
||||
{ name: 'full', type: 'bool' }
|
||||
],
|
||||
type: 'Option<EthRichBlock>'
|
||||
},
|
||||
getBlockTransactionCountByHash: {
|
||||
description: 'Returns the number of transactions in a block with given hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getBlockTransactionCountByNumber: {
|
||||
description: 'Returns the number of transactions in a block with given block number.',
|
||||
params: [
|
||||
{ name: 'block', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getCode: {
|
||||
description: 'Returns the code at given address at given time (block number).',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'Bytes'
|
||||
},
|
||||
getLogs: {
|
||||
description: 'Returns logs matching given filter object.',
|
||||
params: [
|
||||
{ name: 'filter', type: 'EthFilter' }
|
||||
],
|
||||
type: 'Vec<EthLog>'
|
||||
},
|
||||
getProof: {
|
||||
description: 'Returns proof for account and storage.',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ name: 'storageKeys', type: 'Vec<H256>' },
|
||||
{ name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'EthAccount'
|
||||
},
|
||||
getStorageAt: {
|
||||
description: 'Returns content of the storage at given address.',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ name: 'index', type: 'U256' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'H256'
|
||||
},
|
||||
getTransactionByBlockHashAndIndex: {
|
||||
description: 'Returns transaction at given block hash and index.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
],
|
||||
type: 'EthTransaction'
|
||||
},
|
||||
getTransactionByBlockNumberAndIndex: {
|
||||
description: 'Returns transaction by given block number and index.',
|
||||
params: [
|
||||
{ name: 'number', type: 'BlockNumber' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
],
|
||||
type: 'EthTransaction'
|
||||
},
|
||||
getTransactionByHash: {
|
||||
description: 'Get transaction by its hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
],
|
||||
type: 'EthTransaction'
|
||||
},
|
||||
getTransactionCount: {
|
||||
description: 'Returns the number of transactions sent from given address at given time (block number).',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getTransactionReceipt: {
|
||||
description: 'Returns transaction receipt by transaction hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
],
|
||||
type: 'EthReceipt'
|
||||
},
|
||||
getUncleByBlockHashAndIndex: {
|
||||
description: 'Returns an uncles at given block and index.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
],
|
||||
type: 'EthRichBlock'
|
||||
},
|
||||
getUncleByBlockNumberAndIndex: {
|
||||
description: 'Returns an uncles at given block and index.',
|
||||
params: [
|
||||
{ name: 'number', type: 'BlockNumber' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
],
|
||||
type: 'EthRichBlock'
|
||||
},
|
||||
getUncleCountByBlockHash: {
|
||||
description: 'Returns the number of uncles in a block with given hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getUncleCountByBlockNumber: {
|
||||
description: 'Returns the number of uncles in a block with given block number.',
|
||||
params: [
|
||||
{ name: 'number', type: 'BlockNumber' }
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getWork: {
|
||||
description: 'Returns the hash of the current block, the seedHash, and the boundary condition to be met.',
|
||||
params: [],
|
||||
type: 'EthWork'
|
||||
},
|
||||
hashrate: {
|
||||
description: 'Returns the number of hashes per second that the node is mining with.',
|
||||
params: [],
|
||||
type: 'U256'
|
||||
},
|
||||
mining: {
|
||||
description: 'Returns true if client is actively mining new blocks.',
|
||||
params: [],
|
||||
type: 'bool'
|
||||
},
|
||||
protocolVersion: {
|
||||
description: 'Returns protocol version encoded as a string (quotes are necessary).',
|
||||
params: [],
|
||||
type: 'u64'
|
||||
},
|
||||
sendRawTransaction: {
|
||||
description: 'Sends signed transaction, returning its hash.',
|
||||
params: [
|
||||
{ name: 'bytes', type: 'Bytes' }
|
||||
],
|
||||
type: 'H256'
|
||||
},
|
||||
sendTransaction: {
|
||||
description: 'Sends transaction; will block waiting for signer to return the transaction hash',
|
||||
params: [
|
||||
{ name: 'tx', type: 'EthTransactionRequest' }
|
||||
],
|
||||
type: 'H256'
|
||||
},
|
||||
submitHashrate: {
|
||||
description: 'Used for submitting mining hashrate.',
|
||||
params: [
|
||||
{ name: 'index', type: 'U256' },
|
||||
{ name: 'hash', type: 'H256' }
|
||||
],
|
||||
type: 'bool'
|
||||
},
|
||||
submitWork: {
|
||||
description: 'Used for submitting a proof-of-work solution.',
|
||||
params: [
|
||||
{ name: 'nonce', type: 'H64' },
|
||||
{ name: 'headerHash', type: 'H256' },
|
||||
{ name: 'mixDigest', type: 'H256' }
|
||||
],
|
||||
type: 'bool'
|
||||
},
|
||||
subscribe: {
|
||||
description: 'Subscribe to Eth subscription.',
|
||||
params: [
|
||||
{ name: 'kind', type: 'EthSubKind' },
|
||||
{ isOptional: true, name: 'params', type: 'EthSubParams' }
|
||||
],
|
||||
pubsub: [
|
||||
'subscription',
|
||||
'subscribe',
|
||||
'unsubscribe'
|
||||
],
|
||||
type: 'Null'
|
||||
},
|
||||
syncing: {
|
||||
description: 'Returns an object with data about the sync status or false.',
|
||||
params: [],
|
||||
type: 'EthSyncStatus'
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,274 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Bytes, Enum, GenericEthereumAccountId, GenericEthereumLookupSource, Option, Struct, U256, U64, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||
import type { BlockNumber, H160, H2048, H256, H512 } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
/** @name EthAccount */
|
||||
export interface EthAccount extends Struct {
|
||||
readonly address: H160;
|
||||
readonly balance: U256;
|
||||
readonly nonce: U256;
|
||||
readonly codeHash: H256;
|
||||
readonly storageHash: H256;
|
||||
readonly accountProof: Vec<Bytes>;
|
||||
readonly storageProof: Vec<EthStorageProof>;
|
||||
}
|
||||
|
||||
/** @name EthBlock */
|
||||
export interface EthBlock extends Struct {
|
||||
readonly blockHash: Option<H256>;
|
||||
readonly parentHash: H256;
|
||||
readonly sha3Uncles: H256;
|
||||
readonly author: H160;
|
||||
readonly miner: H160;
|
||||
readonly stateRoot: H256;
|
||||
readonly transactionsRoot: H256;
|
||||
readonly receiptsRoot: H256;
|
||||
readonly number: Option<U256>;
|
||||
readonly gasUsed: U256;
|
||||
readonly gasLimit: U256;
|
||||
readonly extraData: Bytes;
|
||||
readonly logsBloom: H2048;
|
||||
readonly timestamp: U256;
|
||||
readonly difficulty: U256;
|
||||
readonly totalDifficulty: Option<U256>;
|
||||
readonly sealFields: Vec<Bytes>;
|
||||
readonly uncles: Vec<H256>;
|
||||
readonly transactions: Vec<EthTransaction>;
|
||||
readonly blockSize: Option<U256>;
|
||||
}
|
||||
|
||||
/** @name EthBloom */
|
||||
export interface EthBloom extends H2048 {}
|
||||
|
||||
/** @name EthCallRequest */
|
||||
export interface EthCallRequest extends Struct {
|
||||
readonly from: Option<H160>;
|
||||
readonly to: Option<H160>;
|
||||
readonly gasPrice: Option<U256>;
|
||||
readonly gas: Option<U256>;
|
||||
readonly value: Option<U256>;
|
||||
readonly data: Option<Bytes>;
|
||||
readonly nonce: Option<U256>;
|
||||
}
|
||||
|
||||
/** @name EthereumAccountId */
|
||||
export interface EthereumAccountId extends GenericEthereumAccountId {}
|
||||
|
||||
/** @name EthereumLookupSource */
|
||||
export interface EthereumLookupSource extends GenericEthereumLookupSource {}
|
||||
|
||||
/** @name EthereumSignature */
|
||||
export interface EthereumSignature extends U8aFixed {}
|
||||
|
||||
/** @name EthFilter */
|
||||
export interface EthFilter extends Struct {
|
||||
readonly fromBlock: Option<BlockNumber>;
|
||||
readonly toBlock: Option<BlockNumber>;
|
||||
readonly blockHash: Option<H256>;
|
||||
readonly address: Option<EthFilterAddress>;
|
||||
readonly topics: Option<EthFilterTopic>;
|
||||
}
|
||||
|
||||
/** @name EthFilterAddress */
|
||||
export interface EthFilterAddress extends Enum {
|
||||
readonly isSingle: boolean;
|
||||
readonly asSingle: H160;
|
||||
readonly isMultiple: boolean;
|
||||
readonly asMultiple: Vec<H160>;
|
||||
readonly isNull: boolean;
|
||||
}
|
||||
|
||||
/** @name EthFilterTopic */
|
||||
export interface EthFilterTopic extends Enum {
|
||||
readonly isSingle: boolean;
|
||||
readonly asSingle: EthFilterTopicInner;
|
||||
readonly isMultiple: boolean;
|
||||
readonly asMultiple: Vec<EthFilterTopicInner>;
|
||||
readonly isNull: boolean;
|
||||
}
|
||||
|
||||
/** @name EthFilterTopicEntry */
|
||||
export interface EthFilterTopicEntry extends Option<H256> {}
|
||||
|
||||
/** @name EthFilterTopicInner */
|
||||
export interface EthFilterTopicInner extends Enum {
|
||||
readonly isSingle: boolean;
|
||||
readonly asSingle: EthFilterTopicEntry;
|
||||
readonly isMultiple: boolean;
|
||||
readonly asMultiple: Vec<EthFilterTopicEntry>;
|
||||
readonly isNull: boolean;
|
||||
}
|
||||
|
||||
/** @name EthHeader */
|
||||
export interface EthHeader extends Struct {
|
||||
readonly blockHash: Option<H256>;
|
||||
readonly parentHash: H256;
|
||||
readonly sha3Uncles: H256;
|
||||
readonly author: H160;
|
||||
readonly miner: H160;
|
||||
readonly stateRoot: H256;
|
||||
readonly transactionsRoot: H256;
|
||||
readonly receiptsRoot: H256;
|
||||
readonly number: Option<U256>;
|
||||
readonly gasUsed: U256;
|
||||
readonly gasLimit: U256;
|
||||
readonly extraData: Bytes;
|
||||
readonly logsBloom: H2048;
|
||||
readonly timestamp: U256;
|
||||
readonly difficulty: U256;
|
||||
readonly sealFields: Vec<Bytes>;
|
||||
readonly blockSize: Option<U256>;
|
||||
}
|
||||
|
||||
/** @name EthLog */
|
||||
export interface EthLog extends Struct {
|
||||
readonly address: H160;
|
||||
readonly topics: Vec<H256>;
|
||||
readonly data: Bytes;
|
||||
readonly blockHash: Option<H256>;
|
||||
readonly blockNumber: Option<U256>;
|
||||
readonly transactionHash: Option<H256>;
|
||||
readonly transactionIndex: Option<U256>;
|
||||
readonly logIndex: Option<U256>;
|
||||
readonly transactionLogIndex: Option<U256>;
|
||||
readonly removed: bool;
|
||||
}
|
||||
|
||||
/** @name EthReceipt */
|
||||
export interface EthReceipt extends Struct {
|
||||
readonly transactionHash: Option<H256>;
|
||||
readonly transactionIndex: Option<U256>;
|
||||
readonly blockHash: Option<H256>;
|
||||
readonly from: Option<H160>;
|
||||
readonly to: Option<H160>;
|
||||
readonly blockNumber: Option<U256>;
|
||||
readonly cumulativeGasUsed: U256;
|
||||
readonly gasUsed: Option<U256>;
|
||||
readonly contractAddress: Option<H160>;
|
||||
readonly logs: Vec<EthLog>;
|
||||
readonly root: Option<H256>;
|
||||
readonly logsBloom: H2048;
|
||||
readonly statusCode: Option<U64>;
|
||||
}
|
||||
|
||||
/** @name EthRichBlock */
|
||||
export interface EthRichBlock extends EthBlock {}
|
||||
|
||||
/** @name EthRichHeader */
|
||||
export interface EthRichHeader extends EthHeader {}
|
||||
|
||||
/** @name EthStorageProof */
|
||||
export interface EthStorageProof extends Struct {
|
||||
readonly key: U256;
|
||||
readonly value: U256;
|
||||
readonly proof: Vec<Bytes>;
|
||||
}
|
||||
|
||||
/** @name EthSubKind */
|
||||
export interface EthSubKind extends Enum {
|
||||
readonly isNewHeads: boolean;
|
||||
readonly isLogs: boolean;
|
||||
readonly isNewPendingTransactions: boolean;
|
||||
readonly isSyncing: boolean;
|
||||
}
|
||||
|
||||
/** @name EthSubParams */
|
||||
export interface EthSubParams extends Enum {
|
||||
readonly isNone: boolean;
|
||||
readonly isLogs: boolean;
|
||||
readonly asLogs: EthFilter;
|
||||
}
|
||||
|
||||
/** @name EthSubResult */
|
||||
export interface EthSubResult extends Enum {
|
||||
readonly isHeader: boolean;
|
||||
readonly asHeader: EthRichHeader;
|
||||
readonly isLog: boolean;
|
||||
readonly asLog: EthLog;
|
||||
readonly isTransactionHash: boolean;
|
||||
readonly asTransactionHash: H256;
|
||||
readonly isSyncState: boolean;
|
||||
readonly asSyncState: EthSyncStatus;
|
||||
}
|
||||
|
||||
/** @name EthSyncInfo */
|
||||
export interface EthSyncInfo extends Struct {
|
||||
readonly startingBlock: U256;
|
||||
readonly currentBlock: U256;
|
||||
readonly highestBlock: U256;
|
||||
readonly warpChunksAmount: Option<U256>;
|
||||
readonly warpChunksProcessed: Option<U256>;
|
||||
}
|
||||
|
||||
/** @name EthSyncStatus */
|
||||
export interface EthSyncStatus extends Enum {
|
||||
readonly isInfo: boolean;
|
||||
readonly asInfo: EthSyncInfo;
|
||||
readonly isNone: boolean;
|
||||
}
|
||||
|
||||
/** @name EthTransaction */
|
||||
export interface EthTransaction extends Struct {
|
||||
readonly blockHash: Option<H256>;
|
||||
readonly blockNumber: Option<U256>;
|
||||
readonly chainId: Option<u64>;
|
||||
readonly condition: Option<EthTransactionCondition>;
|
||||
readonly creates: Option<H160>;
|
||||
readonly from: H160;
|
||||
readonly gas: U256;
|
||||
readonly gasPrice: U256;
|
||||
readonly hash: H256;
|
||||
readonly input: Bytes;
|
||||
readonly nonce: U256;
|
||||
readonly publicKey: Option<H512>;
|
||||
readonly r: U256;
|
||||
readonly raw: Bytes;
|
||||
readonly s: U256;
|
||||
readonly standardV: U256;
|
||||
readonly to: Option<H160>;
|
||||
readonly transactionIndex: Option<U256>;
|
||||
readonly v: U256;
|
||||
readonly value: U256;
|
||||
}
|
||||
|
||||
/** @name EthTransactionCondition */
|
||||
export interface EthTransactionCondition extends Enum {
|
||||
readonly isBlock: boolean;
|
||||
readonly asBlock: u64;
|
||||
readonly isTime: boolean;
|
||||
readonly asTime: u64;
|
||||
}
|
||||
|
||||
/** @name EthTransactionRequest */
|
||||
export interface EthTransactionRequest extends Struct {
|
||||
readonly from: Option<H160>;
|
||||
readonly to: Option<H160>;
|
||||
readonly gasPrice: Option<U256>;
|
||||
readonly gas: Option<U256>;
|
||||
readonly value: Option<U256>;
|
||||
readonly data: Option<Bytes>;
|
||||
readonly nonce: Option<U256>;
|
||||
}
|
||||
|
||||
/** @name EthTransactionStatus */
|
||||
export interface EthTransactionStatus extends Struct {
|
||||
readonly transactionHash: H256;
|
||||
readonly transactionIndex: u32;
|
||||
readonly from: H160;
|
||||
readonly to: Option<H160>;
|
||||
readonly contractAddress: Option<H160>;
|
||||
readonly logs: Vec<EthLog>;
|
||||
readonly logsBloom: EthBloom;
|
||||
}
|
||||
|
||||
/** @name EthWork */
|
||||
export interface EthWork extends Struct {
|
||||
readonly powHash: H256;
|
||||
readonly seedHash: H256;
|
||||
readonly target: H256;
|
||||
readonly number: Option<u64>;
|
||||
}
|
||||
|
||||
export type PHANTOM_ETH = 'eth';
|
||||
@@ -1,15 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import type { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
EthereumAccountId: 'GenericEthereumAccountId',
|
||||
EthereumLookupSource: 'GenericEthereumLookupSource'
|
||||
}
|
||||
} as Definitions;
|
||||
@@ -1,12 +0,0 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { GenericEthereumAccountId, GenericEthereumLookupSource } from '@polkadot/types';
|
||||
|
||||
/** @name EthereumAccountId */
|
||||
export interface EthereumAccountId extends GenericEthereumAccountId {}
|
||||
|
||||
/** @name EthereumLookupSource */
|
||||
export interface EthereumLookupSource extends GenericEthereumLookupSource {}
|
||||
|
||||
export type PHANTOM_ETHEREUM = 'ethereum';
|
||||
@@ -17,7 +17,7 @@ describe('Registration', (): void => {
|
||||
'039911039922039944039955039933000003996600'
|
||||
).toJSON()
|
||||
).toEqual({
|
||||
deposit: 10000000000000,
|
||||
deposit: '0x0000000000000000000009184e72a000',
|
||||
info: {
|
||||
additional: [],
|
||||
display: { Raw: '0x9911' },
|
||||
|
||||
@@ -10,13 +10,19 @@ const jsonrpc: Record<string, Record<string, DefinitionRpcExt>> = {};
|
||||
Object
|
||||
.keys(definitions)
|
||||
.filter((key) => Object.keys(definitions[key as 'babe'].rpc || {}).length !== 0)
|
||||
.forEach((section): void => {
|
||||
jsonrpc[section] = {};
|
||||
.forEach((_section): void => {
|
||||
jsonrpc[_section] = {};
|
||||
|
||||
Object
|
||||
.entries(definitions[section as 'babe'].rpc)
|
||||
.entries(definitions[_section as 'babe'].rpc)
|
||||
.forEach(([method, def]): void => {
|
||||
const isSubscription = !!(def as DefinitionRpcSub).pubsub;
|
||||
const section = def.aliasSection || _section;
|
||||
|
||||
// allow for section overrides
|
||||
if (!jsonrpc[section]) {
|
||||
jsonrpc[section] = {};
|
||||
}
|
||||
|
||||
jsonrpc[section][method] = ({ ...def, isSubscription, jsonrpc: `${section}_${method}`, method, section });
|
||||
});
|
||||
|
||||
@@ -250,6 +250,7 @@ export default {
|
||||
|
||||
// This always maps to the latest
|
||||
DoubleMapTypeLatest: 'DoubleMapTypeV12',
|
||||
ErrorMetadataLatest: 'ErrorMetadataV12',
|
||||
EventMetadataLatest: 'EventMetadataV12',
|
||||
ExtrinsicMetadataLatest: 'ExtrinsicMetadataV12',
|
||||
FunctionArgumentMetadataLatest: 'FunctionArgumentMetadataV12',
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user