Compare commits

...
40 Commits
Author SHA1 Message Date
Github Actions bfb241d995 [CI Skip] release/stable 4.0.2
skip-checks: true
2021-03-08 14:23:22 +00:00
Jaco Greeff 314ad8c3f2 4.0.2 (#3283)
* 4.0.2

* Update CHANGELOG.md

* Bump common
2021-03-08 15:14:24 +01:00
Github Actions aa85371f82 [CI Skip] release/beta 4.0.2-0
skip-checks: true
2021-03-08 12:46:02 +00:00
Jaco Greeff d0a08dadd9 Add correct election Phase type (#3280) 2021-03-08 13:38:14 +01:00
Github Actions eeff764345 [CI Skip] release/stable 4.0.1
skip-checks: true
2021-03-07 15:47:19 +00:00
Jaco Greeff 4870ec4f40 4.0 (#3277)
* 4.0

* Correct patch
2021-03-07 16:37:47 +01:00
Github Actions 1c3cfbfa0c [CI Skip] release/beta 4.0.1-14
skip-checks: true
2021-03-07 15:10:20 +00:00
Jaco Greeff 3c9b7de6c7 Add createdAtHash to Codec interface (#3276)
* Add createdAtHash to Codec interface

* Adjust linkedHash (also on )

* createdAtHash
2021-03-07 16:00:30 +01:00
Github Actions 22e5488f16 [CI Skip] release/beta 4.0.1-13
skip-checks: true
2021-03-06 14:57:52 +00:00
Jaco Greeff b37887993e Westend 49 upgrade block (#3273) 2021-03-06 15:49:10 +01:00
Github Actions 75361cb0ff [CI Skip] release/beta 4.0.1-12
skip-checks: true
2021-03-06 07:21:18 +00:00
Jaco Greeff 894992bc4c Bump deps (#3272) 2021-03-06 08:12:35 +01:00
Github Actions d955fab169 [CI Skip] release/beta 4.0.1-11
skip-checks: true
2021-03-05 16:23:50 +00:00
Jaco Greeff 580d225387 Bump common (#3271) 2021-03-05 17:13:37 +01:00
Github Actions d48f59e48d [CI Skip] release/beta 4.0.1-10
skip-checks: true
2021-03-05 12:34:38 +00:00
Jaco Greeff 108b49ea03 Expose the hash field from contract wasm (#3267) 2021-03-05 13:25:00 +01:00
Github Actions 9295349886 [CI Skip] release/beta 4.0.1-9
skip-checks: true
2021-03-05 09:38:48 +00:00
Jaco Greeff a51658ffac Cater for at-genesis best headers (#3264) 2021-03-05 10:28:56 +01:00
Github Actions 47f08e9e04 [CI Skip] release/beta 4.0.1-8
skip-checks: true
2021-03-05 08:45:40 +00:00
iiiiiiiiandJaco Greeff 7906ae63dc Make unknownTypes externally accessible (#3263)
* Make unknownTypes externally accessible

* fix lint

* Update registry.ts

* Update registry.ts

* Update packages/types/src/types/registry.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* Update packages/types/src/create/registry.ts

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
2021-03-05 09:36:01 +01:00
Github Actions 0e76271dba [CI Skip] release/beta 4.0.1-7
skip-checks: true
2021-03-04 08:04:33 +00:00
Jaco Greeff e117619e34 Use the parent header for era info (#3260) 2021-03-04 08:57:22 +01:00
Github Actions 67b416fe80 [CI Skip] release/beta 4.0.1-6
skip-checks: true
2021-03-04 07:13:35 +00:00
Jaco Greeff 78dbfa46fa AccountInfoWithTripleRefCount type & detection (#3228)
* AccountInfoWithTripleRefCount

* Update naming

* build
2021-03-04 08:03:25 +01:00
Github Actions 01db9261d5 [CI Skip] release/beta 4.0.1-5
skip-checks: true
2021-03-03 12:28:40 +00:00
Jaco Greeff 674c38b384 Enum serializes to camelCase (#3024)
* Enum serializes to camelCase

* Dedupe

* rewrite static json

* test for StorageKind enum
2021-03-03 13:18:07 +01:00
Github Actions 0700e824eb [CI Skip] release/beta 4.0.1-4
skip-checks: true
2021-03-03 09:12:10 +00:00
Jaco Greeff 0362eaf472 Bump deps (& berry) (#3259)
* Bump deps (& berry)

* new 4.2.2 linting issues
2021-03-03 10:03:46 +01:00
Github Actions 696b3964e6 [CI Skip] release/beta 4.0.1-3
skip-checks: true
2021-03-02 20:29:13 +00:00
Jaco Greeff 5d0c2eed7b Default build to type: module (#3253)
* Default build to type: module

* 4.0

* pre

* yarn.lock

* packageInfo

* Bump common

* jest & bumps

* additional
2021-03-02 21:19:55 +01:00
Github Actions e4c3289ad8 [CI Skip] release/beta 3.11.2-4
skip-checks: true
2021-03-01 20:51:04 +00:00
Jaco Greeff 4449bdae6f Bump deps (#3252) 2021-03-01 21:43:13 +01:00
Github Actions 064957db81 [CI Skip] release/beta 3.11.2-3
skip-checks: true
2021-03-01 16:07:02 +00:00
Jaco Greeff ccd89ef0a6 Trigger validator shash retrievals on Bonded events (#3251) 2021-03-01 16:57:27 +01:00
Github Actions 47beb5f41f [CI Skip] release/beta 3.11.2-2
skip-checks: true
2021-03-01 08:32:11 +00:00
Jaco Greeff 9f205392a3 Remove old RewardDestination type (#3246)
* Remove old RewardDestination type

* merge master

* adjust

* Adjust
2021-03-01 09:23:37 +01:00
Github Actions adce7ccbee [CI Skip] release/beta 3.11.2-1
skip-checks: true
2021-03-01 08:08:09 +00:00
Jaco Greeff b83b3a9437 Change default ValidatorPrefs (#3244)
* Change default ValidatorPrefs

* Linkage test

* Previous default
2021-03-01 08:59:38 +01:00
Github Actions 147dbcf24f [CI Skip] release/beta 3.11.2-0
skip-checks: true
2021-03-01 07:52:05 +00:00
Alex D 2afff1b41f Use derive customAccount and customLocks for balance overrides (#3248)
* modified api-derive balances to allow use of custom balance storages via derives; current implementation only works with standard call signatures

* type predicate as filter value

* renamed derive method name
2021-03-01 08:42:07 +01:00
95 changed files with 1617 additions and 1358 deletions
+2
View File
@@ -17,3 +17,5 @@
3.9.2
3.9.3
3.10.2
4.0.2
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -10,4 +10,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: "@yarnpkg/plugin-version"
yarnPath: .yarn/releases/yarn-2.4.0.cjs
yarnPath: .yarn/releases/yarn-2.4.1.cjs
+31
View File
@@ -1,5 +1,36 @@
# CHANGELOG
## 4.0.2 Mar 8, 2021
Upgrade priority: High. Required if you are using 4.0.1 in a Node.js environment.
Changes:
- Fix import from `@polkadot/x-rxjs` in Node environments (From common)
- Add correct types for `Phase` is new validator elections module
## 4.0.1 Mar 7, 2021
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
**Important** In the 4.0 version the default package type has been changed to ESM modules by default. This should not affect usage, however since the output formats changed, a new major version is required.
Contributed:
- Expose `unknownTypes` on the registry interface (Thanks to https://github.com/ii-ii-ii)
Changes:
- Build to ESM by default (with cjs versions via export map)
- Enum `.toSON()` now encodes all keys as `camelCase` (aligning with the output from Substrate)
- Add `createdAtHash?: Hash` to `Codec` interface (filled-in by storage retrievals)
- Expose the source hash as `wamHash` on Abi parsed instances
- Use `parentHash` when creating mortal era (handles frequent forks better)
- Add `AccountInfoWithTripleRefCount` to cater for latest Substrate
- Add upgrade block for Westend 49
## 3.11.1 Feb 28, 2021
Upgrade priority: Low. Recommended for users wanting to keep updated with chain changes.
+1 -1
View File
@@ -26,5 +26,5 @@ module.exports = Object.assign({}, config, {
'<rootDir>/packages/types/build',
'<rootDir>/packages/types-known/build'
],
resolver: '@polkadot/dev/config/jest-resolver.cjs'
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/|rxjs/_esm5)']
});
+5 -5
View File
@@ -8,7 +8,7 @@
"packages/*"
],
"resolutions": {
"typescript": "^4.1.5"
"typescript": "^4.2.3"
},
"scripts": {
"build": "yarn build:interfaces && polkadot-dev-build-ts",
@@ -27,12 +27,12 @@
"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/register": "^7.13.8",
"@babel/runtime": "^7.13.8",
"@polkadot/dev": "^0.61.30",
"@polkadot/ts": "^0.3.59",
"@babel/runtime": "^7.13.9",
"@polkadot/dev": "^0.62.5",
"@polkadot/ts": "^0.3.61",
"@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.20",
"copyfiles": "^2.4.1"
},
"version": "3.11.1"
"version": "4.0.2"
}
+8 -7
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/api-contract",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,11 +16,11 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/api": "3.11.1",
"@polkadot/types": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/x-rxjs": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/api": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"bn.js": "^4.11.9"
}
}
+22
View File
@@ -1,10 +1,18 @@
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { blake2AsHex } from '@polkadot/util-crypto';
import abis from '../test/contracts';
import { Abi } from '.';
interface JSONAbi {
source: {
compiler: string,
hash: string,
language: string,
wasm: string
},
spec: {
messages: {
name: string[] | string
@@ -27,4 +35,18 @@ describe('Abi', (): void => {
}
});
});
it('has the correct hash for the source', (): void => {
const bundle = abis.ink_flipperBundle as JSONAbi;
const abi = new Abi(bundle as any);
// manual
expect(bundle.source.hash).toEqual(blake2AsHex(bundle.source.wasm));
// the Codec hash
expect(bundle.source.hash).toEqual(abi.project.source.wasm.hash.toHex());
// the hash as per the actual Abi
expect(bundle.source.hash).toEqual(abi.project.source.wasmHash.toHex());
});
});
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-contract', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/api-contract', version: '4.0.2' };
@@ -0,0 +1,6 @@
[
{
"info": 6,
"type": "bool"
}
]
@@ -6,5 +6,6 @@ export { default as dns } from './dns.json';
export { default as erc20 } from './erc20.json';
export { default as erc721 } from './erc721.json';
export { default as flipper } from './flipper.json';
export { default as flipperBundle } from './flipper.contract.json';
export { default as incrementer } from './incrementer.json';
export { default as multisigPlain } from './multisig_plain.json';
+12 -11
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/api-derive",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,17 +16,17 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/api": "3.11.1",
"@polkadot/rpc-core": "3.11.1",
"@polkadot/types": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/util-crypto": "^5.9.2",
"@polkadot/x-rxjs": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/api": "4.0.2",
"@polkadot/rpc-core": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.9.2",
"@polkadot/rpc-provider": "3.11.1"
"@polkadot/keyring": "^6.0.5",
"@polkadot/rpc-provider": "4.0.2"
}
}
+17 -3
View File
@@ -17,6 +17,12 @@ type BalanceResult = [Balance, Balance, Balance, Balance];
type Result = [Index, BalanceResult[]];
type DeriveCustomAccount = ApiInterfaceRx['derive'] & {
[custom: string]: {
customAccount?: ApiInterfaceRx['query']['balances']['account']
}
}
function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenFee, frozenMisc]: BalanceResult): DeriveBalancesAccountData {
return {
freeBalance,
@@ -55,7 +61,13 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
}
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
const balances = modules.map((m): QueryableStorageMultiArg<'rxjs'> => [api.query[m].account, accountId]);
const balances = modules.map(
(m): QueryableStorageMultiArg<'rxjs'> => [
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
accountId
]
);
const extract = (data: AccountData[]) =>
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
@@ -75,9 +87,11 @@ function queryCurrent (api: ApiInterfaceRx, accountId: AccountId): Observable<Re
const { feeFrozen, free, miscFrozen, reserved } = (infoOrTuple as AccountInfo).nonce
? (infoOrTuple as AccountInfo).data
: (infoOrTuple as [Index, AccountData])[1];
const accountNonce = (infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0];
return [accountNonce, [[free, reserved, feeFrozen, miscFrozen]]];
return [
(infoOrTuple as AccountInfo).nonce || (infoOrTuple as [Index, AccountData])[0],
[[free, reserved, feeFrozen, miscFrozen]]
];
})
);
}
+19 -10
View File
@@ -9,7 +9,7 @@ import type { DeriveBalancesAccount, DeriveBalancesAccountData, DeriveBalancesAl
import BN from 'bn.js';
import { bnMax } from '@polkadot/util';
import { bnMax, isFunction } from '@polkadot/util';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -27,6 +27,12 @@ interface AllLocked {
vestingLocked: Balance
}
type DeriveCustomLocks = ApiInterfaceRx['derive'] & {
[custom: string]: {
customLocks?: ApiInterfaceRx['query']['balances']['locks']
}
}
const VESTING_ID = '0x76657374696e6720';
function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (BalanceLock | BalanceLockTo212)[]): AllLocked {
@@ -54,11 +60,10 @@ function calcLocked (api: ApiInterfaceRx, bestNumber: BlockNumber, locks: (Balan
function calcShared (api: ApiInterfaceRx, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (BalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
const availableBalance = api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance)));
return {
...data,
availableBalance,
availableBalance: api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance))),
lockedBalance,
lockedBreakdown,
vestingLocked
@@ -75,8 +80,6 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
const isVesting = isStarted && !shared.vestingLocked.isZero();
const vestedClaimable = api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0);
const vestingEndBlock = api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0);
return {
...shared,
@@ -85,8 +88,8 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
additional: allLocks.filter((_, index) => index !== 0).map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
isVesting,
vestedBalance,
vestedClaimable,
vestingEndBlock,
vestedClaimable: api.registry.createType('Balance', isVesting ? shared.vestingLocked.sub(vestingTotal.sub(vestedBalance)) : 0),
vestingEndBlock: api.registry.createType('BlockNumber', isVesting ? vestingTotal.div(perBlock).add(startingBlock) : 0),
vestingPerBlock: perBlock,
vestingTotal
};
@@ -112,11 +115,17 @@ function queryOld (api: ApiInterfaceRx, accountId: AccountId): Observable<Result
);
}
const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable;
// current (balances, vesting)
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
const lockCalls = balanceInstances.map((m) => api.query[m].locks);
const lockCalls = balanceInstances.map(
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
);
const lockEmpty = lockCalls.map((c) => !c);
const lockQueries = lockCalls.filter((c) => c).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
return (
api.query.vesting?.vesting
@@ -166,7 +175,7 @@ export function all (instanceId: string, api: ApiInterfaceRx): (address: Account
? combineLatest([
of(account),
api.derive.chain.bestNumber(),
api.query.system?.account || api.query.balances?.account
isFunction(api.query.system?.account) || isFunction(api.query.balances?.account)
? queryCurrent(api, account.accountId, balanceInstances)
: queryOld(api, account.accountId)
])
@@ -2,8 +2,10 @@
// SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId, EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import type { Vec } from '@polkadot/types';
import type { EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import type { HeaderExtended } from '../type';
import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators';
@@ -18,17 +20,17 @@ import { memo } from '../util';
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
return memo(instanceId, (): Observable<SignedBlockExtended> =>
api.derive.chain.subscribeNewHeads().pipe(
switchMap((header): Observable<[SignedBlock, EventRecord[], AccountId[] | undefined]> => {
const blockHash = header.hash;
switchMap((header): Observable<[SignedBlock, Vec<EventRecord>, HeaderExtended]> => {
const blockHash = header.createdAtHash || header.hash;
return combineLatest(
api.rpc.chain.getBlock(blockHash),
api.query.system.events.at(blockHash),
of(header.validators)
of(header)
);
}),
map(([block, events, validators]) =>
new SignedBlockExtended(api.registry, block, events, validators)
map(([block, events, header]) =>
new SignedBlockExtended(api.registry, block, events, header.validators)
)
)
);
@@ -29,10 +29,13 @@ export function subscribeNewHeads (instanceId: string, api: ApiInterfaceRx): ()
api.rpc.chain.subscribeNewHeads(),
api.query.session
? api.query.session.validators()
: of([])
: of(undefined)
]).pipe(
map(([header, validators]): HeaderExtended =>
new HeaderExtended(api.registry, header, validators)
)
));
map(([header, validators]): HeaderExtended => {
header.createdAtHash = header.hash;
return new HeaderExtended(api.registry, header, validators);
})
)
);
}
@@ -51,7 +51,7 @@ function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
export function proposals (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveProposal[]> {
return memo(instanceId, (): Observable<DeriveProposal[]> =>
api.query.democracy?.publicProps && api.query.democracy?.preimages
isFunction(api.query.democracy?.publicProps) && isFunction(api.query.democracy?.preimages)
? api.query.democracy.publicProps<Proposals>().pipe(
switchMap((proposals) =>
combineLatest([
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api-derive', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/api-derive', version: '4.0.2' };
+28 -3
View File
@@ -5,16 +5,41 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountId } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs';
import { map } from '@polkadot/x-rxjs/operators';
import { map, startWith, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util';
import { drr, memo } from '../util';
function onBondedEvent (api: ApiInterfaceRx): Observable<number> {
let current = Date.now();
return api.query.system.events().pipe(
map((events): number => {
current = events.filter(({ event, phase }): boolean => {
try {
return phase.isApplyExtrinsic &&
event.section === 'staking' &&
event.method === 'Bonded';
} catch {
return false;
}
})
? Date.now()
: current;
return current;
}),
startWith(current),
drr({ skipTimeout: true })
);
}
/**
* @description Retrieve the list of all validator stashes
*/
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> =>
api.query.staking.validators.keys().pipe(
onBondedEvent(api).pipe(
switchMap(() => api.query.staking.validators.keys()),
map((keys) => keys.map(({ args: [validatorId] }) => validatorId).filter((a) => a))
)
);
+12 -3
View File
@@ -33,10 +33,19 @@ function nextNonce (api: ApiInterfaceRx, address: string): Observable<Index> {
function signingHeader (api: ApiInterfaceRx): Observable<Header> {
return combineLatest([
api.rpc.chain.getHeader(),
api.rpc.chain.getFinalizedHead().pipe(
switchMap((hash) => api.rpc.chain.getHeader(hash))
)
api.rpc.chain.getFinalizedHead()
]).pipe(
switchMap(([bestHeader, finHash]) =>
// retrieve the headers - in the case of the current block, we use the parent
// to minimize (not completely remove) the impact that forks do have on the system
// (when at genesis, just return the current header as the last known)
bestHeader.parentHash.isEmpty
? of([bestHeader, bestHeader])
: combineLatest([
api.rpc.chain.getHeader(bestHeader.parentHash),
api.rpc.chain.getHeader(finHash)
])
),
map(([current, finalized]) =>
// determine the hash to use, current when lag > max, else finalized
current.number.unwrap().sub(finalized.number.unwrap()).gt(MAX_FINALITY_LAG)
@@ -26,6 +26,7 @@ export class HeaderExtended extends _Header {
this.#author = extractAuthor(this.digest, validators);
this.#validators = validators;
this.createdAtHash = header?.createdAtHash;
}
/**
@@ -53,12 +53,13 @@ export class SignedBlockExtended extends _SignedBlock {
readonly #events: EventRecord[];
readonly #extrinsics: TxWithEvent[];
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], sessionValidators?: AccountId[]) {
constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], validators?: AccountId[]) {
super(registry, block);
this.#author = extractAuthor(this.block.header.digest, sessionValidators);
this.#author = extractAuthor(this.block.header.digest, validators);
this.#events = events || ([] as EventRecord[]);
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
this.createdAtHash = block?.createdAtHash;
}
/**
+14 -13
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/api",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,17 +16,17 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/api-derive": "3.11.1",
"@polkadot/keyring": "^5.9.2",
"@polkadot/metadata": "3.11.1",
"@polkadot/rpc-core": "3.11.1",
"@polkadot/rpc-provider": "3.11.1",
"@polkadot/types": "3.11.1",
"@polkadot/types-known": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/util-crypto": "^5.9.2",
"@polkadot/x-rxjs": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/api-derive": "4.0.2",
"@polkadot/keyring": "^6.0.5",
"@polkadot/metadata": "4.0.2",
"@polkadot/rpc-core": "4.0.2",
"@polkadot/rpc-provider": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/types-known": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"bn.js": "^4.11.9",
"eventemitter3": "^4.0.7"
}
+2 -2
View File
@@ -23,7 +23,7 @@ import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber,
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
import type { ActiveEraInfo, ElectionPhase, ElectionResult, ElectionScore, ElectionStatus, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
@@ -328,7 +328,7 @@ declare module '@polkadot/api/types/storage' {
/**
* Current phase.
**/
currentPhase: AugmentedQuery<ApiType, () => Observable<Phase>, []> & QueryableStorageEntry<ApiType, []>;
currentPhase: AugmentedQuery<ApiType, () => Observable<ElectionPhase>, []> & QueryableStorageEntry<ApiType, []>;
/**
* Desired number of targets to elect for this round.
*
+1 -1
View File
@@ -3080,7 +3080,7 @@ declare module '@polkadot/api/types/submittable' {
* - Write: Nominators, Validators
* # </weight>
**/
validate: AugmentedSubmittable<(prefs: ValidatorPrefs | { commission?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ValidatorPrefs]>;
validate: AugmentedSubmittable<(prefs: ValidatorPrefs | { commission?: any; blocked?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [ValidatorPrefs]>;
/**
* Remove any unlocked chunks from the `unlocking` queue from our management.
*
+5 -3
View File
@@ -492,9 +492,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
)
),
tap((keys): void => {
keys.length === PAGE_SIZE
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
: startSubject.complete();
setTimeout((): void => {
keys.length === PAGE_SIZE
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
: startSubject.complete();
}, 0);
}),
toArray(), // toArray since we want to startSubject to be completed
map((keysArr: StorageKey[][]) => arrayFlatten(keysArr))
+1 -1
View File
@@ -139,7 +139,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
// nothing has been found, construct new
const metadata = await this._rpcCore.state.getMetadata(header.parentHash).toPromise();
const registry = this._initRegistry(new TypeRegistry(), this._runtimeChain as Text, version, metadata);
const registry = this._initRegistry(new TypeRegistry(blockHash), this._runtimeChain as Text, version, metadata);
// For now, since this is new we ignore the capability lookups (this could be useful once proven)
// this._detectCapabilities(registry, blockHash);
+14 -6
View File
@@ -10,25 +10,32 @@ import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, take } from '@polkadot/x-rxjs/operators';
// the order and types needs to map with the all array setup below
type Extracted = [bool | null, bool | null, Releases | null];
type Extracted = [bool | null, bool | null, bool | null, Releases | null];
type DetectedKeys = keyof Pick<InterfaceTypes, 'AccountInfo' | 'ValidatorPrefs'>;
type DetectedValues = keyof InterfaceTypes;
interface DetectedTypes extends Record<DetectedKeys, DetectedValues> {
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithProviders',
AccountInfo: 'AccountInfoWithRefCount' | 'AccountInfoWithDualRefCount' | 'AccountInfoWithTripleRefCount',
RefCount: 'u8' | 'u32',
ValidatorPrefs: 'ValidatorPrefsWithBlocked' | 'ValidatorPrefsWithCommission';
}
function mapCapabilities ([systemRefcount32, systemRefcountDual, stakingVersion]: Extracted): Partial<DetectedTypes> {
function mapCapabilities ([systemRefcount32, systemRefcountDual, systemRefcountTriple, stakingVersion]: Extracted): Partial<DetectedTypes> {
const types: Partial<DetectedTypes> = {};
// AccountInfo
if (systemRefcountDual && systemRefcountDual.isTrue) {
types.AccountInfo = 'AccountInfoWithProviders';
} else if (systemRefcount32 && systemRefcount32.isTrue) {
if (systemRefcountTriple && systemRefcountTriple.isTrue) {
types.AccountInfo = 'AccountInfoWithTripleRefCount';
} else if (systemRefcountDual && systemRefcountDual.isTrue) {
types.AccountInfo = 'AccountInfoWithDualRefCount';
} else {
types.AccountInfo = 'AccountInfoWithRefCount';
if (!systemRefcount32 || systemRefcount32.isFalse) {
types.RefCount = 'u8';
}
}
// ValidatorPrefs
@@ -50,6 +57,7 @@ export function detectedCapabilities (api: ApiInterfaceRx, blockHash?: Uint8Arra
const all = [
api.query.system?.upgradedToU32RefCount,
api.query.system?.upgradedToDualRefCount,
api.query.system?.upgradedToTripleRefCount,
api.query.staking?.storageVersion
];
const included = all.map((c) => !!c);
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/api', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/api', version: '4.0.2' };
+9 -8
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/metadata",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Helpers to extract information from runtime metadata",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"repository": "github:polkadot-js/api",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -15,14 +16,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/types": "3.11.1",
"@polkadot/types-known": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/util-crypto": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/types": "4.0.2",
"@polkadot/types-known": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.9.2"
"@polkadot/keyring": "^6.0.5"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/metadata authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/metadata', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/metadata', version: '4.0.2' };
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+10 -9
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/rpc-core",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,14 +16,14 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/metadata": "3.11.1",
"@polkadot/rpc-provider": "3.11.1",
"@polkadot/types": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/x-rxjs": "^5.9.2"
"@babel/runtime": "^7.13.9",
"@polkadot/metadata": "4.0.2",
"@polkadot/rpc-provider": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5"
},
"devDependencies": {
"@polkadot/keyring": "^5.9.2"
"@polkadot/keyring": "^6.0.5"
}
}
+33 -27
View File
@@ -244,17 +244,17 @@ export class RpcCore implements RpcInterface {
// execute the RPC call, doing a registry swap for historic as applicable
const callWithRegistry = async (outputAs: OutputType, values: any[]): Promise<Codec | Codec[]> => {
const hash = hashIndex === -1
? undefined
const blockHash = hashIndex === -1
? null
: values[hashIndex] as Uint8Array;
const { registry } = hash && this.#getBlockRegistry
? await this.#getBlockRegistry(hash)
const { registry } = blockHash && this.#getBlockRegistry
? await this.#getBlockRegistry(blockHash)
: { registry: this.#registryDefault };
const params = this._formatInputs(registry, def, values);
const params = this._formatInputs(registry, null, def, values);
const data = await this.provider.send(rpcName, params.map((param): AnyJson => param.toJSON())) as AnyJson;
return outputAs === 'scale'
? this._formatOutput(registry, method, def, params, data)
? this._formatOutput(registry, blockHash, method, def, params, data)
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', data);
};
@@ -324,7 +324,7 @@ export class RpcCore implements RpcInterface {
};
try {
const params = this._formatInputs(registry, def, values);
const params = this._formatInputs(registry, null, def, values);
const paramsJson = params.map((param): AnyJson => param.toJSON());
const update = (error?: Error | null, result?: any): void => {
@@ -337,7 +337,7 @@ export class RpcCore implements RpcInterface {
try {
observer.next(
outputAs === 'scale'
? this._formatOutput(registry, method, def, params, result)
? this._formatOutput(registry, null, method, def, params, result)
: registry.createType(outputAs === 'raw' ? 'Raw' : 'Json', result)
);
} catch (error) {
@@ -372,8 +372,8 @@ export class RpcCore implements RpcInterface {
return memoized;
}
private _formatInputs (registry: Registry, def: DefinitionRpc, inputs: any[]): Codec[] {
const reqArgCount = def.params.filter(({ isOptional }): boolean => !isOptional).length;
private _formatInputs (registry: Registry, blockHash: Uint8Array | string | null | undefined, def: DefinitionRpc, inputs: any[]): Codec[] {
const reqArgCount = def.params.filter(({ isOptional }) => !isOptional).length;
const optText = reqArgCount === def.params.length
? ''
: ` (${def.params.length - reqArgCount} optional)`;
@@ -381,25 +381,25 @@ export class RpcCore implements RpcInterface {
assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`);
return inputs.map((input, index): Codec =>
createTypeUnsafe(registry, def.params[index].type, [input])
createTypeUnsafe(registry, def.params[index].type, [input], { blockHash })
);
}
private _formatOutput (registry: Registry, method: string, rpc: DefinitionRpc, params: Codec[], result?: any): Codec | Codec[] {
private _formatOutput (registry: Registry, blockHash: Uint8Array | string | null | undefined, method: string, rpc: DefinitionRpc, params: Codec[], result?: any): Codec | Codec[] {
if (rpc.type === 'StorageData') {
const key = params[0] as StorageKey;
return this._formatStorageData(registry, key, result);
return this._formatStorageData(registry, blockHash, key, result);
} else if (rpc.type === 'StorageChangeSet') {
const keys = params[0] as Vec<StorageKey>;
return keys
? this._formatStorageSet(registry, keys, (result as StorageChangeSetJSON).changes)
? this._formatStorageSet(registry, (result as StorageChangeSetJSON).block, keys, (result as StorageChangeSetJSON).changes)
: registry.createType('StorageChangeSet', result);
} else if (rpc.type === 'Vec<StorageChangeSet>') {
const mapped = (result as StorageChangeSetJSON[]).map(({ block, changes }): [Hash, Codec[]] => [
registry.createType('Hash', block),
this._formatStorageSet(registry, params[0] as Vec<StorageKey>, changes)
this._formatStorageSet(registry, block, params[0] as Vec<StorageKey>, changes)
]);
// we only query at a specific block, not a range - flatten
@@ -408,10 +408,10 @@ export class RpcCore implements RpcInterface {
: mapped as unknown as Codec[];
}
return createTypeUnsafe(registry, rpc.type, [result]);
return createTypeUnsafe(registry, rpc.type, [result], { blockHash });
}
private _formatStorageData (registry: Registry, key: StorageKey, value: string | null): Codec {
private _formatStorageData (registry: Registry, blockHash: Uint8Array | string | null | undefined, key: StorageKey, value: string | null): Codec {
const isEmpty = isNull(value);
// we convert to Uint8Array since it maps to the raw encoding, all
@@ -422,10 +422,10 @@ export class RpcCore implements RpcInterface {
? value
: u8aToU8a(value);
return this._newType(registry, key, input, isEmpty);
return this._newType(registry, blockHash, key, input, isEmpty);
}
private _formatStorageSet (registry: Registry, keys: Vec<StorageKey>, changes: [string, string | null][]): Codec[] {
private _formatStorageSet (registry: Registry, blockHash: string, keys: Vec<StorageKey>, changes: [string, string | null][]): Codec[] {
// For StorageChangeSet, the changes has the [key, value] mappings
const withCache = keys.length !== 1;
@@ -434,13 +434,13 @@ export class RpcCore implements RpcInterface {
// - Codec - There is a valid value, non-empty
// - null - The storage key is empty
return keys.reduce((results: Codec[], key: StorageKey, index): Codec[] => {
results.push(this._formatStorageSetEntry(registry, key, changes, withCache, index));
results.push(this._formatStorageSetEntry(registry, blockHash, key, changes, withCache, index));
return results;
}, []);
}
private _formatStorageSetEntry (registry: Registry, key: StorageKey, changes: [string, string | null][], witCache: boolean, entryIndex: number): Codec {
private _formatStorageSetEntry (registry: Registry, blockHash: string, key: StorageKey, changes: [string, string | null][], witCache: boolean, entryIndex: number): Codec {
const hexKey = key.toHex();
const found = changes.find(([key]) => key === hexKey);
@@ -461,10 +461,10 @@ export class RpcCore implements RpcInterface {
// will increase memory beyond what is allowed.
this.#storageCache.set(hexKey, value);
return this._newType(registry, key, input, isEmpty, entryIndex);
return this._newType(registry, blockHash, key, input, isEmpty, entryIndex);
}
private _newType (registry: Registry, key: StorageKey, input: string | Uint8Array | null, isEmpty: boolean, entryIndex = -1): Codec {
private _newType (registry: Registry, blockHash: Uint8Array | string | null | undefined, key: StorageKey, input: string | Uint8Array | null, isEmpty: boolean, entryIndex = -1): Codec {
// single return value (via state.getStorage), decode the value based on the
// outputType that we have specified. Fallback to Raw on nothing
const type = key.outputType || 'Raw';
@@ -478,13 +478,19 @@ export class RpcCore implements RpcInterface {
if (!isEmpty) {
try {
inner = createTypeUnsafe(registry, type, [input], { isPedantic: true });
inner = createTypeUnsafe(registry, type, [input], { blockHash, isPedantic: true });
} catch (error) {
l.error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}`, (error as Error).message);
}
}
return new Option(registry, createClass(registry, type), inner);
const option = new Option(registry, createClass(registry, type), inner);
if (blockHash) {
option.createdAtHash = registry.createType('Hash', blockHash);
}
return option;
}
try {
@@ -494,11 +500,11 @@ export class RpcCore implements RpcInterface {
? hexToU8a(meta.fallback.toHex())
: undefined
: input
], { isPedantic: true });
], { blockHash, isPedantic: true });
} catch (error) {
l.error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}`, (error as Error).message);
return registry.createType('Raw', input);
return createTypeUnsafe(registry, 'Raw', [input], { blockHash });
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/rpc-core authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-core', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.0.2' };
+13 -12
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/rpc-provider",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Transport providers for the API",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,20 +16,20 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/types": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/util-crypto": "^5.9.2",
"@polkadot/x-fetch": "^5.9.2",
"@polkadot/x-global": "^5.9.2",
"@polkadot/x-ws": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"@polkadot/x-fetch": "^6.0.5",
"@polkadot/x-global": "^6.0.5",
"@polkadot/x-ws": "^6.0.5",
"bn.js": "^4.11.9",
"eventemitter3": "^4.0.7"
},
"devDependencies": {
"@polkadot/keyring": "^5.9.2",
"@polkadot/metadata": "3.11.1",
"@polkadot/keyring": "^6.0.5",
"@polkadot/metadata": "4.0.2",
"mock-socket": "^9.0.3",
"nock": "^13.0.9"
"nock": "^13.0.10"
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/rpc-provider', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.0.2' };
+15 -14
View File
@@ -1,18 +1,19 @@
{
"name": "@polkadot/typegen",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Type generation scripts",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"bin": {
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.js",
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.js",
"polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.js",
"polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.js",
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.js"
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
"polkadot-types-from-chain": "./scripts/polkadot-types-from-chain.cjs",
"polkadot-types-from-defs": "./scripts/polkadot-types-from-defs.cjs",
"polkadot-types-internal-interfaces": "./scripts/polkadot-types-internal-interfaces.cjs",
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
},
"repository": "github:polkadot-js/api",
"author": "Jaco Greeff <jacogr@gmail.com>",
@@ -24,18 +25,18 @@
"dependencies": {
"@babel/core": "^7.13.8",
"@babel/register": "^7.13.8",
"@babel/runtime": "^7.13.8",
"@polkadot/api": "3.11.1",
"@polkadot/metadata": "3.11.1",
"@polkadot/rpc-provider": "3.11.1",
"@polkadot/types": "3.11.1",
"@polkadot/util": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/api": "4.0.2",
"@polkadot/metadata": "4.0.2",
"@polkadot/rpc-provider": "4.0.2",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"handlebars": "^4.7.7",
"websocket": "^1.0.33",
"yargs": "^16.2.0"
},
"devDependencies": {
"@types/websocket": "^1.0.1",
"@types/websocket": "^1.0.2",
"@types/yargs": "^16.0.0"
}
}
@@ -7,8 +7,10 @@
let main;
try {
main = require('../extractChain').main;
main = require('../extractChain.cjs').main;
} catch (error) {
process.env.JEST_WORKER_ID = '123';
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
@@ -7,8 +7,10 @@
let main;
try {
main = require('../fromChain').main;
main = require('../fromChain.cjs').main;
} catch (error) {
process.env.JEST_WORKER_ID = '123';
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
@@ -7,8 +7,10 @@
let main;
try {
main = require('../fromDefs').main;
main = require('../fromDefs.cjs').main;
} catch (error) {
process.env.JEST_WORKER_ID = '123';
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
@@ -7,8 +7,10 @@
let main;
try {
main = require('../interfacesTs').main;
main = require('../interfacesTs.cjs').main;
} catch (error) {
process.env.JEST_WORKER_ID = '123';
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
@@ -7,8 +7,10 @@
let main;
try {
main = require('../metadataMd').main;
main = require('../metadataMd.cjs').main;
} catch (error) {
process.env.JEST_WORKER_ID = '123';
require('@babel/register')({
extensions: ['.js', '.ts'],
plugins: [
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/typegen authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/typegen', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/typegen', version: '4.0.2' };
+7 -6
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/types-known",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,10 +16,10 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/networks": "^5.9.2",
"@polkadot/types": "3.11.1",
"@polkadot/util": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/networks": "^6.0.5",
"@polkadot/types": "4.0.2",
"@polkadot/util": "^6.0.5",
"bn.js": "^4.11.9"
},
"devDependencies": {
+3
View File
@@ -17,6 +17,9 @@ const typesModules: Record<string, OverrideModuleType> = {
contracts: {
StorageKey: 'ContractStorageKey'
},
electionProviderMultiPhase: {
Phase: 'ElectionPhase'
},
ethereum: {
Block: 'EthBlock',
Header: 'EthHeader',
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/types-known authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types-known', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/types-known', version: '4.0.2' };
+4 -12
View File
@@ -6,7 +6,7 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
AccountInfo: 'AccountInfoWithProviders',
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
Keys: 'SessionKeys6',
LookupSource: 'MultiAddress',
@@ -47,7 +47,6 @@ const versioned: OverrideVersionedType[] = [
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
ReferendumInfo: 'ReferendumInfoTo239',
RewardDestination: 'RewardDestinationTo257',
SlashingSpans: 'SlashingSpansTo204',
StakingLedger: 'StakingLedgerTo223',
Votes: 'VotesTo230',
@@ -66,7 +65,6 @@ const versioned: OverrideVersionedType[] = [
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
ReferendumInfo: 'ReferendumInfoTo239',
RewardDestination: 'RewardDestinationTo257',
SlashingSpans: 'SlashingSpansTo204',
StakingLedger: 'StakingLedgerTo223',
Votes: 'VotesTo230',
@@ -86,7 +84,6 @@ const versioned: OverrideVersionedType[] = [
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
ReferendumInfo: 'ReferendumInfoTo239',
RewardDestination: 'RewardDestinationTo257',
StakingLedger: 'StakingLedgerTo223',
Votes: 'VotesTo230',
Weight: 'u32'
@@ -104,7 +101,6 @@ const versioned: OverrideVersionedType[] = [
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
ReferendumInfo: 'ReferendumInfoTo239',
RewardDestination: 'RewardDestinationTo257',
StakingLedger: 'StakingLedgerTo240',
Weight: 'u32'
}
@@ -119,7 +115,6 @@ const versioned: OverrideVersionedType[] = [
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257',
StakingLedger: 'StakingLedgerTo240',
Weight: 'u32'
}
@@ -132,8 +127,7 @@ const versioned: OverrideVersionedType[] = [
CompactAssignments: 'CompactAssignmentsTo257',
DispatchInfo: 'DispatchInfoTo244',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
@@ -143,8 +137,7 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
@@ -153,8 +146,7 @@ const versioned: OverrideVersionedType[] = [
...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
+1 -1
View File
@@ -18,7 +18,7 @@ const versioned: OverrideVersionedType[] = [
{
minmax: [261, undefined],
types: {
AccountInfo: 'AccountInfoWithProviders',
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
LookupSource: 'MultiAddress'
}
+3 -5
View File
@@ -6,7 +6,7 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
AccountInfo: 'AccountInfoWithProviders',
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
Keys: 'SessionKeys6',
LookupSource: 'MultiAddress',
@@ -41,8 +41,7 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
@@ -51,8 +50,7 @@ const versioned: OverrideVersionedType[] = [
...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
+1 -1
View File
@@ -9,7 +9,7 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
/* eslint-disable sort-keys */
const sharedTypes = {
AccountInfo: 'AccountInfoWithProviders',
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
FullIdentification: '()', // No staking, only session (as per config)
LookupSource: 'MultiAddress',
+3 -6
View File
@@ -6,7 +6,7 @@
import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = {
AccountInfo: 'AccountInfoWithProviders',
AccountInfo: 'AccountInfoWithDualRefCount',
Address: 'MultiAddress',
Keys: 'SessionKeys6',
LookupSource: 'MultiAddress',
@@ -35,7 +35,6 @@ const versioned: OverrideVersionedType[] = [
Multiplier: 'Fixed64',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257',
Weight: 'u32'
}
},
@@ -46,8 +45,7 @@ const versioned: OverrideVersionedType[] = [
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
OpenTip: 'OpenTipTo225',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
@@ -56,8 +54,7 @@ const versioned: OverrideVersionedType[] = [
...sharedTypes,
...addrAccountIdTypes,
CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257'
RefCount: 'RefCountTo259'
}
},
{
+1 -1
View File
@@ -8,7 +8,7 @@ const upgrades: ChainUpgradesRaw = [
[879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29],
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48]
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49]
];
export default upgrades;
+9 -8
View File
@@ -1,11 +1,12 @@
{
"name": "@polkadot/types",
"version": "3.11.1",
"version": "4.0.2",
"type": "module",
"description": "Implementation of the Parity codec",
"main": "index.js",
"sideEffects": [
"./detectPackage.js",
"./detectPackage.mjs"
"./detectPackage.cjs"
],
"author": "Jaco Greeff <jacogr@gmail.com>",
"maintainers": [],
@@ -15,15 +16,15 @@
"bugs": "https://github.com/polkadot-js/api/issues",
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.13.8",
"@polkadot/metadata": "3.11.1",
"@polkadot/util": "^5.9.2",
"@polkadot/util-crypto": "^5.9.2",
"@polkadot/x-rxjs": "^5.9.2",
"@babel/runtime": "^7.13.9",
"@polkadot/metadata": "4.0.2",
"@polkadot/util": "^6.0.5",
"@polkadot/util-crypto": "^6.0.5",
"@polkadot/x-rxjs": "^6.0.5",
"@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9"
},
"devDependencies": {
"@polkadot/keyring": "^5.9.2"
"@polkadot/keyring": "^6.0.5"
}
}
+11 -5
View File
@@ -44,10 +44,10 @@ import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
import type { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9, ValidatorCount } from '@polkadot/types/interfaces/session';
import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardDestinationTo257, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
import type { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
import type { AccountInfo, AccountInfoWithProviders, AccountInfoWithRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
@@ -152,8 +152,10 @@ declare module '@polkadot/types/types/registry' {
'Option<AccountIndex>': Option<AccountIndex>;
'Option<AccountIndex64Junction>': Option<AccountIndex64Junction>;
'Option<AccountInfo>': Option<AccountInfo>;
'Option<AccountInfoWithDualRefCount>': Option<AccountInfoWithDualRefCount>;
'Option<AccountInfoWithProviders>': Option<AccountInfoWithProviders>;
'Option<AccountInfoWithRefCount>': Option<AccountInfoWithRefCount>;
'Option<AccountInfoWithTripleRefCount>': Option<AccountInfoWithTripleRefCount>;
'Option<AccountKey20Junction>': Option<AccountKey20Junction>;
'Option<AccountStatus>': Option<AccountStatus>;
'Option<AccountValidity>': Option<AccountValidity>;
@@ -323,6 +325,7 @@ declare module '@polkadot/types/types/registry' {
'Option<EcdsaSignature>': Option<EcdsaSignature>;
'Option<Ed25519Signature>': Option<Ed25519Signature>;
'Option<ElectionCompute>': Option<ElectionCompute>;
'Option<ElectionPhase>': Option<ElectionPhase>;
'Option<ElectionResult>': Option<ElectionResult>;
'Option<ElectionScore>': Option<ElectionScore>;
'Option<ElectionSize>': Option<ElectionSize>;
@@ -687,7 +690,6 @@ declare module '@polkadot/types/types/registry' {
'Option<ReserveAssetDeposit>': Option<ReserveAssetDeposit>;
'Option<Retriable>': Option<Retriable>;
'Option<RewardDestination>': Option<RewardDestination>;
'Option<RewardDestinationTo257>': Option<RewardDestinationTo257>;
'Option<RewardPoint>': Option<RewardPoint>;
'Option<RoundSnapshot>': Option<RoundSnapshot>;
'Option<RoundState>': Option<RoundState>;
@@ -896,8 +898,10 @@ declare module '@polkadot/types/types/registry' {
'Vec<AccountIndex>': Vec<AccountIndex>;
'Vec<AccountIndex64Junction>': Vec<AccountIndex64Junction>;
'Vec<AccountInfo>': Vec<AccountInfo>;
'Vec<AccountInfoWithDualRefCount>': Vec<AccountInfoWithDualRefCount>;
'Vec<AccountInfoWithProviders>': Vec<AccountInfoWithProviders>;
'Vec<AccountInfoWithRefCount>': Vec<AccountInfoWithRefCount>;
'Vec<AccountInfoWithTripleRefCount>': Vec<AccountInfoWithTripleRefCount>;
'Vec<AccountKey20Junction>': Vec<AccountKey20Junction>;
'Vec<AccountStatus>': Vec<AccountStatus>;
'Vec<AccountValidity>': Vec<AccountValidity>;
@@ -1067,6 +1071,7 @@ declare module '@polkadot/types/types/registry' {
'Vec<EcdsaSignature>': Vec<EcdsaSignature>;
'Vec<Ed25519Signature>': Vec<Ed25519Signature>;
'Vec<ElectionCompute>': Vec<ElectionCompute>;
'Vec<ElectionPhase>': Vec<ElectionPhase>;
'Vec<ElectionResult>': Vec<ElectionResult>;
'Vec<ElectionScore>': Vec<ElectionScore>;
'Vec<ElectionSize>': Vec<ElectionSize>;
@@ -1431,7 +1436,6 @@ declare module '@polkadot/types/types/registry' {
'Vec<ReserveAssetDeposit>': Vec<ReserveAssetDeposit>;
'Vec<Retriable>': Vec<Retriable>;
'Vec<RewardDestination>': Vec<RewardDestination>;
'Vec<RewardDestinationTo257>': Vec<RewardDestinationTo257>;
'Vec<RewardPoint>': Vec<RewardPoint>;
'Vec<RoundSnapshot>': Vec<RoundSnapshot>;
'Vec<RoundState>': Vec<RoundState>;
@@ -1640,8 +1644,10 @@ declare module '@polkadot/types/types/registry' {
AccountIndex: AccountIndex;
AccountIndex64Junction: AccountIndex64Junction;
AccountInfo: AccountInfo;
AccountInfoWithDualRefCount: AccountInfoWithDualRefCount;
AccountInfoWithProviders: AccountInfoWithProviders;
AccountInfoWithRefCount: AccountInfoWithRefCount;
AccountInfoWithTripleRefCount: AccountInfoWithTripleRefCount;
AccountKey20Junction: AccountKey20Junction;
AccountStatus: AccountStatus;
AccountValidity: AccountValidity;
@@ -1811,6 +1817,7 @@ declare module '@polkadot/types/types/registry' {
EcdsaSignature: EcdsaSignature;
Ed25519Signature: Ed25519Signature;
ElectionCompute: ElectionCompute;
ElectionPhase: ElectionPhase;
ElectionResult: ElectionResult;
ElectionScore: ElectionScore;
ElectionSize: ElectionSize;
@@ -2175,7 +2182,6 @@ declare module '@polkadot/types/types/registry' {
ReserveAssetDeposit: ReserveAssetDeposit;
Retriable: Retriable;
RewardDestination: RewardDestination;
RewardDestinationTo257: RewardDestinationTo257;
RewardPoint: RewardPoint;
RoundSnapshot: RoundSnapshot;
RoundState: RoundState;
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, Codec, Registry } from '../types';
import { compactToU8a, u8aConcat, u8aToHex } from '@polkadot/util';
@@ -18,6 +18,8 @@ import { compareArray } from './utils';
export abstract class AbstractArray<T extends Codec> extends Array<T> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
protected constructor (registry: Registry, ...values: T[]) {
super(...values);
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyNumber, Codec, Registry } from '../types';
import type { UIntBitLength } from './types';
@@ -67,6 +67,8 @@ function decodeAbstractInt (value: AnyNumber, bitLength: UIntBitLength, isNegati
export abstract class AbstractInt extends BN implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #bitLength: UIntBitLength;
readonly #isSigned: boolean;
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { compactFromU8a, compactToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
@@ -79,6 +79,8 @@ function decodeSet<V extends Codec = Codec> (registry: Registry, valType: Constr
export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #ValClass: Constructor<V>;
constructor (registry: Registry, valType: Constructor<V> | keyof InterfaceTypes, rawValue?: Uint8Array | string | string[] | Set<any>) {
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, BareOpts, Codec, Registry } from '../types';
/**
@@ -11,6 +11,8 @@ import type { AnyJson, BareOpts, Codec, Registry } from '../types';
export abstract class Base<T extends Codec> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
protected readonly _raw: T;
protected constructor (registry: Registry, value: T) {
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces';
import type { CodecHash, Hash } from '../interfaces';
import type { AnyJson, AnyNumber, Constructor, ICompact, InterfaceTypes, Registry } from '../types';
import type { CompactEncodable, UIntBitLength } from './types';
@@ -22,6 +22,8 @@ import { typeToConstructor } from './utils';
export class Compact<T extends CompactEncodable> implements ICompact<T> {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #Type: Constructor<T>;
readonly #raw: T;
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyNumber, Codec, Registry } from '../types';
import type { UIntBitLength } from './types';
@@ -24,6 +24,8 @@ const BITLENGTH: UIntBitLength = 64;
export class CodecDate extends Date implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
constructor (registry: Registry, value: CodecDate | Date | AnyNumber = 0) {
super(CodecDate.decodeDate(value));
+4 -4
View File
@@ -30,7 +30,7 @@ describe('Enum', (): void => {
{ Text, U32 },
new Uint8Array([1, 2 << 2, 49, 50])
).toString()
).toEqual('{"U32":3289352}');
).toEqual('{"u32":3289352}');
});
it('decodes from a JSON input (lowercase)', (): void => {
@@ -43,7 +43,7 @@ describe('Enum', (): void => {
).toEqual('some text value');
});
it('decodes reusing instanciated inputs', (): void => {
it('decodes reusing instantiated inputs', (): void => {
const foo = new Text(registry, 'bar');
expect(
@@ -144,8 +144,8 @@ describe('Enum', (): void => {
class C extends Null { }
const Test = Enum.with({ A, B, C });
expect(new Test(registry).toJSON()).toEqual({ A: null });
expect(new Test(registry, 1234, 1).toJSON()).toEqual({ B: 1234 });
expect(new Test(registry).toJSON()).toEqual({ a: null });
expect(new Test(registry, 1234, 1).toJSON()).toEqual({ b: 1234 });
expect(new Test(registry, 0x1234, 1).toU8a()).toEqual(new Uint8Array([1, 0x34, 0x12, 0x00, 0x00]));
expect(new Test(registry, 0x1234, 1).toU8a(true)).toEqual(new Uint8Array([0x34, 0x12, 0x00, 0x00]));
});
+5 -3
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces';
import type { CodecHash, Hash } from '../interfaces';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util';
@@ -99,7 +99,7 @@ function createFromValue (registry: Registry, def: TypesDef, index = 0, value?:
}
function decodeFromJSON (registry: Registry, def: TypesDef, key: string, value?: any): Decoded {
// JSON comes in the form of { "<type (lowercased)>": "<value for type>" }, here we
// JSON comes in the form of { "<type (camelCase)>": "<value for type>" }, here we
// additionally force to lower to ensure forward compat
const keys = Object.keys(def).map((k) => k.toLowerCase());
const keyLower = key.toLowerCase();
@@ -166,6 +166,8 @@ function decodeEnum (registry: Registry, def: TypesDef, value?: any, index?: num
export class Enum implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #def: TypesDef;
readonly #entryIndex: number;
@@ -343,7 +345,7 @@ export class Enum implements Codec {
public toJSON (): AnyJson {
return this.#isBasic
? this.type
: { [this.type]: this.#raw.toJSON() };
: { [stringCamelCase(this.type)]: this.#raw.toJSON() };
}
/**
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, Codec, Registry } from '../types';
import { isFunction, isUndefined } from '@polkadot/util';
@@ -24,6 +24,8 @@ function decodeJson (value?: Record<string, unknown> | null): [string, any][] {
export class Json extends Map<string, any> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
constructor (registry: Registry, value?: Record<string, unknown> | null) {
const decoded = decodeJson(value);
+2 -2
View File
@@ -14,7 +14,7 @@ describe('Linkage', (): void => {
// prefs sanity check
expect(
registry.createType(
'ValidatorPrefs',
'ValidatorPrefsWithCommission',
'0x0284d717'
).toHuman()
).toEqual(PREFS);
@@ -33,7 +33,7 @@ describe('Linkage', (): void => {
// actual check
expect(
registry.createType(
'(ValidatorPrefs, Linkage<AccountId>)' as 'u32',
'(ValidatorPrefsWithCommission, Linkage<AccountId>)' as 'u32',
'0x0284d7170001da30b68f54f686f586ddb29de12b682dd8bd1404566fb8a8db5dec20aa5b6b36'
).toHuman()
).toEqual([PREFS, LINKA]);
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
@@ -88,6 +88,8 @@ function decodeMap<K extends Codec = Codec, V extends Codec = Codec> (registry:
export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends Map<K, V> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #KeyClass: Constructor<K>;
readonly #ValClass: Constructor<V>;
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces';
import type { CodecHash, Hash } from '../interfaces';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { assert, isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
@@ -50,6 +50,8 @@ function decodeOption (registry: Registry, typeName: Constructor | keyof Interfa
export class Option<T extends Codec> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #Type: Constructor<T>;
readonly #raw: T;
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, AnyU8a, IU8a, Registry } from '../types';
import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
@@ -18,6 +18,8 @@ import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a }
export class Raw extends Uint8Array implements IU8a {
public readonly registry: Registry;
public createdAtHash?: Hash;
constructor (registry: Registry, value?: AnyU8a) {
super(u8aToU8a(value));
+2 -2
View File
@@ -22,7 +22,7 @@ describe('Result', (): void => {
expect(result.asOk.toU8a()).toEqual(new Uint8Array([1, 2, 3, 4]));
expect(result.toHex()).toEqual('0x0001020304');
expect(result.toJSON()).toEqual({
Ok: 0x04030201
ok: 0x04030201
});
});
@@ -33,7 +33,7 @@ describe('Result', (): void => {
expect(result.asErr.toU8a()).toEqual(new Uint8Array([4 << 2, 100, 101, 102, 103]));
expect(result.toHex()).toEqual('0x011064656667');
expect(result.toJSON()).toEqual({
Err: hexToString('0x64656667')
err: hexToString('0x64656667')
});
});
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { Codec, Constructor, Registry } from '../types';
import BN from 'bn.js';
@@ -80,6 +80,8 @@ function decodeSet (setValues: SetValues, value: string[] | Set<string> | Uint8A
export class CodecSet extends Set<string> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #allowed: SetValues;
readonly #byteLength: number;
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyJson, BareOpts, Codec, Constructor, ConstructorDef, InterfaceTypes, Registry } from '../types';
import { hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, stringCamelCase, u8aConcat, u8aToHex } from '@polkadot/util';
@@ -135,6 +135,8 @@ export class Struct<
E extends { [K in keyof S]: string } = { [K in keyof S]: string }> extends Map<keyof S, Codec> implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
readonly #jsonMap: Map<keyof S, string>;
readonly #Types: ConstructorDef;
+2 -2
View File
@@ -60,7 +60,7 @@ describe('createType', (): void => {
it('allows creation of a Enum (with types)', (): void => {
expect(
createTypeUnsafe(registry, '{"_enum": {"A": null, "B": "u32", "C": null} }', [1]).toJSON()
).toEqual({ B: 0 });
).toEqual({ b: 0 });
});
it('allows creation of a Enum (with indexes)', (): void => {
@@ -72,7 +72,7 @@ describe('createType', (): void => {
it('allows creation of a Result', (): void => {
expect(
createTypeUnsafe(registry, 'Result<u32,Text>', ['0x011064656667']).toJSON()
).toEqual({ Err: 'defg' });
).toEqual({ err: 'defg' });
});
it('allows creation of a Set', (): void => {
+34 -34
View File
@@ -4,72 +4,72 @@
import type { Codec, Constructor, InterfaceTypes, Registry } from '../types';
import type { FromReg } from './types';
import { isU8a, logger, u8aToHex } from '@polkadot/util';
import { logger } from '@polkadot/util';
import { createClass } from './createClass';
interface UnsafeOptions {
interface CreateOptions {
blockHash?: Uint8Array | string | null;
isPedantic?: boolean;
withoutLog?: boolean;
}
const l = logger('registry');
function u8aHasValue (value: Uint8Array): boolean {
return value.some((v): boolean => !!v);
}
// TODO: Fix and re-enable
// With isPedantic, actually check that the encoding matches that supplied. This
// is much slower, but verifies that we have the correct types defined
function checkInstance<T extends Codec = Codec, K extends string = string> (value: Uint8Array, created: FromReg<T, K>): void {
// the underlying type created.toRawType()
const rawType = created.toRawType();
// function checkInstance<T extends Codec = Codec, K extends string = string> (value: Uint8Array, created: FromReg<T, K>): void {
// // the underlying type created.toRawType()
// const rawType = created.toRawType();
// ignore bytes completely - this is probably a FIXME, since these are somewhat
// breaking for at least online queries - not quite sure wtf is going wrong here
if (rawType === 'Bytes') {
return;
}
// // ignore bytes completely - this is probably a FIXME, since these are somewhat
// // breaking for at least online queries - not quite sure wtf is going wrong here
// if (rawType === 'Bytes') {
// return;
// }
// the hex values for what we have
const inHex = u8aToHex(value);
const crHex = created.toHex();
// // the hex values for what we have
// const inHex = u8aToHex(value);
// const crHex = created.toHex();
// Check equality, based on some different approaches (as decoded)
const isEqual = inHex === crHex || // raw hex values, quick path
inHex === created.toHex(true) || // wrapped options
u8aToHex(value.reverse()) === crHex; // reverse (for numbers, which are BE)
// // Check equality, based on some different approaches (as decoded)
// const isEqual = inHex === crHex || // raw hex values, quick path
// inHex === created.toHex(true) || // wrapped options
// u8aToHex(value.reverse()) === crHex; // reverse (for numbers, which are BE)
// if the hex doesn't match and the value for both is non-empty, complain... bitterly
if (!isEqual && (u8aHasValue(value) || u8aHasValue(created.toU8a(true)))) {
l.warn(`${rawType}:: Input doesn't match output, received ${u8aToHex(value)}, created ${crHex}`);
}
}
// // if the hex doesn't match and the value for both is non-empty, complain... bitterly
// if (!isEqual && (u8aHasValue(value) || u8aHasValue(created.toU8a(true)))) {
// l.warn(`${rawType}:: Input doesn't match output, received ${u8aToHex(value)}, created ${crHex}`);
// }
// }
// Initializes a type with a value. This also checks for fallbacks and in the cases
// where isPedantic is specified (storage decoding), also check the format/structure
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor<FromReg<T, K>>, params: any[] = [], isPedantic?: boolean): FromReg<T, K> {
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor<FromReg<T, K>>, params: any[] = [], { blockHash }: CreateOptions = {}): FromReg<T, K> {
const created = new Type(registry, ...params);
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const [value] = params;
if (isPedantic && isU8a(value)) {
checkInstance(value, created);
if (blockHash) {
created.createdAtHash = createType(registry, 'Hash', blockHash);
}
// if (isPedantic && isU8a(value)) {
// checkInstance(value, created);
// }
return created;
}
// An unsafe version of the `createType` below. It's unsafe because the `type`
// argument here can be any string, which, when it cannot parse, will yield a
// runtime error.
export function createTypeUnsafe<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, params: any[] = [], { withoutLog }: UnsafeOptions = {}): T {
export function createTypeUnsafe<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, params: any[] = [], options: CreateOptions = {}): T {
try {
// Circle back to isPedantic when it handles all cases 100% - as of now,
// it provides false warning which is more hinderance than help
return initType(registry, createClass<T, K>(registry, type), params); // , isPedantic);
return initType(registry, createClass<T, K>(registry, type), params, options);
} catch (error) {
!withoutLog && l.error(error);
!options.withoutLog && l.error(error);
throw new Error(`createType(${type}):: ${(error as Error).message}`);
}
+12 -2
View File
@@ -4,7 +4,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { ChainProperties, CodecHash, DispatchErrorModule } from '../interfaces/types';
import type { ChainProperties, CodecHash, DispatchErrorModule, Hash } from '../interfaces/types';
import type { CallFunction, Codec, CodecHasher, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
// we are attempting to avoid circular refs, hence the Metadata path import
@@ -136,11 +136,17 @@ export class TypeRegistry implements Registry {
#userExtensions?: ExtDef;
constructor () {
public createdAtHash?: Hash;
constructor (createdAtHash?: Hash | Uint8Array | string) {
this.#knownDefaults = { Json, Metadata, Raw, ...baseTypes };
this.#knownDefinitions = definitions as unknown as Record<string, { types: RegistryTypes }>;
this.init();
if (createdAtHash) {
this.createdAtHash = this.createType('Hash', createdAtHash);
}
}
public init (): this {
@@ -193,6 +199,10 @@ export class TypeRegistry implements Registry {
return this.#knownTypes;
}
public get unknownTypes (): string[] {
return [...this.#unknownTypes.keys()];
}
public get signedExtensions (): string[] {
return this.#signedExtensions;
}
@@ -11,7 +11,7 @@ describe('ExtrinsicEra', (): void => {
const extrinsicEra = new ExtrinsicEra(registry, new Uint8Array([0]));
expect(extrinsicEra.asImmortalEra).toBeDefined();
expect(extrinsicEra.toJSON()).toEqual({ ImmortalEra: '0x00' });
expect(extrinsicEra.toJSON()).toEqual({ immortalEra: '0x00' });
});
it('decodes an Extrinsic Era from u8 as mortal', (): void => {
@@ -35,13 +35,13 @@ describe('ExtrinsicEra', (): void => {
expect(extrinsicEra.asMortalEra.phase.toNumber()).toEqual(120);
});
it('serializes and de-serializes from JSON', (): void => {
it.only('serializes and de-serializes from JSON', (): void => {
const extrinsicEra = new ExtrinsicEra(registry, new Uint8Array([78, 156]));
const u8a = extrinsicEra.toU8a();
const json = extrinsicEra.toJSON();
expect(u8a).toEqual(new Uint8Array([78, 156]));
expect(json).toEqual({ MortalEra: '0x4e9c' });
expect(json).toEqual({ mortalEra: '0x4e9c' });
expect(new ExtrinsicEra(registry, json).toU8a()).toEqual(u8a);
});
+8 -4
View File
@@ -218,11 +218,15 @@ export class GenericExtrinsicEra extends Enum implements IExtrinsicEra {
? new Uint8Array([0])
: new Uint8Array([1, value[0], value[1]]);
} else if (isObject(value)) {
const entries = Object.entries(value as MortalEnumDef).map(([k, v]): [string, any] => [k.toLowerCase(), v]);
const mortal = entries.find(([k]) => k.toLowerCase() === 'mortalera');
const immortal = entries.find(([k]) => k.toLowerCase() === 'immortalera');
// this is to de-serialize from JSON
return (value as MortalEnumDef).MortalEra
? { MortalEra: (value as MortalEnumDef).MortalEra }
: (value as ImmortalEnumDef).ImmortalEra
? { ImmortalEra: (value as ImmortalEnumDef).ImmortalEra }
return mortal
? { MortalEra: mortal[1] as string }
: immortal
? { ImmortalEra: immortal[1] as string }
: { MortalEra: value };
}
@@ -126,7 +126,10 @@ export default {
license: 'Option<Text>'
},
ContractProjectSource: {
hash: '[u8; 32]',
_alias: {
wasmHash: 'hash'
},
wasmHash: '[u8; 32]',
language: 'Text',
compiler: 'Text',
wasm: 'Raw'
@@ -136,7 +136,7 @@ export interface ContractProjectContract extends Struct {
/** @name ContractProjectSource */
export interface ContractProjectSource extends Struct {
readonly hash: U8aFixed;
readonly wasmHash: U8aFixed;
readonly language: Text;
readonly compiler: Text;
readonly wasm: Raw;
@@ -20,14 +20,14 @@ describe('Registration', (): void => {
deposit: 10000000000000, // '0x0000000000000000000009184e72a000',
info: {
additional: [],
display: { Raw: '0x9911' },
email: { Raw: '0x9933' },
image: { None: null },
legal: { Raw: '0x9922' },
display: { raw: '0x9911' },
email: { raw: '0x9933' },
image: { none: null },
legal: { raw: '0x9922' },
pgpFingerprint: null,
riot: { Raw: '0x9955' },
twitter: { Raw: '0x9966' },
web: { Raw: '0x9944' }
riot: { raw: '0x9955' },
twitter: { raw: '0x9966' },
web: { raw: '0x9944' }
},
judgements: []
});
@@ -0,0 +1,19 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { TypeRegistry } from '../../create';
describe('offchain definitions', (): void => {
const registry = new TypeRegistry();
describe('StorageKind', (): void => {
it('has the correct indexes', (): void => {
expect(registry.createType('StorageKind').index).toEqual(1);
expect(registry.createType('StorageKind', 'LOCAL').index).toEqual(2);
});
it('has a correct JSON for the type', (): void => {
expect(registry.createType('StorageKind').toJSON()).toEqual('PERSISTENT');
});
});
});
@@ -54,7 +54,16 @@ const phragmen = {
CompactScore: '(ValidatorIndex, OffchainAccuracy)',
CompactScoreCompact: '(ValidatorIndexCompact, OffchainAccuracyCompact)',
ElectionCompute: {
_enum: ['OnChain', 'Signed', 'Authority']
// in previous versions the last entry was "AuthorityId"
// (since no data attached, and it is via SCALE can rename)
_enum: ['OnChain', 'Signed', 'Unsigned']
},
ElectionPhase: {
_enum: {
Off: null,
Signed: null,
Unsigned: '(bool, BlockNumber)'
}
},
ElectionResult: {
compute: 'ElectionCompute',
@@ -166,13 +175,6 @@ export default {
Account: 'AccountId'
}
},
RewardDestinationTo257: {
_enum: [
'Staked',
'Stash',
'Controller'
]
},
RewardPoint: 'u32',
SlashJournalEntry: {
who: 'AccountId',
@@ -229,7 +231,7 @@ export default {
},
ValidatorIndex: 'u16',
ValidatorIndexCompact: 'Compact<ValidatorIndex>',
ValidatorPrefs: 'ValidatorPrefsWithCommission',
ValidatorPrefs: 'ValidatorPrefsWithBlocked',
ValidatorPrefsWithCommission: {
commission: 'Compact<Perbill>'
},
+10 -9
View File
@@ -61,7 +61,15 @@ export interface CompactScoreCompact extends ITuple<[ValidatorIndexCompact, Offc
export interface ElectionCompute extends Enum {
readonly isOnChain: boolean;
readonly isSigned: boolean;
readonly isAuthority: boolean;
readonly isUnsigned: boolean;
}
/** @name ElectionPhase */
export interface ElectionPhase extends Enum {
readonly isOff: boolean;
readonly isSigned: boolean;
readonly isUnsigned: boolean;
readonly asUnsigned: ITuple<[bool, BlockNumber]>;
}
/** @name ElectionResult */
@@ -187,13 +195,6 @@ export interface RewardDestination extends Enum {
readonly asAccount: AccountId;
}
/** @name RewardDestinationTo257 */
export interface RewardDestinationTo257 extends Enum {
readonly isStaked: boolean;
readonly isStash: boolean;
readonly isController: boolean;
}
/** @name RewardPoint */
export interface RewardPoint extends u32 {}
@@ -307,7 +308,7 @@ export interface ValidatorIndex extends u16 {}
export interface ValidatorIndexCompact extends Compact<ValidatorIndex> {}
/** @name ValidatorPrefs */
export interface ValidatorPrefs extends ValidatorPrefsWithCommission {}
export interface ValidatorPrefs extends ValidatorPrefsWithBlocked {}
/** @name ValidatorPrefsTo145 */
export interface ValidatorPrefsTo145 extends Struct {
@@ -140,12 +140,21 @@ export default {
refcount: 'RefCount',
data: 'AccountData'
},
AccountInfoWithProviders: {
AccountInfoWithDualRefCount: {
nonce: 'Index',
consumers: 'RefCount',
providers: 'RefCount',
data: 'AccountData'
},
// original naming
AccountInfoWithProviders: 'AccountInfoWithDualRefCount',
AccountInfoWithTripleRefCount: {
nonce: 'Index',
consumers: 'RefCount',
providers: 'RefCount',
sufficients: 'RefCount',
data: 'AccountData'
},
ApplyExtrinsicResult: 'Result<DispatchOutcome, TransactionValidityError>',
BlockLength: {
max: 'PerDispatchClassU32'
+14 -2
View File
@@ -9,14 +9,17 @@ import type { AccountId, BlockNumber, Digest, Hash, Index, Pays, Weight } from '
/** @name AccountInfo */
export interface AccountInfo extends AccountInfoWithRefCount {}
/** @name AccountInfoWithProviders */
export interface AccountInfoWithProviders extends Struct {
/** @name AccountInfoWithDualRefCount */
export interface AccountInfoWithDualRefCount extends Struct {
readonly nonce: Index;
readonly consumers: RefCount;
readonly providers: RefCount;
readonly data: AccountData;
}
/** @name AccountInfoWithProviders */
export interface AccountInfoWithProviders extends AccountInfoWithDualRefCount {}
/** @name AccountInfoWithRefCount */
export interface AccountInfoWithRefCount extends Struct {
readonly nonce: Index;
@@ -24,6 +27,15 @@ export interface AccountInfoWithRefCount extends Struct {
readonly data: AccountData;
}
/** @name AccountInfoWithTripleRefCount */
export interface AccountInfoWithTripleRefCount extends Struct {
readonly nonce: Index;
readonly consumers: RefCount;
readonly providers: RefCount;
readonly sufficients: RefCount;
readonly data: AccountData;
}
/** @name ApplyExtrinsicResult */
export interface ApplyExtrinsicResult extends Result<DispatchOutcome, TransactionValidityError> {
readonly isErr: boolean;
+2 -2
View File
@@ -1,6 +1,6 @@
// Copyright 2017-2021 @polkadot/dev authors & contributors
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Auto-generated by @polkadot/dev, do not edit
export const packageInfo = { name: '@polkadot/types', version: '3.11.1' };
export const packageInfo = { name: '@polkadot/types', version: '4.0.2' };
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { Codec, Registry } from '../types';
import { isU8a, u8aToHex } from '@polkadot/util';
@@ -26,6 +26,8 @@ function decodeBool (value: any): boolean {
export class bool extends Boolean implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
// eslint-disable-next-line @typescript-eslint/ban-types
constructor (registry: Registry, value: bool | Boolean | Uint8Array | boolean | number = false) {
super(decodeBool(value));
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { Codec, Registry } from '../types';
import { isNull } from '@polkadot/util';
@@ -14,6 +14,8 @@ import { isNull } from '@polkadot/util';
export class Null implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
constructor (registry: Registry) {
this.registry = registry;
}
+3 -1
View File
@@ -1,7 +1,7 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { AnyU8a, Codec, Registry } from '../types';
import { assert, compactAddLength, compactFromU8a, hexToU8a, isHex, isString, stringToU8a, u8aToHex, u8aToString } from '@polkadot/util';
@@ -50,6 +50,8 @@ function decodeText (value?: null | Text | string | AnyU8a | { toString: () => s
export class Text extends String implements Codec {
public readonly registry: Registry;
public createdAtHash?: Hash;
#override: string | null = null;
constructor (registry: Registry, value?: null | Text | string | AnyU8a | { toString: () => string }) {
+7 -2
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
import type BN from 'bn.js';
import type { H256 } from '../interfaces/runtime';
import type { Hash } from '../interfaces/runtime';
import type { Registry } from './registry';
export type AnyJson = string | number | boolean | null | undefined | AnyJson[] | { [index: string]: AnyJson };
@@ -46,7 +46,7 @@ export interface Codec {
/**
* @description Returns a hash of the value
*/
readonly hash: H256;
readonly hash: Hash;
/**
* @description Checks if the value is an empty value
@@ -58,6 +58,11 @@ export interface Codec {
*/
readonly registry: Registry;
/**
* @description The block at which this value was retrieved/created (set to non-empty when retrieved from storage)
*/
createdAtHash?: Hash;
/**
* @description Compares the value of the input to see if there is a match
*/
+4 -1
View File
@@ -5,7 +5,7 @@ import type BN from 'bn.js';
import type { Metadata } from '@polkadot/metadata';
import type { Observable } from '@polkadot/x-rxjs';
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { CodecHash } from '../interfaces/runtime';
import type { CodecHash, Hash } from '../interfaces/runtime';
import type { ChainProperties } from '../interfaces/system';
import type { CallFunction } from './calls';
import type { Codec, Constructor } from './codec';
@@ -98,8 +98,11 @@ export interface Registry {
readonly chainSS58: number | undefined;
readonly chainTokens: string[];
readonly knownTypes: RegisteredTypes;
readonly unknownTypes: string[];
readonly signedExtensions: string[];
createdAtHash?: Hash;
findMetaCall (callIndex: Uint8Array): CallFunction;
findMetaError (errorIndex: Uint8Array | { error: BN, index: BN }): RegistryError;
// due to same circular imports where types don't really want to import from EventData,
+378 -376
View File
File diff suppressed because it is too large Load Diff