Compare commits

...
71 Commits
Author SHA1 Message Date
Github Actions 093d2cfa7c [CI Skip] release/stable 3.5.1
skip-checks: true
2021-01-18 11:37:28 +00:00
Jaco Greeff 35b31a21dc 3.5 (#3071) 2021-01-18 12:29:58 +01:00
Github Actions 8b9741a722 [CI Skip] release/beta 3.4.2-18
skip-checks: true
2021-01-18 08:42:18 +00:00
Ewa Kowalska d5cfa9b0e9 Handle no council for bounties proposals (#3062)
* Handle no council for bounties proposals

* Fix code climate

* Handle no council present with api derive
2021-01-18 09:33:20 +01:00
Github Actions 129d1214fe [CI Skip] release/beta 3.4.2-17
skip-checks: true
2021-01-17 15:11:37 +00:00
Jaco Greeff abb3375c3a Bump common (& Substrate node references) (#3069) 2021-01-17 16:04:26 +01:00
Github Actions 4cfa06b43f [CI Skip] release/beta 3.4.2-16
skip-checks: true
2021-01-17 13:30:25 +00:00
Jaco Greeff 8fa80ac0f6 Adjust node-template for MultiAddress (>= 100) (#3068)
* Adjust node-template for MultiAddress (>= 100)

* Bump deps
2021-01-17 14:22:09 +01:00
Github Actions 2d011c68df [CI Skip] release/beta 3.4.2-15
skip-checks: true
2021-01-17 12:48:44 +00:00
Jaco Greeff 640ef4bdab Adjust Rococo types (#3067) 2021-01-17 13:39:29 +01:00
Github Actions cdd20c0b99 [CI Skip] release/beta 3.4.2-14
skip-checks: true
2021-01-15 21:41:55 +00:00
Jaco Greeff 3a12123bf9 Remove recursion on decodeU8a (#3063)
* Remove recursion on decodeU8a

* Remove skipped tests

* Remove extra allocation
2021-01-15 22:34:30 +01:00
Github Actions 5657d5395b [CI Skip] release/beta 3.4.2-13
skip-checks: true
2021-01-15 15:14:00 +00:00
Jeremías Díaz 66b1108c5c feat(types): add correct tuple type to storage key (#3054)
* feat(types): add correct tuple type to storage key

* refactor(types): remove unneeded type assertions
2021-01-15 16:06:23 +01:00
Github Actions 7bf7e207c2 [CI Skip] release/beta 3.4.2-12
skip-checks: true
2021-01-15 13:38:01 +00:00
Jaco Greeff 01098395ec Add crowdloan types (#3060)
* Add crowdloan types

* Update
2021-01-15 14:28:57 +01:00
Github Actions 3e21dfdc03 [CI Skip] release/beta 3.4.2-11
skip-checks: true
2021-01-15 12:56:17 +00:00
Jaco Greeff a400fb2362 Sort registry (#3061) 2021-01-15 13:49:12 +01:00
Github Actions 44172aa359 [CI Skip] release/beta 3.4.2-10
skip-checks: true
2021-01-15 11:32:08 +00:00
Jaco Greeff 82cab2827a Add lottery types (#3059) 2021-01-15 12:23:19 +01:00
Github Actions a198eb1515 [CI Skip] release/beta 3.4.2-9
skip-checks: true
2021-01-15 10:57:12 +00:00
Jaco Greeff 6e67cd6c97 Bump common (#3058) 2021-01-15 11:48:25 +01:00
Github Actions e51e89df56 [CI Skip] release/beta 3.4.2-8
skip-checks: true
2021-01-13 23:12:15 +00:00
Jaco Greeff e46fd07d39 align aura/babe without staking 2021-01-14 00:03:28 +01:00
Jaco Greeff b2cf9aed83 Info changes for no staking (but with babe) 2021-01-14 00:01:42 +01:00
Jaco Greeff c632030437 Fix derive session.info with no staking 2021-01-13 23:59:59 +01:00
Github Actions 9dc683d289 [CI Skip] release/beta 3.4.2-7
skip-checks: true
2021-01-13 22:53:45 +00:00
Jaco Greeff 6cef6190b1 Optional staking in session progress calcs (#3051)
* Optional staking in session progress calcs

* No extra pipe
2021-01-13 23:46:15 +01:00
Github Actions 75dd443d79 [CI Skip] release/beta 3.4.2-6
skip-checks: true
2021-01-13 12:14:07 +00:00
Jaco Greeff 13dacb591d Updata parachain types (#3050) 2021-01-13 13:07:07 +01:00
Jaco Greeff 429bf5456e Add tests for toBigInt usage (#3049)
* Add tests for toBigInt usage

* Update packages/types/src/codec/UInt.spec.ts
2021-01-13 13:00:10 +01:00
Github Actions 527c0f5015 [CI Skip] release/beta 3.4.2-5
skip-checks: true
2021-01-13 10:19:11 +00:00
Jaco Greeff 527ab27bee Westend 46, 47 blocks (#3044) 2021-01-13 11:09:33 +01:00
Github Actions 7991403022 [CI Skip] release/beta 3.4.2-4
skip-checks: true
2021-01-13 08:07:59 +00:00
Ian He 61d2e6c5e5 toBigInt() uses primitive type bigint (#3047) 2021-01-13 09:01:11 +01:00
Github Actions e005a3fc0c [CI Skip] release/beta 3.4.2-3
skip-checks: true
2021-01-12 13:54:07 +00:00
Jaco Greeff 2dfb0fb59a Dedupe parachain types (#3043)
* Updata parachain types

* Remove duplication

* hrmp update
2021-01-12 14:46:57 +01:00
Github Actions 70c011e7e2 [CI Skip] release/beta 3.4.2-2
skip-checks: true
2021-01-12 13:23:32 +00:00
Jaco Greeff 8134322626 Updata parachain types (#3042) 2021-01-12 14:14:54 +01:00
Github Actions 60152749bb [CI Skip] release/beta 3.4.2-1
skip-checks: true
2021-01-11 23:27:12 +00:00
Jaco Greeff b257e120d4 Update parachain types (#3041) 2021-01-12 00:20:20 +01:00
Github Actions 6dc75acd21 [CI Skip] release/beta 3.4.2-0
skip-checks: true
2021-01-11 15:44:17 +00:00
Jaco Greeff a04400170c Set Rococo Keys to 6 (#3040) 2021-01-11 16:36:32 +01:00
Github Actions e3f16e6066 [CI Skip] release/stable 3.4.1
skip-checks: true
2021-01-11 08:13:52 +00:00
Jaco Greeff c3b697d52d 3.4 (#3037) 2021-01-11 09:04:19 +01:00
Github Actions 645fb58e82 [CI Skip] release/beta 3.3.3-5
skip-checks: true
2021-01-10 09:27:13 +00:00
icodezjb 474e509507 Update SessionKeys (#3035)
SessionKeys6, SessionKeys7, SessionKeys8, SessionKeys9
2021-01-10 10:19:55 +01:00
Github Actions df9aff3bac [CI Skip] release/beta 3.3.3-4
skip-checks: true
2021-01-08 16:15:40 +00:00
Jaco Greeff caface921e Adjust max signed check (#3034) 2021-01-08 17:08:04 +01:00
Github Actions ba9cc785c1 [CI Skip] release/beta 3.3.3-3
skip-checks: true
2021-01-08 13:51:18 +00:00
Jaco Greeff 4ff9b51af2 Add API option for chain-specific signedExtensions (#3033)
* Add API option for chain-specific signedExtensions

* typo
2021-01-08 14:42:26 +01:00
Github Actions 2c20a9f395 [CI Skip] release/beta 3.3.3-2
skip-checks: true
2021-01-08 10:28:58 +00:00
Jaco Greeff ee17aa7464 Fix v12 static json 2021-01-08 11:20:18 +01:00
Jaco Greeff 2d01a7b593 Update alias mapping (asset Balance in events) 2021-01-08 11:01:48 +01:00
Github Actions 000e8089d9 [CI Skip] release/beta 3.3.3-1
skip-checks: true
2021-01-08 09:53:41 +00:00
Jaco Greeff 43000b6aaf Update contract types (#3032)
* Update contract types

* Add registry lookup name compat

* cleanup

* Rebuild ts defs
2021-01-08 10:46:12 +01:00
Github Actions 0f8b204db8 [CI Skip] release/beta 3.3.3-0
skip-checks: true
2021-01-07 18:53:56 +00:00
Jaco Greeff 679f4103e1 Fix EthTransaction to ethereum crate (#3030)
* Fix (alhabetically sorted??) EthTransaction

* EthTransaction from ethereum crate
2021-01-07 19:45:37 +01:00
Github Actions 6c61708eff [CI Skip] release/stable 3.3.2
skip-checks: true
2021-01-06 17:30:18 +00:00
Jaco Greeff f0ce53f5a5 dispatchInfo on failed 2021-01-06 18:20:52 +01:00
Jaco Greeff d826ac85fa Event check index (#3028)
* Event check index

* patch
2021-01-06 18:18:08 +01:00
Github Actions 18a81fbbcb [CI Skip] release/beta 3.3.2-4
skip-checks: true
2021-01-06 10:56:45 +00:00
Jeremías Díaz 9ab59c9241 fix(typegen): support vecs of tuples in enums (#3022) 2021-01-06 11:48:32 +01:00
Github Actions 0161996cf6 [CI Skip] release/beta 3.3.2-3
skip-checks: true
2021-01-06 09:51:22 +00:00
Jaco Greeff 99463a3f1d Return result with entries with 0 keys (#3025)
* Return result with entries with 0 keys

* Cleanup
2021-01-06 10:42:53 +01:00
Github Actions cec4c69374 [CI Skip] release/beta 3.3.2-2
skip-checks: true
2021-01-05 13:13:44 +00:00
Jaco Greeff 44077c7cf6 Add ParaGenesisArgs type (#3021) 2021-01-05 14:04:50 +01:00
Github Actions ac7b1bdeeb [CI Skip] release/beta 3.3.2-1
skip-checks: true
2021-01-05 11:30:57 +00:00
Jaco Greeff 1c86333b5f derive.chain.getBlock() now maps events to extrinsics (#3020)
* derive.chain.getBlock() now maps events to extrinsics

* Also apply to subscribeNewBlocks

* Cleanup

* breaking
2021-01-05 12:21:58 +01:00
Github Actions da4108ff9b [CI Skip] release/beta 3.3.2-0
skip-checks: true
2021-01-05 09:46:04 +00:00
Ewa Kowalska 0c5fc15935 Add motions to bounty derive (#3016)
* Add proposals to BountyDerive

* Extract filterBountiesProposals method

* Apply review suggestions
2021-01-05 10:37:45 +01:00
89 changed files with 3520 additions and 2980 deletions
+2
View File
@@ -8,3 +8,5 @@
2.8.2 2.8.2
3.2.2 3.2.2
3.2.3 3.2.3
3.3.2
+51
View File
@@ -1,5 +1,56 @@
# CHANGELOG # CHANGELOG
## 3.5.1 Jan 18, 2020
Upgrade priority: Low. Recommended for parachain developers.
- **Important** The default for Substrate on the Address types are `MultiAddress`. It is recommended that chains add explicit definitions for `Address` and `LookupSource` in their types, instead of relying on the API-defaults. A future update will swap the API defaults to align with Substrate.
- **Important** Like the above changes in Substrate, the `AccountInfo` structure has also changed. It is recommended that chain developers explicitly add `AccountInfo: 'AccountInfoWithRefCount'` for the version with `refCount` on and `AccountInfoWithProviders` for the latest Substrate version. As per the above, the API defaults will be changed to align with Substrate.
Contributed:
- Apply correct TypeScript type for `toBigInt()` (Thanks to https://github.com/ianhe8x)
- Expand type definitions for storage key tuples (Thanks to https://github.com/monitz87)
- Adjust bounty derive to cater for non-council chains (Thanks to https://github.com/ekowalsk)
Changes:
- Remove recursion in vector/struct U8a stream decoding
- Availability of staking made optional in session length calcs (era does require it)
- Updates to parachain types, ensuring it has coverage for all the latest
- Update all Rococo types to the latest (session keys, session reports, parachain indexes)
- Update known upgrade checkpoints fo WestEnd
- Add types of the lottery module in Substrate
- Add and extend types for the crowdloan module in Polkadot
- Adjust node-template to default to `MultiAddress` on specVersion >= 100
## 3.4.1 Jan 11, 2020
Upgrade priority: Low. Fixes for parachain types, `.entries()` (with no values) and `event.is(...)` checks, users of these interfaces will have benefit.
- **Breaking change** The `derive.chain.{getBlock, subscribeNewBlocks}` now return `SignedBlockExtended`, all with the actual extrinsics and events mapped. Users of the latter interface should take note.
Contributed:
- Fix `SessionKeys{6-9}` definitions (Thanks to https://github.com/icodezjb)
- Support `Vec<(a, b)>` in enums (Thanks to https://github.com/monitz87)
- Add motions to bounty derive (Thanks to https://github.com/ekowalsk)
Changes:
- `derive.chain.getBlock()` now maps events to extrinsics via `.extrinsics` getter
- Ensure dispatchInfo is extracted on failed extrinsics (`getBlock` derive)
- Allow specification of additional signed extrinsic via API options
- Add missing parachain types, `ParaGenesisArgs`
- Correct `EthTransaction` type (as per the correct cargo crate)
- Update with latest contract types for Substrate master
- Update alias mapping for asset palette (including Substrate starting defaults)
- Allow `.entries()` call where 0 keys are present
- Fix `.is` on events not checking the correct index
- Construction of `i*` types ow correctly checks for max positive/negative
## 3.3.1 Jan 4, 2021 ## 3.3.1 Jan 4, 2021
Upgrade priority: Low. Recommended for users of frontier evm module with additional types. Upgrade priority: Low. Recommended for users of frontier evm module with additional types.
+3 -3
View File
@@ -28,11 +28,11 @@
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/register": "^7.12.10", "@babel/register": "^7.12.10",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/dev": "^0.61.22", "@polkadot/dev": "^0.61.24",
"@polkadot/ts": "^0.3.59", "@polkadot/ts": "^0.3.59",
"@polkadot/typegen": "workspace:packages/typegen", "@polkadot/typegen": "workspace:packages/typegen",
"@types/jest": "^26.0.19", "@types/jest": "^26.0.20",
"copyfiles": "^2.4.1" "copyfiles": "^2.4.1"
}, },
"version": "3.3.1" "version": "3.5.1"
} }
+5 -5
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api-contract", "name": "@polkadot/api-contract",
"version": "3.3.1", "version": "3.5.1",
"description": "Interfaces for interacting with contracts and contract ABIs", "description": "Interfaces for interacting with contracts and contract ABIs",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -14,10 +14,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api": "3.3.1", "@polkadot/api": "3.5.1",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "3.5.1",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
} }
} }
+9 -9
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api-derive", "name": "@polkadot/api-derive",
"version": "3.3.1", "version": "3.5.1",
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.", "description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -14,16 +14,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api": "3.3.1", "@polkadot/api": "3.5.1",
"@polkadot/rpc-core": "3.3.1", "@polkadot/rpc-core": "3.5.1",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.3.1",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "3.5.1",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3", "@polkadot/keyring": "^5.3.1",
"@polkadot/rpc-provider": "3.3.1" "@polkadot/rpc-provider": "3.5.1"
} }
} }
+1 -2
View File
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { AccountIndex } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { AccountIndexes } from '../types'; import type { AccountIndexes } from '../types';
@@ -18,7 +17,7 @@ function queryAccounts (api: ApiInterfaceRx): Observable<AccountIndexes> {
map((entries): AccountIndexes => map((entries): AccountIndexes =>
entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => { entries.reduce((indexes: AccountIndexes, [key, idOpt]): AccountIndexes => {
if (idOpt.isSome) { if (idOpt.isSome) {
indexes[idOpt.unwrap()[0].toString()] = key.args[0] as AccountIndex; indexes[idOpt.unwrap()[0].toString()] = key.args[0];
} }
return indexes; return indexes;
@@ -1,16 +1,20 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors // Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx, SubmittableExtrinsic } from '@polkadot/api/types';
import type { Bytes, Option, StorageKey } from '@polkadot/types'; import type { Bytes, Option, StorageKey } from '@polkadot/types';
import type { Bounty, BountyIndex } from '@polkadot/types/interfaces'; import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import type { Codec, InterfaceTypes } from '@polkadot/types/types'; import type { Codec, InterfaceTypes } from '@polkadot/types/types';
import { ApiPromise } from '@polkadot/api';
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import { Proposal } from '@polkadot/types/interfaces';
import { of } from '@polkadot/x-rxjs'; import { of } from '@polkadot/x-rxjs';
import { BountyFactory } from '../../test/bountyFactory'; import { BountyFactory } from '../../test/bountyFactory';
import { BytesFactory } from '../../test/bytesFactory'; import { BytesFactory } from '../../test/bytesFactory';
import { createApiWithAugmentations } from '../../test/helpers'; import { createApiWithAugmentations } from '../../test/helpers';
import { ProposalFactory } from '../../test/proposalFactory';
import { bounties } from '.'; import { bounties } from '.';
const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM'; const DEFAULT_PROPOSER = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';
@@ -21,22 +25,62 @@ describe('bounties derive', () => {
let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>; let emptyOption: <T extends Codec> (typeName: keyof InterfaceTypes) => Option<T>;
let optionOf: <T extends Codec> (value: T)=> Option<T>; let optionOf: <T extends Codec> (value: T)=> Option<T>;
let bountyIndex: (index: number) => BountyIndex; let bountyIndex: (index: number) => BountyIndex;
let proposalIndex: (index: number) => ProposalIndex;
let bytes: (value: string) => Bytes; let bytes: (value: string) => Bytes;
let api: ApiPromise;
let createProposal: (method: SubmittableExtrinsic<'promise'>) => Proposal;
let defaultMockApi: ApiInterfaceRx;
beforeAll(() => { beforeAll(() => {
const api = createApiWithAugmentations(); api = createApiWithAugmentations();
({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api)); ({ bountyIndex, defaultBounty, emptyOption, optionOf, storageKey } = new BountyFactory(api));
({ bytes } = new BytesFactory(api.registry)); ({ bytes } = new BytesFactory(api.registry));
({ createProposal, proposalIndex } = new ProposalFactory(api));
});
beforeEach(() => {
defaultMockApi = {
derive: {
council: {
proposals: () => of([] as DeriveCollectiveProposal[])
}
},
query: {
council: {
proposalCount: () => of(proposalIndex(2))
},
treasury: {
bounties: {
keys: () => of([storageKey(0), storageKey(1)]),
multi: () => of([optionOf(defaultBounty()), optionOf(defaultBounty())])
},
bountyCount: () => of(bountyIndex(2)),
bountyDescriptions: {
multi: () => of([
optionOf(bytes('make polkadot even better')),
optionOf(bytes('some other bounty'))
])
}
}
},
tx: api.tx
} as unknown as ApiInterfaceRx;
}); });
it('creates storage key', function () { it('creates storage key', function () {
expect(storageKey(194).args[0].eq(194)).toBe(true); expect(storageKey(194).args[0].eq(194)).toBe(true);
}); });
it('creates proposal', function () {
expect(createProposal(api.tx.balances.transfer('5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z', 1))).toBeTruthy();
});
it('combines bounties with descriptions', async () => { it('combines bounties with descriptions', async () => {
const mockApi = { const mockApi = {
...defaultMockApi,
query: { query: {
...defaultMockApi.query,
treasury: { treasury: {
bounties: { bounties: {
keys: () => of([storageKey(0), storageKey(2), storageKey(3)]), keys: () => of([storageKey(0), storageKey(2), storageKey(3)]),
@@ -64,4 +108,54 @@ describe('bounties derive', () => {
expect(result[1].description).toEqual(''); expect(result[1].description).toEqual('');
expect(result[1].index.eq(3)).toBe(true); expect(result[1].index.eq(3)).toBe(true);
}); });
it('returns motions', async () => {
const result = await bounties('', defaultMockApi)().toPromise();
expect(result).toHaveLength(2);
expect(result[0].proposals).toHaveLength(0);
expect(result[1].proposals).toHaveLength(0);
});
it('when no council, returns bounties without motions', async () => {
const mockApi = {
...defaultMockApi,
query: {
...defaultMockApi.query,
council: null
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
expect(result).toHaveLength(2);
expect(result[0].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
expect(result[0].description).toEqual('make polkadot even better');
expect(result[0].index.eq(0)).toBe(true);
expect(result[0].proposals).toHaveLength(0);
expect(result[1].bounty.proposer.toString()).toEqual(DEFAULT_PROPOSER);
expect(result[1].description).toEqual('some other bounty');
expect(result[1].index.eq(1)).toBe(true);
expect(result[1].proposals).toHaveLength(0);
});
it('combines bounties with motions', async () => {
const mockApi = {
...defaultMockApi,
derive: {
council: {
proposals: () => of([
{ proposal: createProposal(api.tx.bounties.approveBounty(1)) },
{ proposal: createProposal(api.tx.treasury.approveProposal(1)) }] as DeriveCollectiveProposal[])
}
}
} as unknown as ApiInterfaceRx;
const result = await bounties('', mockApi)().toPromise();
expect(result).toHaveLength(2);
expect(result[0].proposals).toHaveLength(0);
expect(result[1].proposals).toHaveLength(1);
expect(result[1].proposals[0].proposal.method).toEqual('approveBounty');
});
}); });
+25 -15
View File
@@ -2,17 +2,19 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { DeriveBounties } from '@polkadot/api-derive/types'; import type { DeriveBounties, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
import type { Bytes, Option } from '@polkadot/types'; import type { Bytes, Option, StorageKey } from '@polkadot/types';
import type { Bounty, BountyIndex } from '@polkadot/types/interfaces'; import type { Bounty, BountyIndex, ProposalIndex } from '@polkadot/types/interfaces';
import { memo } from '@polkadot/api-derive/util'; import { memo } from '@polkadot/api-derive/util';
import { combineLatest, Observable, of } from '@polkadot/x-rxjs'; import { combineLatest, Observable, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[]]; import { filterBountiesProposals } from './helpers/filterBountyProposals';
function parseResult (api: ApiInterfaceRx, [maybeBounties, maybeDescriptions, ids]: Result): DeriveBounties { type Result = [Option<Bounty>[], Option<Bytes>[], BountyIndex[], DeriveCollectiveProposal[]];
function parseResult ([maybeBounties, maybeDescriptions, ids, bountyProposals]: Result): DeriveBounties {
const bounties: DeriveBounties = []; const bounties: DeriveBounties = [];
maybeBounties.forEach((bounty, index) => { maybeBounties.forEach((bounty, index) => {
@@ -20,7 +22,8 @@ function parseResult (api: ApiInterfaceRx, [maybeBounties, maybeDescriptions, id
bounties.push({ bounties.push({
bounty: bounty.unwrap(), bounty: bounty.unwrap(),
description: maybeDescriptions[index].unwrapOrDefault().toUtf8(), description: maybeDescriptions[index].unwrapOrDefault().toUtf8(),
index: ids[index] index: ids[index],
proposals: bountyProposals.filter((bountyProposal) => ids[index].eq(bountyProposal.proposal.args[0]))
}); });
} }
}); });
@@ -29,23 +32,30 @@ function parseResult (api: ApiInterfaceRx, [maybeBounties, maybeDescriptions, id
} }
export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> { export function bounties (instanceId: string, api: ApiInterfaceRx): () => Observable<DeriveBounties> {
const bountyBase = api.query.bounties const bountyBase = api.query.bounties ? api.query.bounties : api.query.treasury;
? api.query.bounties
: api.query.treasury;
return memo(instanceId, (): Observable<DeriveBounties> => return memo(instanceId, (): Observable<DeriveBounties> =>
bountyBase.bountyCount<BountyIndex>().pipe( combineLatest([
switchMap(() => bountyBase.bounties.keys()), bountyBase.bountyCount<BountyIndex>(),
switchMap((keys): Observable<Result> => { api.query.council ? api.query.council.proposalCount<ProposalIndex>() : of(0)
const ids = keys.map(({ args: [id] }) => id as BountyIndex); ]).pipe(
switchMap(() =>
combineLatest([
bountyBase.bounties.keys(),
api.derive.council ? api.derive.council.proposals() : of([])
])
),
switchMap(([keys, proposals]): Observable<Result> => {
const ids = (keys as StorageKey<[BountyIndex]>[]).map(({ args: [id] }) => id);
return combineLatest([ return combineLatest([
bountyBase.bounties.multi<Option<Bounty>>(ids), bountyBase.bounties.multi<Option<Bounty>>(ids),
bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids), bountyBase.bountyDescriptions.multi<Option<Bytes>>(ids),
of(ids) of(ids),
of(filterBountiesProposals(api, proposals))
]); ]);
}), }),
map(([maybeBounties, maybeDescriptions, ids]) => parseResult(api, [maybeBounties, maybeDescriptions, ids])) map(parseResult)
) )
); );
} }
@@ -0,0 +1,12 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiInterfaceRx } from '@polkadot/api/types';
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
export function filterBountiesProposals (api: ApiInterfaceRx, allProposals: DeriveCollectiveProposal[]): DeriveCollectiveProposal[] {
const bountyTxBase = api.tx.bounties ? api.tx.bounties : api.tx.treasury;
const bountyProposalCalls = [bountyTxBase.approveBounty, bountyTxBase.closeBounty, bountyTxBase.proposeCurator, bountyTxBase.unassignCurator];
return allProposals.filter((proposal) => bountyProposalCalls.find((bountyCall) => bountyCall.is(proposal.proposal)));
}
+3 -2
View File
@@ -27,12 +27,13 @@ export function getBlock (instanceId: string, api: ApiInterfaceRx): (hash: Uint8
return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> => return memo(instanceId, (hash: Uint8Array | string): Observable<SignedBlockExtended | undefined> =>
combineLatest([ combineLatest([
api.rpc.chain.getBlock(hash), api.rpc.chain.getBlock(hash),
api.query.system.events.at(hash),
api.query.session api.query.session
? api.query.session.validators.at(hash) ? api.query.session.validators.at(hash)
: of([]) : of([])
]).pipe( ]).pipe(
map(([signedBlock, validators]): SignedBlockExtended => map(([signedBlock, events, validators]): SignedBlockExtended =>
new SignedBlockExtended(api.registry, signedBlock, validators) new SignedBlockExtended(api.registry, signedBlock, events, validators)
), ),
catchError((): Observable<undefined> => catchError((): Observable<undefined> =>
// where rpc.chain.getHeader throws, we will land here - it can happen that // where rpc.chain.getHeader throws, we will land here - it can happen that
@@ -2,32 +2,34 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { ApiInterfaceRx } from '@polkadot/api/types'; import type { ApiInterfaceRx } from '@polkadot/api/types';
import type { EventRecord, Hash, SignedBlock } from '@polkadot/types/interfaces'; import type { AccountId, EventRecord, SignedBlock } from '@polkadot/types/interfaces';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { FullNewBlock } from '../types';
import { combineLatest, of } from '@polkadot/x-rxjs'; import { combineLatest, of } from '@polkadot/x-rxjs';
import { map, switchMap } from '@polkadot/x-rxjs/operators'; import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { SignedBlockExtended } from '../type';
import { memo } from '../util'; import { memo } from '../util';
/** /**
* @name subscribeNewBlocks * @name subscribeNewBlocks
* @returns The latest block & events for that block * @returns The latest block & events for that block
*/ */
export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<FullNewBlock> { export function subscribeNewBlocks (instanceId: string, api: ApiInterfaceRx): () => Observable<SignedBlockExtended> {
return memo(instanceId, (): Observable<FullNewBlock> => return memo(instanceId, (): Observable<SignedBlockExtended> =>
api.derive.chain.subscribeNewHeads().pipe( api.derive.chain.subscribeNewHeads().pipe(
switchMap((header): Observable<[Hash, EventRecord[], SignedBlock]> => { switchMap((header): Observable<[SignedBlock, EventRecord[], AccountId[] | undefined]> => {
const blockHash = header.hash; const blockHash = header.hash;
return combineLatest( return combineLatest(
of(blockHash), api.rpc.chain.getBlock(blockHash),
api.query.system.events.at(blockHash), api.query.system.events.at(blockHash),
api.rpc.chain.getBlock(header.hash) of(header.validators)
); );
}), }),
map(([blockHash, events, block]) => ({ block: block.block, blockHash, blockNumber: block.block.header.number.unwrap(), events, justification: block.justification })) map(([block, events, validators]) =>
new SignedBlockExtended(api.registry, block, events, validators)
)
) )
); );
} }
-12
View File
@@ -1,12 +0,0 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0
import type { Block, BlockNumber, EventRecord, Hash, Justification } from '@polkadot/types/interfaces';
export interface FullNewBlock {
block: Block;
blockHash: Hash;
blockNumber: BlockNumber;
events: EventRecord[];
justification: Justification;
}
@@ -51,7 +51,7 @@ function schedulerEntries (api: ApiInterfaceRx): Observable<[BlockNumber[], Opti
api.query.scheduler.agenda.keys() api.query.scheduler.agenda.keys()
), ),
switchMap((keys) => { switchMap((keys) => {
const blockNumbers = keys.map((key) => key.args[0] as BlockNumber); const blockNumbers = keys.map((key) => key.args[0]);
return combineLatest([ return combineLatest([
of(blockNumbers), of(blockNumbers),
@@ -69,7 +69,7 @@ function extractVotes (mapped: [AccountId, Voting][], referendumId: BN): DeriveR
function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> { function votesCurr (api: ApiInterfaceRx, referendumId: BN): Observable<DeriveReferendumVote[]> {
return api.query.democracy.votingOf.entries<Voting>().pipe( return api.query.democracy.votingOf.entries<Voting>().pipe(
map((allVoting): DeriveReferendumVote[] => { map((allVoting): DeriveReferendumVote[] => {
const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0] as AccountId, voting]); const mapped = allVoting.map(([key, voting]): [AccountId, Voting] => [key.args[0], voting]);
const votes = extractVotes(mapped, referendumId); const votes = extractVotes(mapped, referendumId);
const delegations = mapped const delegations = mapped
.filter(([, voting]) => voting.isDelegating) .filter(([, voting]) => voting.isDelegating)
+3 -1
View File
@@ -35,6 +35,7 @@ function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
[ [
false, false,
api.registry.createType('u64', 1), api.registry.createType('u64', 1),
// we may have aura without staking (permissioned)
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1) api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
], ],
indexes indexes
@@ -50,7 +51,8 @@ function queryBabe (api: ApiInterfaceRx): Observable<DeriveSessionInfo> {
[ [
true, true,
api.consts.babe.epochDuration, api.consts.babe.epochDuration,
api.consts.staking.sessionsPerEra // we may have babe without staking (permissioned)
api.consts.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1)
], ],
indexes indexes
]) ])
+16 -8
View File
@@ -12,6 +12,7 @@ import { map, switchMap } from '@polkadot/x-rxjs/operators';
import { memo } from '../util'; import { memo } from '../util';
type ResultSlotsNoSession = [u64, u64, u64];
type ResultSlots = [u64, u64, u64, Option<SessionIndex>]; type ResultSlots = [u64, u64, u64, Option<SessionIndex>];
type ResultSlotsFlat = [u64, u64, u64, SessionIndex]; type ResultSlotsFlat = [u64, u64, u64, SessionIndex];
@@ -39,19 +40,26 @@ function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionProgress> {
function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> { function queryBabe (api: ApiInterfaceRx): Observable<[DeriveSessionInfo, ResultSlotsFlat]> {
return api.derive.session.info().pipe( return api.derive.session.info().pipe(
switchMap((info): Observable<[DeriveSessionInfo, ResultSlots]> => switchMap((info): Observable<[DeriveSessionInfo, ResultSlots | ResultSlotsNoSession]> =>
combineLatest([ combineLatest([
of(info), of(info),
api.queryMulti<ResultSlots>([ // we may have no staking, but have babe (permissioned)
api.query.babe.currentSlot, api.query.staking
api.query.babe.epochIndex, ? api.queryMulti<ResultSlots>([
api.query.babe.genesisSlot, api.query.babe.currentSlot,
[api.query.staking.erasStartSessionIndex, info.activeEra] api.query.babe.epochIndex,
]) api.query.babe.genesisSlot,
[api.query.staking.erasStartSessionIndex, info.activeEra]
])
: api.queryMulti<ResultSlotsNoSession>([
api.query.babe.currentSlot,
api.query.babe.epochIndex,
api.query.babe.genesisSlot
])
]) ])
), ),
map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [ map(([info, [currentSlot, epochIndex, genesisSlot, optStartIndex]]): [DeriveSessionInfo, ResultSlotsFlat] => [
info, [currentSlot, epochIndex, genesisSlot, optStartIndex.unwrapOr(api.registry.createType('SessionIndex', 1))] info, [currentSlot, epochIndex, genesisSlot, optStartIndex && optStartIndex.isSome ? optStartIndex.unwrap() : api.registry.createType('SessionIndex', 1)]
]) ])
); );
} }
+1 -1
View File
@@ -15,7 +15,7 @@ import { memo } from '../util';
export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> { export function stashes (instanceId: string, api: ApiInterfaceRx): () => Observable<AccountId[]> {
return memo(instanceId, (): Observable<AccountId[]> => return memo(instanceId, (): Observable<AccountId[]> =>
api.query.staking.validators.keys().pipe( api.query.staking.validators.keys().pipe(
map((keys) => keys.map((key) => key.args[0] as AccountId).filter((a) => a)) map((keys) => keys.map((key) => key.args[0]).filter((a) => a))
) )
); );
} }
@@ -18,7 +18,7 @@ export function nextElected (instanceId: string, api: ApiInterfaceRx): () => Obs
// only populate for next era in the last session, so track both here - entries are not // only populate for next era in the last session, so track both here - entries are not
// subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh // subscriptions, so we need a trigger - currentIndex acts as that trigger to refresh
switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)), switchMap(({ currentEra }) => api.query.staking.erasStakers.keys(currentEra)),
map((keys) => keys.map((key) => key.args[1] as AccountId)) map((keys) => keys.map((key) => key.args[1]))
) )
: api.query.staking.currentElected<AccountId[]>() : api.query.staking.currentElected<AccountId[]>()
); );
+8 -23
View File
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AccountId, Header } from '@polkadot/types/interfaces'; import type { AccountId, Header } from '@polkadot/types/interfaces';
import type { AnyJson, Constructor, Registry } from '@polkadot/types/types'; import type { Constructor, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types'; import { Struct } from '@polkadot/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions'; import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
@@ -19,11 +19,13 @@ const _Header = Struct.with(runtimeTypes.types.Header as any) as Constructor<Hea
*/ */
export class HeaderExtended extends _Header { export class HeaderExtended extends _Header {
readonly #author?: AccountId; readonly #author?: AccountId;
readonly #validators?: AccountId[];
constructor (registry: Registry, header?: Header, sessionValidators?: AccountId[]) { constructor (registry: Registry, header?: Header, validators?: AccountId[]) {
super(registry, header); super(registry, header);
this.#author = extractAuthor(this.digest, sessionValidators); this.#author = extractAuthor(this.digest, validators);
this.#validators = validators;
} }
/** /**
@@ -34,26 +36,9 @@ export class HeaderExtended extends _Header {
} }
/** /**
* @description Creates a human-friendly JSON representation * @description Convenience method, returns the validators for the block
*/ */
public toHuman (isExtended?: boolean): Record<string, AnyJson> { public get validators (): AccountId[] | undefined {
return { return this.#validators;
...super.toHuman(isExtended),
author: this.author
? this.author.toHuman()
: undefined
};
}
/**
* @description Creates the JSON representation
*/
public toJSON (): Record<string, AnyJson> {
return {
...super.toJSON(),
author: this.author
? this.author.toJSON()
: undefined
};
} }
} }
@@ -1,8 +1,8 @@
// Copyright 2017-2021 @polkadot/api-derive authors & contributors // Copyright 2017-2021 @polkadot/api-derive authors & contributors
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
import type { AccountId, SignedBlock } from '@polkadot/types/interfaces'; import type { AccountId, DispatchError, DispatchInfo, Event, EventRecord, Extrinsic, SignedBlock } from '@polkadot/types/interfaces';
import type { AnyJson, Constructor, Registry } from '@polkadot/types/types'; import type { Constructor, Registry } from '@polkadot/types/types';
import { Struct } from '@polkadot/types'; import { Struct } from '@polkadot/types';
import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions'; import runtimeTypes from '@polkadot/types/interfaces/runtime/definitions';
@@ -12,6 +12,37 @@ import { extractAuthor } from './util';
// We can ignore the properties, added via Struct.with // We can ignore the properties, added via Struct.with
const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Constructor<SignedBlock>; const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Constructor<SignedBlock>;
interface TxWithEvent {
dispatchError?: DispatchError;
dispatchInfo?: DispatchInfo;
events: Event[];
extrinsic: Extrinsic;
}
function mapExtrinsics (extrinsics: Extrinsic[], records: EventRecord[]): TxWithEvent[] {
return extrinsics.map((extrinsic, index): TxWithEvent => {
let dispatchError: DispatchError | undefined;
let dispatchInfo: DispatchInfo | undefined;
const events = records
.filter(({ phase }) => phase.isApplyExtrinsic && phase.asApplyExtrinsic.eq(index))
.map(({ event }) => {
if (event.section === 'system') {
if (event.method === 'ExtrinsicSuccess') {
dispatchInfo = event.data[0] as DispatchInfo;
} else if (event.method === 'ExtrinsicFailed') {
dispatchError = event.data[0] as DispatchError;
dispatchInfo = event.data[1] as DispatchInfo;
}
}
return event;
});
return { dispatchError, dispatchInfo, events, extrinsic };
});
}
/** /**
* @name SignedBlockExtended * @name SignedBlockExtended
* @description * @description
@@ -19,11 +50,15 @@ const _SignedBlock = Struct.with(runtimeTypes.types.SignedBlock as any) as Const
*/ */
export class SignedBlockExtended extends _SignedBlock { export class SignedBlockExtended extends _SignedBlock {
readonly #author?: AccountId; readonly #author?: AccountId;
readonly #events: EventRecord[];
readonly #extrinsics: TxWithEvent[];
constructor (registry: Registry, block?: SignedBlock, sessionValidators?: AccountId[]) { constructor (registry: Registry, block?: SignedBlock, events?: EventRecord[], sessionValidators?: AccountId[]) {
super(registry, block); super(registry, block);
this.#author = extractAuthor(this.block.header.digest, sessionValidators); this.#author = extractAuthor(this.block.header.digest, sessionValidators);
this.#events = events || ([] as EventRecord[]);
this.#extrinsics = mapExtrinsics(this.block.extrinsics, this.#events);
} }
/** /**
@@ -34,26 +69,16 @@ export class SignedBlockExtended extends _SignedBlock {
} }
/** /**
* @description Creates a human-friendly JSON representation * @description Convenience method, returns the events associated with the block
*/ */
public toHuman (isExtended?: boolean): Record<string, AnyJson> { public get events (): EventRecord[] {
return { return this.#events;
...super.toHuman(isExtended),
author: this.author
? this.author.toHuman()
: undefined
};
} }
/** /**
* @description Creates the JSON representation * @description Returns the extrinsics and their events, mapped
*/ */
public toJSON (): Record<string, AnyJson> { public get extrinsics (): TxWithEvent[] {
return { return this.#extrinsics;
...super.toJSON(),
author: this.author
? this.author.toJSON()
: undefined
};
} }
} }
+1 -1
View File
@@ -6,7 +6,6 @@ import type { u32 } from '@polkadot/types';
import type { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces'; import type { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Bounty, BountyIndex, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
export * from './accounts/types'; export * from './accounts/types';
export * from './chain/types';
export * from './council/types'; export * from './council/types';
export * from './democracy/types'; export * from './democracy/types';
export * from './elections/types'; export * from './elections/types';
@@ -132,6 +131,7 @@ export interface DeriveBounty {
bounty: Bounty; bounty: Bounty;
description: string; description: string;
index: BountyIndex; index: BountyIndex;
proposals: DeriveCollectiveProposal[];
} }
export type DeriveBounties = DeriveBounty[]; export type DeriveBounties = DeriveBounty[];
+3 -1
View File
@@ -10,7 +10,9 @@ export function createApiWithAugmentations (): ApiPromise {
const registry = new TypeRegistry(); const registry = new TypeRegistry();
const metadata = new Metadata(registry, metaStatic); const metadata = new Metadata(registry, metaStatic);
const api = new ApiPromise({ provider: new WsProvider('ws://', false) }); registry.setMetadata(metadata);
const api = new ApiPromise({ provider: new WsProvider('ws://', false), registry });
api.injectMetadata(metadata, true); api.injectMetadata(metadata, true);
@@ -0,0 +1,25 @@
// Copyright 2017-2021 @polkadot/api authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { ApiPromise } from '@polkadot/api';
import { SubmittableExtrinsic } from '@polkadot/api/types';
import { Proposal, ProposalIndex } from '@polkadot/types/interfaces';
import { Registry } from '@polkadot/types/types';
export class ProposalFactory {
readonly #api: ApiPromise;
readonly #registry: Registry;
constructor (api: ApiPromise) {
this.#api = api;
this.#registry = this.#api.registry;
}
public createProposal = (method: SubmittableExtrinsic<'promise'>): Proposal => {
return this.#registry.createType('Proposal', method);
};
public proposalIndex = (index: number): ProposalIndex => {
return this.#registry.createType('ProposalIndex', index);
}
}
+11 -11
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/api", "name": "@polkadot/api",
"version": "3.3.1", "version": "3.5.1",
"description": "Promise and RxJS wrappers around the Polkadot JS RPC", "description": "Promise and RxJS wrappers around the Polkadot JS RPC",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -17,16 +17,16 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api-derive": "3.3.1", "@polkadot/api-derive": "3.5.1",
"@polkadot/keyring": "^5.2.3", "@polkadot/keyring": "^5.3.1",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.5.1",
"@polkadot/rpc-core": "3.3.1", "@polkadot/rpc-core": "3.5.1",
"@polkadot/rpc-provider": "3.3.1", "@polkadot/rpc-provider": "3.5.1",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/types-known": "3.3.1", "@polkadot/types-known": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.3.1",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "3.5.1",
"bn.js": "^4.11.9", "bn.js": "^4.11.9",
"eventemitter3": "^4.0.7" "eventemitter3": "^4.0.7"
} }
+5 -4
View File
@@ -3,6 +3,7 @@
import type { Bytes, Option, Vec, bool, u16, u32 } from '@polkadot/types'; import type { Bytes, Option, Vec, bool, u16, u32 } from '@polkadot/types';
import type { ITuple } from '@polkadot/types/types'; import type { ITuple } from '@polkadot/types/types';
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
import type { BalanceStatus } from '@polkadot/types/interfaces/balances'; import type { BalanceStatus } from '@polkadot/types/interfaces/balances';
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective'; import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
import type { AuthorityId } from '@polkadot/types/interfaces/consensus'; import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
@@ -28,7 +29,7 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets were destroyed. \[asset_id, owner, balance\] * Some assets were destroyed. \[asset_id, owner, balance\]
**/ **/
Burned: AugmentedEvent<ApiType, [AssetId, AccountId, Balance]>; Burned: AugmentedEvent<ApiType, [AssetId, AccountId, TAssetBalance]>;
/** /**
* Some asset class was created. \[asset_id, creator, owner\] * Some asset class was created. \[asset_id, creator, owner\]
**/ **/
@@ -44,7 +45,7 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets was transferred by an admin. \[asset_id, from, to, amount\] * Some assets was transferred by an admin. \[asset_id, from, to, amount\]
**/ **/
ForceTransferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, Balance]>; ForceTransferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
/** /**
* Some account `who` was frozen. \[asset_id, who\] * Some account `who` was frozen. \[asset_id, who\]
**/ **/
@@ -52,7 +53,7 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets were issued. \[asset_id, owner, total_supply\] * Some assets were issued. \[asset_id, owner, total_supply\]
**/ **/
Issued: AugmentedEvent<ApiType, [AssetId, AccountId, Balance]>; Issued: AugmentedEvent<ApiType, [AssetId, AccountId, TAssetBalance]>;
/** /**
* The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\] * The maximum amount of zombies allowed has changed. \[asset_id, max_zombies\]
**/ **/
@@ -72,7 +73,7 @@ declare module '@polkadot/api/types/events' {
/** /**
* Some assets were transferred. \[asset_id, from, to, amount\] * Some assets were transferred. \[asset_id, from, to, amount\]
**/ **/
Transferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, Balance]>; Transferred: AugmentedEvent<ApiType, [AssetId, AccountId, AccountId, TAssetBalance]>;
}; };
balances: { balances: {
[key: string]: AugmentedEvent<ApiType>; [key: string]: AugmentedEvent<ApiType>;
+7 -6
View File
@@ -3,6 +3,7 @@
import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u16, u32, u64 } from '@polkadot/types'; import type { Bytes, Compact, Data, Option, U8aFixed, Vec, bool, u16, u32, u64 } from '@polkadot/types';
import type { AnyNumber, ITuple } from '@polkadot/types/types'; import type { AnyNumber, ITuple } from '@polkadot/types/types';
import type { TAssetBalance } from '@polkadot/types/interfaces/assets';
import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe'; import type { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective'; import type { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts'; import type { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
@@ -45,7 +46,7 @@ declare module '@polkadot/api/types/submittable' {
* Weight: `O(1)` * Weight: `O(1)`
* Modes: Post-existence of `who`; Pre & post Zombie-status of `who`. * Modes: Post-existence of `who`; Pre & post Zombie-status of `who`.
**/ **/
burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<Balance>]>; burn: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/** /**
* Issue a new class of fungible assets from a public origin. * Issue a new class of fungible assets from a public origin.
* *
@@ -71,7 +72,7 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: Balance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, u32, Balance]>; create: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, admin: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: u32 | AnyNumber | Uint8Array, minBalance: TAssetBalance | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, u32, TAssetBalance]>;
/** /**
* Destroy a class of fungible assets owned by the sender. * Destroy a class of fungible assets owned by the sender.
* *
@@ -108,7 +109,7 @@ declare module '@polkadot/api/types/submittable' {
* *
* Weight: `O(1)` * Weight: `O(1)`
**/ **/
forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<u32>, Compact<Balance>]>; forceCreate: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, owner: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array, minBalance: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<u32>, Compact<TAssetBalance>]>;
/** /**
* Destroy a class of fungible assets. * Destroy a class of fungible assets.
* *
@@ -143,7 +144,7 @@ declare module '@polkadot/api/types/submittable' {
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status * Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
* of `source`; Account pre-existence of `dest`. * of `source`; Account pre-existence of `dest`.
**/ **/
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<Balance>]>; forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<TAssetBalance>]>;
/** /**
* Disallow further unprivileged transfers from an account. * Disallow further unprivileged transfers from an account.
* *
@@ -171,7 +172,7 @@ declare module '@polkadot/api/types/submittable' {
* Weight: `O(1)` * Weight: `O(1)`
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`. * Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
**/ **/
mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<Balance>]>; mint: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Compact<u32>]>; setMaxZombies: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, maxZombies: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, Compact<u32>]>;
/** /**
* Change the Issuer, Admin and Freezer of an asset. * Change the Issuer, Admin and Freezer of an asset.
@@ -221,7 +222,7 @@ declare module '@polkadot/api/types/submittable' {
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status * Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
* of sender; Account pre-existence of `target`. * of sender; Account pre-existence of `target`.
**/ **/
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<Balance>]>; transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
/** /**
* Change the Owner of an asset. * Change the Owner of an asset.
* *
+12 -10
View File
@@ -518,13 +518,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
return this._retrieveMapKeys(entry, at, arg).pipe( return this._retrieveMapKeys(entry, at, arg).pipe(
switchMap((keys) => switchMap((keys) =>
combineLatest( keys.length
arrayChunk(keys, PAGE_SIZE).map((keys) => query(keys)) ? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
).pipe( map((valsArr) =>
map((valsArr) => arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value]) )
) )
) : of([])
) )
); );
} }
@@ -532,11 +532,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
private _retrieveMapEntriesPaged (entry: StorageEntry, opts: PaginationOptions): Observable<[StorageKey, Codec][]> { private _retrieveMapEntriesPaged (entry: StorageEntry, opts: PaginationOptions): Observable<[StorageKey, Codec][]> {
return this._retrieveMapKeysPaged(entry, opts).pipe( return this._retrieveMapKeysPaged(entry, opts).pipe(
switchMap((keys) => switchMap((keys) =>
this._rpcCore.state.queryStorageAt(keys).pipe( keys.length
map((valsArr) => ? this._rpcCore.state.queryStorageAt(keys).pipe(
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value]) map((valsArr) =>
valsArr.map((value, index): [StorageKey, Codec] => [keys[index], value])
)
) )
) : of([])
) )
); );
} }
+1 -1
View File
@@ -89,7 +89,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
registry.knownTypes.typesAlias = getSpecAlias(registry, chain, version.specName); registry.knownTypes.typesAlias = getSpecAlias(registry, chain, version.specName);
} }
registry.setMetadata(metadata); registry.setMetadata(metadata, undefined, this._options.signedExtensions);
return registry; return registry;
} }
+5
View File
@@ -9,6 +9,7 @@ import type { DeriveCustom, ExactDerive } from '@polkadot/api-derive';
import type { Metadata } from '@polkadot/metadata'; import type { Metadata } from '@polkadot/metadata';
import type { RpcInterface } from '@polkadot/rpc-core/types'; import type { RpcInterface } from '@polkadot/rpc-core/types';
import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types'; import type { ProviderInterface, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
import type { ExtDef } from '@polkadot/types/extrinsic/signedExtensions/types';
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces'; import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, SignatureOptions, Signer } from '@polkadot/types/types'; import type { DefinitionRpc, DefinitionRpcSub, RegisteredTypes, Registry, SignatureOptions, Signer } from '@polkadot/types/types';
import type { ApiBase } from '../base'; import type { ApiBase } from '../base';
@@ -56,6 +57,10 @@ export interface ApiOptions extends RegisteredTypes {
* @description User-defined RPC methods * @description User-defined RPC methods
*/ */
rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>; rpc?: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>;
/**
* @description Any chain-specific signed extensions that are now well-known
*/
signedExtensions?: Record<string, ExtDef>;
/** /**
* @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair * @description An external signer which will be used to sign extrinsic when account passed in is not KeyringPair
*/ */
+6 -6
View File
@@ -38,16 +38,16 @@ export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple =
export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> { export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple> {
at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>; at: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, ...args: Parameters<F>) => PromiseOrObs<ApiType, T>;
creator: StorageEntry; creator: StorageEntry;
entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>; entries: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<A>, T][]>;
entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey, T][]>; entriesAt: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(hash: Hash | Uint8Array | string, arg?: Parameters<F>[0]) => PromiseOrObs<ApiType, [StorageKey<A>, T][]>;
entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey, T][]>; entriesPaged: <T extends Codec | any = ObsInnerType<ReturnType<F>>>(opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, [StorageKey<A>, T][]>;
hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>; hash: (...args: Parameters<F>) => PromiseOrObs<ApiType, Hash>;
is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>; is: (key: IStorageKey<AnyTuple>) => key is IStorageKey<A>;
key: (...args: Parameters<F>) => string; key: (...args: Parameters<F>) => string;
keyPrefix: () => string; keyPrefix: () => string;
keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey[]>; keys: (arg?: any) => PromiseOrObs<ApiType, StorageKey<A>[]>;
keysAt: (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey[]>; keysAt: (hash: Hash | Uint8Array | string, arg?: any) => PromiseOrObs<ApiType, StorageKey<A>[]>;
keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey[]>; keysPaged: (opts: PaginationOptions<Parameters<F>[0]>) => PromiseOrObs<ApiType, StorageKey<A>[]>;
// @deprecated The underlying RPC this been marked unsafe and is generally not exposed // @deprecated The underlying RPC this been marked unsafe and is generally not exposed
range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>; range: <T extends Codec | any = ObsInnerType<ReturnType<F>>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>; size: (...args: Parameters<F>) => PromiseOrObs<ApiType, u64>;
+6 -6
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/metadata", "name": "@polkadot/metadata",
"version": "3.3.1", "version": "3.5.1",
"description": "Helpers to extract information from runtime metadata", "description": "Helpers to extract information from runtime metadata",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -17,13 +17,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/types-known": "3.3.1", "@polkadot/types-known": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.3.1",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3" "@polkadot/keyring": "^5.3.1"
} }
} }
@@ -8,7 +8,7 @@ import type { Events, ModuleEvents } from '../types';
import { stringCamelCase } from '@polkadot/util'; import { stringCamelCase } from '@polkadot/util';
function isEvent <T extends AnyTuple> (event: IEvent<AnyTuple>, sectionIndex: number, eventIndex: number): event is IEvent<T> { function isEvent <T extends AnyTuple> (event: IEvent<AnyTuple>, sectionIndex: number, eventIndex: number): event is IEvent<T> {
return event.index[0] === sectionIndex && event.index[0] === eventIndex; return event.index[0] === sectionIndex && event.index[1] === eventIndex;
} }
/** @internal */ /** @internal */
+10 -10
View File
@@ -12320,7 +12320,7 @@
}, },
{ {
"name": "min_balance", "name": "min_balance",
"type": "Balance" "type": "TAssetBalance"
} }
], ],
"documentation": [ "documentation": [
@@ -12366,7 +12366,7 @@
}, },
{ {
"name": "min_balance", "name": "min_balance",
"type": "Compact<Balance>" "type": "Compact<TAssetBalance>"
} }
], ],
"documentation": [ "documentation": [
@@ -12456,7 +12456,7 @@
}, },
{ {
"name": "amount", "name": "amount",
"type": "Compact<Balance>" "type": "Compact<TAssetBalance>"
} }
], ],
"documentation": [ "documentation": [
@@ -12487,7 +12487,7 @@
}, },
{ {
"name": "amount", "name": "amount",
"type": "Compact<Balance>" "type": "Compact<TAssetBalance>"
} }
], ],
"documentation": [ "documentation": [
@@ -12521,7 +12521,7 @@
}, },
{ {
"name": "amount", "name": "amount",
"type": "Compact<Balance>" "type": "Compact<TAssetBalance>"
} }
], ],
"documentation": [ "documentation": [
@@ -12562,7 +12562,7 @@
}, },
{ {
"name": "amount", "name": "amount",
"type": "Compact<Balance>" "type": "Compact<TAssetBalance>"
} }
], ],
"documentation": [ "documentation": [
@@ -12729,7 +12729,7 @@
"args": [ "args": [
"AssetId", "AssetId",
"AccountId", "AccountId",
"Balance" "TAssetBalance"
], ],
"documentation": [ "documentation": [
" Some assets were issued. \\[asset_id, owner, total_supply\\]" " Some assets were issued. \\[asset_id, owner, total_supply\\]"
@@ -12741,7 +12741,7 @@
"AssetId", "AssetId",
"AccountId", "AccountId",
"AccountId", "AccountId",
"Balance" "TAssetBalance"
], ],
"documentation": [ "documentation": [
" Some assets were transferred. \\[asset_id, from, to, amount\\]" " Some assets were transferred. \\[asset_id, from, to, amount\\]"
@@ -12752,7 +12752,7 @@
"args": [ "args": [
"AssetId", "AssetId",
"AccountId", "AccountId",
"Balance" "TAssetBalance"
], ],
"documentation": [ "documentation": [
" Some assets were destroyed. \\[asset_id, owner, balance\\]" " Some assets were destroyed. \\[asset_id, owner, balance\\]"
@@ -12786,7 +12786,7 @@
"AssetId", "AssetId",
"AccountId", "AccountId",
"AccountId", "AccountId",
"Balance" "TAssetBalance"
], ],
"documentation": [ "documentation": [
" Some assets was transferred by an admin. \\[asset_id, from, to, amount\\]" " Some assets was transferred by an admin. \\[asset_id, from, to, amount\\]"
+7 -7
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/rpc-core", "name": "@polkadot/rpc-core",
"version": "3.3.1", "version": "3.5.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -14,13 +14,13 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.5.1",
"@polkadot/rpc-provider": "3.3.1", "@polkadot/rpc-provider": "3.5.1",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/x-rxjs": "3.3.1" "@polkadot/x-rxjs": "3.5.1"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3" "@polkadot/keyring": "^5.3.1"
} }
} }
+8 -8
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/rpc-provider", "name": "@polkadot/rpc-provider",
"version": "3.3.1", "version": "3.5.1",
"description": "Transport providers for the API", "description": "Transport providers for the API",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -14,17 +14,17 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.3.1",
"@polkadot/x-fetch": "^5.2.3", "@polkadot/x-fetch": "^5.3.1",
"@polkadot/x-ws": "^5.2.3", "@polkadot/x-ws": "^5.3.1",
"bn.js": "^4.11.9", "bn.js": "^4.11.9",
"eventemitter3": "^4.0.7" "eventemitter3": "^4.0.7"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3", "@polkadot/keyring": "^5.3.1",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.5.1",
"mock-socket": "^9.0.3", "mock-socket": "^9.0.3",
"nock": "^13.0.5" "nock": "^13.0.5"
} }
+6 -6
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/typegen", "name": "@polkadot/typegen",
"version": "3.3.1", "version": "3.5.1",
"description": "Type generation scripts", "description": "Type generation scripts",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -23,11 +23,11 @@
"@babel/core": "^7.12.10", "@babel/core": "^7.12.10",
"@babel/register": "^7.12.10", "@babel/register": "^7.12.10",
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/api": "3.3.1", "@polkadot/api": "3.5.1",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.5.1",
"@polkadot/rpc-provider": "3.3.1", "@polkadot/rpc-provider": "3.5.1",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"handlebars": "^4.7.6", "handlebars": "^4.7.6",
"websocket": "^1.0.33", "websocket": "^1.0.33",
"yargs": "^16.2.0" "yargs": "^16.2.0"
@@ -72,7 +72,7 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
return generateInterfaceTypesTemplate({ return generateInterfaceTypesTemplate({
headerType: 'defs', headerType: 'defs',
imports, imports,
items, items: items.sort((a, b) => a.localeCompare(b)),
types types
}); });
}); });
+1 -1
View File
@@ -52,7 +52,7 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
const keys = (sub as TypeDef[]).map(({ info, name = '', type }): string => { const keys = (sub as TypeDef[]).map(({ info, name = '', type }): string => {
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_'))); const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.VecFixed].includes(info); const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
? '' ? ''
: createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, type, imports) : type, imports); : createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, type, imports) : type, imports);
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/types-known", "name": "@polkadot/types-known",
"version": "3.3.1", "version": "3.5.1",
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface", "description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -14,8 +14,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/types": "3.3.1", "@polkadot/types": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
+3
View File
@@ -5,6 +5,9 @@ import type { OverrideModuleType } from '@polkadot/types/types';
// type overrides for modules (where duplication between modules exist) // type overrides for modules (where duplication between modules exist)
const typesModules: Record<string, OverrideModuleType> = { const typesModules: Record<string, OverrideModuleType> = {
assets: {
Balance: 'TAssetBalance'
},
babe: { babe: {
EquivocationProof: 'BabeEquivocationProof' EquivocationProof: 'BabeEquivocationProof'
}, },
@@ -7,11 +7,18 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
const versioned: OverrideVersionedType[] = [ const versioned: OverrideVersionedType[] = [
{ {
minmax: [0, undefined], minmax: [0, 99],
types: { types: {
Address: 'AccountId', Address: 'AccountId',
LookupSource: 'AccountId' LookupSource: 'AccountId'
} }
},
{
minmax: [100, undefined],
types: {
Address: 'MultiAddress',
LookupSource: 'MultiAddress'
}
} }
]; ];
+9 -1
View File
@@ -16,12 +16,20 @@ const versioned: OverrideVersionedType[] = [
} }
}, },
{ {
minmax: [260, undefined], minmax: [260, 260],
types: { types: {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithRefCount',
Address: 'MultiAddress', Address: 'MultiAddress',
LookupSource: 'MultiAddress' LookupSource: 'MultiAddress'
} }
},
{
minmax: [261, undefined],
types: {
AccountInfo: 'AccountInfoWithProviders',
Address: 'MultiAddress',
LookupSource: 'MultiAddress'
}
} }
]; ];
+13 -9
View File
@@ -11,8 +11,9 @@ import type { OverrideVersionedType } from '@polkadot/types/types';
const sharedTypes = { const sharedTypes = {
AccountInfo: 'AccountInfoWithRefCount', AccountInfo: 'AccountInfoWithRefCount',
Address: 'AccountId', Address: 'AccountId',
Keys: 'SessionKeys5', FullIdentification: '()', // No staking, only session (as per config)
LookupSource: 'AccountId' LookupSource: 'AccountId',
Keys: 'SessionKeys6'
}; };
const versioned: OverrideVersionedType[] = [ const versioned: OverrideVersionedType[] = [
@@ -22,18 +23,21 @@ const versioned: OverrideVersionedType[] = [
...sharedTypes, ...sharedTypes,
CompactAssignments: 'CompactAssignmentsTo257', CompactAssignments: 'CompactAssignmentsTo257',
RefCount: 'RefCountTo259', RefCount: 'RefCountTo259',
RewardDestination: 'RewardDestinationTo257' RewardDestination: 'RewardDestinationTo257',
Keys: 'SessionKeys5'
} }
}, },
{ {
minmax: [10, undefined], minmax: [10, 12],
types: { types: {
...sharedTypes, ...sharedTypes,
ParaGenesisArgs: { Keys: 'SessionKeys5'
genesisHead: 'Bytes', }
validationCode: 'Bytes', },
parachain: 'bool' {
} minmax: [13, undefined],
types: {
...sharedTypes
} }
} }
]; ];
+1 -1
View File
@@ -10,7 +10,7 @@ const upgrades: ChainUpgradesRaw = {
[879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29], [879238, 25], [889472, 26], [902937, 27], [932751, 28], [991142, 29],
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35], [1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44], [1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
[2549864, 45] [2549864, 45], [3925782, 46], [3925843, 47]
] ]
}; };
+6 -6
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/types", "name": "@polkadot/types",
"version": "3.3.1", "version": "3.5.1",
"description": "Implementation of the Parity codec", "description": "Implementation of the Parity codec",
"main": "index.js", "main": "index.js",
"module": "index.mjs", "module": "index.mjs",
@@ -17,14 +17,14 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme", "homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.12.5", "@babel/runtime": "^7.12.5",
"@polkadot/metadata": "3.3.1", "@polkadot/metadata": "3.5.1",
"@polkadot/util": "^5.2.3", "@polkadot/util": "^5.3.1",
"@polkadot/util-crypto": "^5.2.3", "@polkadot/util-crypto": "^5.3.1",
"@polkadot/x-rxjs": "3.3.1", "@polkadot/x-rxjs": "3.5.1",
"@types/bn.js": "^4.11.6", "@types/bn.js": "^4.11.6",
"bn.js": "^4.11.9" "bn.js": "^4.11.9"
}, },
"devDependencies": { "devDependencies": {
"@polkadot/keyring": "^5.2.3" "@polkadot/keyring": "^5.3.1"
} }
} }
File diff suppressed because it is too large Load Diff
+6 -3
View File
@@ -78,8 +78,11 @@ export abstract class AbstractInt extends BN implements Codec {
this.#bitLength = bitLength; this.#bitLength = bitLength;
this.#isSigned = isSigned; this.#isSigned = isSigned;
assert(isSigned || this.gte(BN_ZERO), `${this.toRawType()}: Negative number passed to unsigned type`); const isPositive = this.gte(BN_ZERO);
assert(super.bitLength() <= bitLength, `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${bitLength}`); const maxBits = bitLength - (isSigned && isPositive ? 1 : 0);
assert(isSigned || isPositive, `${this.toRawType()}: Negative number passed to unsigned type`);
assert(super.bitLength() <= maxBits, `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${maxBits}`);
} }
/** /**
@@ -143,7 +146,7 @@ export abstract class AbstractInt extends BN implements Codec {
/** /**
* @description Returns a BigInt representation of the number * @description Returns a BigInt representation of the number
*/ */
public toBigInt (): BigInt { public toBigInt (): bigint {
return BigInt(this.toString()); return BigInt(this.toString());
} }
+2 -4
View File
@@ -4,7 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { compactFromU8a, compactToU8a, hexToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compactFromU8a, compactToU8a, isHex, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareSet, decodeU8a, typeToConstructor } from './utils'; import { compareSet, decodeU8a, typeToConstructor } from './utils';
@@ -67,9 +67,7 @@ function decodeSet<V extends Codec = Codec> (registry: Registry, valType: Constr
const ValClass = typeToConstructor(registry, valType); const ValClass = typeToConstructor(registry, valType);
if (isHex(value)) { if (isHex(value) || isU8a(value)) {
return decodeSet(registry, ValClass, hexToU8a(value));
} else if (isU8a(value)) {
return decodeSetFromU8a<V>(registry, ValClass, u8aToU8a(value)); return decodeSetFromU8a<V>(registry, ValClass, u8aToU8a(value));
} else if (Array.isArray(value) || value instanceof Set) { } else if (Array.isArray(value) || value instanceof Set) {
return decodeSetFromSet<V>(registry, ValClass, value); return decodeSetFromSet<V>(registry, ValClass, value);
+3 -1
View File
@@ -73,7 +73,9 @@ describe('Compact', (): void => {
}); });
it('has a valid toBigInt interface', (): void => { it('has a valid toBigInt interface', (): void => {
expect(new (Compact.with('u128'))(registry, 12345678987654321n).toBigInt() === 12345678987654321n).toBe(true); expect(
(new (Compact.with('u128'))(registry, 12345678987654321n).toBigInt() + 1n) === 12345678987654322n
).toBe(true);
}); });
}); });
}); });
+1 -1
View File
@@ -95,7 +95,7 @@ export class Compact<T extends CompactEncodable> implements ICompact<T> {
/** /**
* @description Returns a BigInt representation of the number * @description Returns a BigInt representation of the number
*/ */
public toBigInt (): BigInt { public toBigInt (): bigint {
return BigInt(this.toString()); return BigInt(this.toString());
} }
+6
View File
@@ -59,6 +59,12 @@ describe('Date', (): void => {
new CodecDate(registry, 3).toHex(true) new CodecDate(registry, 3).toHex(true)
).toEqual('0x0300000000000000'); ).toEqual('0x0300000000000000');
}); });
it('encodes correctly to BigInt', (): void => {
expect(
new CodecDate(registry, 41).toBigInt() + 1n
).toEqual(42n);
});
}); });
describe('utils', (): void => { describe('utils', (): void => {
+1 -1
View File
@@ -83,7 +83,7 @@ export class CodecDate extends Date implements Codec {
/** /**
* @description Returns a BigInt representation of the number * @description Returns a BigInt representation of the number
*/ */
public toBigInt (): BigInt { public toBigInt (): bigint {
return BigInt(this.toNumber()); return BigInt(this.toNumber());
} }
+2 -4
View File
@@ -4,7 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { compactFromU8a, compactToU8a, hexToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util'; import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
import { compareMap, decodeU8a, typeToConstructor } from './utils'; import { compareMap, decodeU8a, typeToConstructor } from './utils';
@@ -74,9 +74,7 @@ function decodeMap<K extends Codec = Codec, V extends Codec = Codec> (registry:
if (!value) { if (!value) {
return new Map<K, V>(); return new Map<K, V>();
} else if (isHex(value)) { } else if (isU8a(value) || isHex(value)) {
return decodeMap(registry, KeyClass, ValClass, hexToU8a(value));
} else if (isU8a(value)) {
return decodeMapFromU8a<K, V>(registry, KeyClass, ValClass, u8aToU8a(value)); return decodeMapFromU8a<K, V>(registry, KeyClass, ValClass, u8aToU8a(value));
} else if (value instanceof Map) { } else if (value instanceof Map) {
return decodeMapFromMap<K, V>(registry, KeyClass, ValClass, value); return decodeMapFromMap<K, V>(registry, KeyClass, ValClass, value);
+3 -12
View File
@@ -4,16 +4,7 @@
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { AnyJson, AnyU8a, IU8a, Registry } from '../types'; import type { AnyJson, AnyU8a, IU8a, Registry } from '../types';
import { assert, isAscii, isU8a, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util'; import { assert, isAscii, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
/** @internal */
function decodeU8a (value?: any): Uint8Array {
if (isU8a(value)) {
return value;
}
return u8aToU8a(value);
}
/** /**
* @name Raw * @name Raw
@@ -28,7 +19,7 @@ export class Raw extends Uint8Array implements IU8a {
public readonly registry: Registry; public readonly registry: Registry;
constructor (registry: Registry, value?: AnyU8a) { constructor (registry: Registry, value?: AnyU8a) {
super(decodeU8a(value)); super(u8aToU8a(value));
this.registry = registry; this.registry = registry;
} }
@@ -92,7 +83,7 @@ export class Raw extends Uint8Array implements IU8a {
!this.some((value, index) => value !== other[index]); !this.some((value, index) => value !== other[index]);
} }
return this.eq(decodeU8a(other)); return this.eq(u8aToU8a(other as any));
} }
/** /**
+3 -5
View File
@@ -3,7 +3,7 @@
import type { AnyNumber, AnyString, AnyU8a, Codec, Constructor, InterfaceTypes, Registry } from '../types'; import type { AnyNumber, AnyString, AnyU8a, Codec, Constructor, InterfaceTypes, Registry } from '../types';
import { hexToU8a, isHex, isU8a, u8aConcat } from '@polkadot/util'; import { isHex, isU8a, u8aConcat, u8aToU8a } from '@polkadot/util';
import { AbstractArray } from './AbstractArray'; import { AbstractArray } from './AbstractArray';
import { decodeU8a, mapToTypeMap, typeToConstructor } from './utils'; import { decodeU8a, mapToTypeMap, typeToConstructor } from './utils';
@@ -20,10 +20,8 @@ type TupleTypes = (Constructor | keyof InterfaceTypes)[] | {
/** @internal */ /** @internal */
function decodeTuple (registry: Registry, _Types: TupleConstructors, value?: AnyTuple): Codec[] { function decodeTuple (registry: Registry, _Types: TupleConstructors, value?: AnyTuple): Codec[] {
if (isU8a(value)) { if (isU8a(value) || isHex(value)) {
return decodeU8a(registry, value, _Types); return decodeU8a(registry, u8aToU8a(value), _Types);
} else if (isHex(value)) {
return decodeTuple(registry, _Types, hexToU8a(value));
} }
const Types: Constructor[] = Array.isArray(_Types) const Types: Constructor[] = Array.isArray(_Types)
+6
View File
@@ -45,6 +45,12 @@ describe('UInt', (): void => {
).toEqual(4567); ).toEqual(4567);
}); });
it('has a working toBigInt', (): void => {
expect(
new UInt(registry, 4567).toBigInt() + BigInt(1)
).toEqual(BigInt(4568));
});
it('converts to Little Endian from the provided value', (): void => { it('converts to Little Endian from the provided value', (): void => {
expect( expect(
new UInt(registry, 1234567).toU8a() new UInt(registry, 1234567).toU8a()
+8 -8
View File
@@ -3,8 +3,6 @@
import type { Codec, Constructor, Registry } from '../../types'; import type { Codec, Constructor, Registry } from '../../types';
import { arrayFlatten } from '@polkadot/util';
/** /**
* Given an u8a, and an array of Type constructors, decode the u8a against the * Given an u8a, and an array of Type constructors, decode the u8a against the
* types, and return an array of decoded values. * types, and return an array of decoded values.
@@ -16,13 +14,15 @@ export function decodeU8a (registry: Registry, u8a: Uint8Array, _types: Construc
const types = Array.isArray(_types) const types = Array.isArray(_types)
? _types ? _types
: Object.values(_types); : Object.values(_types);
const result: Codec[] = [];
let offset = 0;
if (!types.length) { for (let i = 0; i < types.length; i++) {
return []; const value = new types[i](registry, u8a.subarray(offset));
result.push(value);
offset += value.encodedLength;
} }
const Type = types[0]; return result;
const value = new Type(registry, u8a);
return arrayFlatten([[value], decodeU8a(registry, u8a.subarray(value.encodedLength), types.slice(1))]);
} }
+13 -7
View File
@@ -3,6 +3,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */ /* eslint-disable @typescript-eslint/no-var-requires */
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types'; import type { ChainProperties, DispatchErrorModule, H256 } from '../interfaces/types';
import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types'; import type { CallFunction, Codec, Constructor, InterfaceTypes, RegisteredTypes, Registry, RegistryError, RegistryTypes } from '../types';
@@ -38,8 +39,9 @@ function injectErrors (_: Registry, metadata: Metadata, metadataErrors: Record<s
const eventIndex = new Uint8Array([sectionIndex, index]); const eventIndex = new Uint8Array([sectionIndex, index]);
metadataErrors[u8aToHex(eventIndex)] = { metadataErrors[u8aToHex(eventIndex)] = {
documentation: documentation.map((d): string => d.toString()), documentation: documentation.map((d) => d.toString()),
index, index,
method: name.toString(),
name: name.toString(), name: name.toString(),
section: sectionName section: sectionName
}; };
@@ -133,6 +135,8 @@ export class TypeRegistry implements Registry {
#signedExtensions: string[] = defaultExtensions; #signedExtensions: string[] = defaultExtensions;
#userExtensions?: Record<string, ExtDef>;
constructor () { constructor () {
this.#knownDefaults = { Json, Metadata, Raw, ...baseTypes }; this.#knownDefaults = { Json, Metadata, Raw, ...baseTypes };
this.#knownDefinitions = definitions as unknown as Record<string, { types: RegistryTypes }>; this.#knownDefinitions = definitions as unknown as Record<string, { types: RegistryTypes }>;
@@ -277,11 +281,11 @@ export class TypeRegistry implements Registry {
} }
public getSignedExtensionExtra (): Record<string, keyof InterfaceTypes> { public getSignedExtensionExtra (): Record<string, keyof InterfaceTypes> {
return expandExtensionTypes(this.#signedExtensions, 'extra'); return expandExtensionTypes(this.#signedExtensions, 'payload', this.#userExtensions);
} }
public getSignedExtensionTypes (): Record<string, keyof InterfaceTypes> { public getSignedExtensionTypes (): Record<string, keyof InterfaceTypes> {
return expandExtensionTypes(this.#signedExtensions, 'types'); return expandExtensionTypes(this.#signedExtensions, 'extrinsic', this.#userExtensions);
} }
public hasClass (name: string): boolean { public hasClass (name: string): boolean {
@@ -355,7 +359,7 @@ export class TypeRegistry implements Registry {
} }
// sets the metadata // sets the metadata
public setMetadata (metadata: Metadata, signedExtensions?: string[]): void { public setMetadata (metadata: Metadata, signedExtensions?: string[], userExtensions?: Record<string, ExtDef>): void {
injectExtrinsics(this, metadata, this.#metadataCalls); injectExtrinsics(this, metadata, this.#metadataCalls);
injectErrors(this, metadata, this.#metadataErrors); injectErrors(this, metadata, this.#metadataErrors);
injectEvents(this, metadata, this.#metadataEvents); injectEvents(this, metadata, this.#metadataEvents);
@@ -366,7 +370,8 @@ export class TypeRegistry implements Registry {
metadata.asLatest.extrinsic.version.gt(BN_ZERO) metadata.asLatest.extrinsic.version.gt(BN_ZERO)
? metadata.asLatest.extrinsic.signedExtensions.map((key) => key.toString()) ? metadata.asLatest.extrinsic.signedExtensions.map((key) => key.toString())
: defaultExtensions : defaultExtensions
) ),
userExtensions
); );
// setup the chain properties with format overrides // setup the chain properties with format overrides
@@ -376,10 +381,11 @@ export class TypeRegistry implements Registry {
} }
// sets the available signed extensions // sets the available signed extensions
setSignedExtensions (signedExtensions: string[] = defaultExtensions): void { setSignedExtensions (signedExtensions: string[] = defaultExtensions, userExtensions?: Record<string, ExtDef>): void {
this.#signedExtensions = signedExtensions; this.#signedExtensions = signedExtensions;
this.#userExtensions = userExtensions;
const unknown = findUnknownExtensions(this.#signedExtensions); const unknown = findUnknownExtensions(this.#signedExtensions, this.#userExtensions);
if (unknown.length) { if (unknown.length) {
l.warn(`Unknown signed extensions ${unknown.join(', ')} found, treating them as no-effect`); l.warn(`Unknown signed extensions ${unknown.join(', ')} found, treating them as no-effect`);
@@ -2,6 +2,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
export const emptyCheck = { export const emptyCheck = {
extra: {}, extrinsic: {},
types: {} payload: {}
}; };
@@ -9,7 +9,7 @@ import substrateExtensions from './substrate';
// A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions, // A mapping of the known signed extensions to the extra fields that they contain. Unlike in the actual extensions,
// we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded // we define the extra fields not as a Tuple, but rather as a struct so they can be named. These will be expanded
// into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are // into the various fields when added to the payload (we only support V4 onwards with these, V3 and earlier are
// deemded fixed and non-changeable) // deemed fixed and non-changeable)
const allExtensions: ExtDef = { const allExtensions: ExtDef = {
...substrateExtensions, ...substrateExtensions,
...polkadotExtensions ...polkadotExtensions
@@ -26,16 +26,16 @@ const defaultExtensions: Array<keyof typeof allExtensions> = [
'CheckBlockGasLimit' 'CheckBlockGasLimit'
]; ];
function findUnknownExtensions (extensions: string[]): string[] { function findUnknownExtensions (extensions: string[], userExtensions: Record<string, ExtDef> = {}): string[] {
const names = Object.keys(allExtensions); const names = [...Object.keys(allExtensions), ...Object.keys(userExtensions)];
return extensions.filter((key): boolean => !names.includes(key)); return extensions.filter((key) => !names.includes(key));
} }
function expandExtensionTypes (extensions: string[], type: keyof ExtInfo): ExtTypes { function expandExtensionTypes (extensions: string[], type: keyof ExtInfo, userExtensions: Record<string, ExtDef> = {}): ExtTypes {
return extensions return extensions
.map((key): ExtInfo => allExtensions[key]) .map((key) => allExtensions[key] || userExtensions[key])
.filter((info): boolean => !!info) .filter((info): info is ExtInfo => !!info)
.reduce((result, info): ExtTypes => ({ ...result, ...info[type] }), {}); .reduce((result, info): ExtTypes => ({ ...result, ...info[type] }), {});
} }
@@ -6,53 +6,53 @@ import type { ExtDef } from './types';
import { emptyCheck } from './emptyCheck'; import { emptyCheck } from './emptyCheck';
const CheckMortality = { const CheckMortality = {
extra: { extrinsic: {
blockHash: 'Hash'
},
types: {
era: 'ExtrinsicEra' era: 'ExtrinsicEra'
},
payload: {
blockHash: 'Hash'
} }
}; };
export default { export default {
ChargeTransactionPayment: { ChargeTransactionPayment: {
extra: {}, extrinsic: {
types: {
tip: 'Compact<Balance>' tip: 'Compact<Balance>'
} },
payload: {}
}, },
CheckBlockGasLimit: emptyCheck, CheckBlockGasLimit: emptyCheck,
CheckEra: CheckMortality, CheckEra: CheckMortality,
CheckGenesis: { CheckGenesis: {
extra: { extrinsic: {},
payload: {
genesisHash: 'Hash' genesisHash: 'Hash'
}, }
types: {}
}, },
CheckMortality, CheckMortality,
CheckNonce: { CheckNonce: {
extra: {}, extrinsic: {
types: {
nonce: 'Compact<Index>' nonce: 'Compact<Index>'
} },
payload: {}
}, },
CheckSpecVersion: { CheckSpecVersion: {
extra: { extrinsic: {},
payload: {
specVersion: 'u32' specVersion: 'u32'
}, }
types: {}
}, },
CheckTxVersion: { CheckTxVersion: {
extra: { extrinsic: {},
payload: {
transactionVersion: 'u32' transactionVersion: 'u32'
}, }
types: {}
}, },
CheckVersion: { CheckVersion: {
extra: { extrinsic: {},
payload: {
specVersion: 'u32' specVersion: 'u32'
}, }
types: {}
}, },
CheckWeight: emptyCheck, CheckWeight: emptyCheck,
LockStakingStatus: emptyCheck, LockStakingStatus: emptyCheck,
@@ -6,8 +6,8 @@ import type { InterfaceTypes } from '../../types';
export type ExtTypes = Record<string, keyof InterfaceTypes>; export type ExtTypes = Record<string, keyof InterfaceTypes>;
export type ExtInfo = { export type ExtInfo = {
extra: ExtTypes; extrinsic: ExtTypes;
types: ExtTypes; payload: ExtTypes;
} }
export type ExtDef = Record<string, ExtInfo>; export type ExtDef = Record<string, ExtInfo>;
@@ -26,7 +26,7 @@ export default {
zombies: 'u32', zombies: 'u32',
accounts: 'u32' accounts: 'u32'
}, },
TAssetBalance: 'Balance', TAssetBalance: 'u64',
TAssetDepositBalance: 'BalanceOf' TAssetDepositBalance: 'BalanceOf'
} }
} as Definitions; } as Definitions;
@@ -1,8 +1,8 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit // Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */ /* eslint-disable */
import type { Struct, bool, u32 } from '@polkadot/types'; import type { Struct, bool, u32, u64 } from '@polkadot/types';
import type { AccountId, Balance, BalanceOf } from '@polkadot/types/interfaces/runtime'; import type { AccountId, BalanceOf } from '@polkadot/types/interfaces/runtime';
/** @name AssetBalance */ /** @name AssetBalance */
export interface AssetBalance extends Struct { export interface AssetBalance extends Struct {
@@ -26,7 +26,7 @@ export interface AssetDetails extends Struct {
} }
/** @name TAssetBalance */ /** @name TAssetBalance */
export interface TAssetBalance extends Balance {} export interface TAssetBalance extends u64 {}
/** @name TAssetDepositBalance */ /** @name TAssetDepositBalance */
export interface TAssetDepositBalance extends BalanceOf {} export interface TAssetDepositBalance extends BalanceOf {}
@@ -136,6 +136,10 @@ export default {
} }
}, },
ContractStorageKey: '[u8; 32]', ContractStorageKey: '[u8; 32]',
DeletedContract: {
pairCount: 'u32',
trieId: 'TrieId'
},
Gas: 'u64', Gas: 'u64',
HostFnWeights: { HostFnWeights: {
caller: 'Weight', caller: 'Weight',
@@ -104,6 +104,12 @@ export interface ContractInfo extends Enum {
/** @name ContractStorageKey */ /** @name ContractStorageKey */
export interface ContractStorageKey extends U8aFixed {} export interface ContractStorageKey extends U8aFixed {}
/** @name DeletedContract */
export interface DeletedContract extends Struct {
readonly pairCount: u32;
readonly trieId: TrieId;
}
/** @name Gas */ /** @name Gas */
export interface Gas extends u64 {} export interface Gas extends u64 {}
@@ -0,0 +1,38 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { Definitions } from '../../types';
export default {
rpc: {},
types: {
FundIndex: 'u32',
LastContribution: {
_enum: {
Never: 'Null',
PreEnding: 'AuctionIndex',
Ending: 'BlockNumber'
}
},
DeployData: {
codeHash: 'Hash',
codeSize: 'u32',
initialHeadData: 'HeadData'
},
FundInfo: {
parachain: 'Option<ParaId>',
owner: 'AccountId',
deposit: 'Balance',
raised: 'Balance',
end: 'BlockNumber',
cap: 'Balance',
lastContribution: 'LastContribution',
firstSlot: 'BlockNumber',
lastSlot: 'BlockNumber',
deployData: 'Option<DeployData>'
}
}
} as Definitions;
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
export * from './types';
@@ -0,0 +1,41 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Enum, Option, Struct, u32 } from '@polkadot/types';
import type { AuctionIndex, HeadData, ParaId } from '@polkadot/types/interfaces/parachains';
import type { AccountId, Balance, BlockNumber, Hash } from '@polkadot/types/interfaces/runtime';
/** @name DeployData */
export interface DeployData extends Struct {
readonly codeHash: Hash;
readonly codeSize: u32;
readonly initialHeadData: HeadData;
}
/** @name FundIndex */
export interface FundIndex extends u32 {}
/** @name FundInfo */
export interface FundInfo extends Struct {
readonly parachain: Option<ParaId>;
readonly owner: AccountId;
readonly deposit: Balance;
readonly raised: Balance;
readonly end: BlockNumber;
readonly cap: Balance;
readonly lastContribution: LastContribution;
readonly firstSlot: BlockNumber;
readonly lastSlot: BlockNumber;
readonly deployData: Option<DeployData>;
}
/** @name LastContribution */
export interface LastContribution extends Enum {
readonly isNever: boolean;
readonly isPreEnding: boolean;
readonly asPreEnding: AuctionIndex;
readonly isEnding: boolean;
readonly asEnding: BlockNumber;
}
export type PHANTOM_CROWDLOAN = 'crowdloan';
@@ -22,6 +22,7 @@ export { default as genericAsset } from './genericAsset/definitions';
export { default as grandpa } from './grandpa/definitions'; export { default as grandpa } from './grandpa/definitions';
export { default as identity } from './identity/definitions'; export { default as identity } from './identity/definitions';
export { default as imOnline } from './imOnline/definitions'; export { default as imOnline } from './imOnline/definitions';
export { default as lottery } from './lottery/definitions';
export { default as offences } from './offences/definitions'; export { default as offences } from './offences/definitions';
export { default as proxy } from './proxy/definitions'; export { default as proxy } from './proxy/definitions';
export { default as recovery } from './recovery/definitions'; export { default as recovery } from './recovery/definitions';
@@ -40,6 +41,7 @@ export { default as vesting } from './vesting/definitions';
// polkadot-specific types // polkadot-specific types
export { default as attestations } from './attestations/definitions'; export { default as attestations } from './attestations/definitions';
export { default as claims } from './claims/definitions'; export { default as claims } from './claims/definitions';
export { default as crowdloan } from './crowdloan/definitions';
export { default as parachains } from './parachains/definitions'; export { default as parachains } from './parachains/definitions';
export { default as poll } from './poll/definitions'; export { default as poll } from './poll/definitions';
export { default as purchase } from './purchase/definitions'; export { default as purchase } from './purchase/definitions';
@@ -176,26 +176,46 @@ const types: DefinitionsTypes = {
} }
}, },
EthTransaction: { EthTransaction: {
blockHash: 'Option<H256>',
blockNumber: 'Option<U256>',
chainId: 'Option<u64>',
condition: 'Option<EthTransactionCondition>',
creates: 'Option<H160>',
from: 'H160',
gas: 'U256',
gasPrice: 'U256',
hash: 'H256',
input: 'Bytes',
nonce: 'U256', nonce: 'U256',
publicKey: 'Option<H512>', gasPrice: 'U256',
r: 'U256', gasLimit: 'U256',
raw: 'Bytes', action: 'EthTransactionAction',
s: 'U256', value: 'U256',
standardV: 'U256', input: 'Bytes',
to: 'Option<H160>', // TransactionSignature (embedded)
transactionIndex: 'Option<U256>', v: 'u64',
v: 'U256', r: 'H256',
value: 'U256' s: 'H256'
},
// as per the RPC definition
// TODO: Check these, re-add
// EthTransaction: {
// // hash in Rust
// transactionHash: 'H256',
// nonce: 'U256',
// blockHash: 'Option<H256>',
// blockNumber: 'Option<U256>',
// transactionIndex: 'Option<U256>',
// from: 'H160',
// to: 'Option<H160>',
// value: 'U256',
// gasPrice: 'U256',
// gas: 'U256',
// input: 'Bytes',
// creates: 'Option<H160>',
// raw: 'Bytes',
// publicKey: 'Option<H512>',
// chainId: 'Option<U64>',
// standardV: 'U256',
// v: 'U256',
// r: 'U256',
// s: 'U256'
// },
EthTransactionAction: {
_enum: {
Call: 'H160',
Create: 'Null'
}
}, },
EthTransactionCondition: { EthTransactionCondition: {
_enum: { _enum: {
+15 -19
View File
@@ -2,7 +2,7 @@
/* eslint-disable */ /* eslint-disable */
import type { Bytes, Enum, GenericEthereumAccountId, GenericEthereumLookupSource, Option, Struct, U256, U64, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types'; import type { Bytes, Enum, GenericEthereumAccountId, GenericEthereumLookupSource, Option, Struct, U256, U64, U8aFixed, Vec, bool, u32, u64 } from '@polkadot/types';
import type { BlockNumber, H160, H2048, H256, H512 } from '@polkadot/types/interfaces/runtime'; import type { BlockNumber, H160, H2048, H256 } from '@polkadot/types/interfaces/runtime';
/** @name EthAccount */ /** @name EthAccount */
export interface EthAccount extends Struct { export interface EthAccount extends Struct {
@@ -211,26 +211,22 @@ export interface EthSyncStatus extends Enum {
/** @name EthTransaction */ /** @name EthTransaction */
export interface EthTransaction extends Struct { export interface EthTransaction extends Struct {
readonly blockHash: Option<H256>;
readonly blockNumber: Option<U256>;
readonly chainId: Option<u64>;
readonly condition: Option<EthTransactionCondition>;
readonly creates: Option<H160>;
readonly from: H160;
readonly gas: U256;
readonly gasPrice: U256;
readonly hash: H256;
readonly input: Bytes;
readonly nonce: U256; readonly nonce: U256;
readonly publicKey: Option<H512>; readonly gasPrice: U256;
readonly r: U256; readonly gasLimit: U256;
readonly raw: Bytes; readonly action: EthTransactionAction;
readonly s: U256;
readonly standardV: U256;
readonly to: Option<H160>;
readonly transactionIndex: Option<U256>;
readonly v: U256;
readonly value: U256; readonly value: U256;
readonly input: Bytes;
readonly v: u64;
readonly r: H256;
readonly s: H256;
}
/** @name EthTransactionAction */
export interface EthTransactionAction extends Enum {
readonly isCall: boolean;
readonly asCall: H160;
readonly isCreate: boolean;
} }
/** @name EthTransactionCondition */ /** @name EthTransactionCondition */
@@ -0,0 +1,21 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
import type { Definitions } from '../../types';
export default {
rpc: {},
types: {
CallIndex: '(u8, u8)',
LotteryConfig: {
price: 'Balance',
start: 'BlockNumber',
length: 'BlockNumber',
delay: 'BlockNumber',
repeat: 'bool'
}
}
} as Definitions;
@@ -0,0 +1,4 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
export * from './types';
@@ -0,0 +1,20 @@
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
/* eslint-disable */
import type { Struct, bool, u8 } from '@polkadot/types';
import type { ITuple } from '@polkadot/types/types';
import type { Balance, BlockNumber } from '@polkadot/types/interfaces/runtime';
/** @name CallIndex */
export interface CallIndex extends ITuple<[u8, u8]> {}
/** @name LotteryConfig */
export interface LotteryConfig extends Struct {
readonly price: Balance;
readonly start: BlockNumber;
readonly length: BlockNumber;
readonly delay: BlockNumber;
readonly repeat: bool;
}
export type PHANTOM_LOTTERY = 'lottery';
@@ -6,15 +6,17 @@
import type { Definitions } from '../../types'; import type { Definitions } from '../../types';
const SLOT_RANGE_COUNT = 10; import hrmpTypes from './hrmp';
import slotTypes from './slots';
// proposeParachain
const proposeTypes = { const proposeTypes = {
ParachainProposal: { ParachainProposal: {
proposer: 'AccountId', proposer: 'AccountId',
validationFunction: 'ValidationCode', validationCode: 'ValidationCode',
initialHeadState: 'HeadData', genesisHead: 'HeadData',
validators: 'Vec<ValidatorId>', validators: 'Vec<ValidatorId>',
name: 'Vec<u8>', name: 'Bytes',
balance: 'Balance' balance: 'Balance'
}, },
RegisteredParachainInfo: { RegisteredParachainInfo: {
@@ -27,6 +29,8 @@ export default {
rpc: {}, rpc: {},
types: { types: {
...proposeTypes, ...proposeTypes,
...hrmpTypes,
...slotTypes,
AbridgedCandidateReceipt: { AbridgedCandidateReceipt: {
parachainIndex: 'ParaId', parachainIndex: 'ParaId',
relayParent: 'Hash', relayParent: 'Hash',
@@ -36,6 +40,25 @@ export default {
povBlockHash: 'Hash', povBlockHash: 'Hash',
commitments: 'CandidateCommitments' commitments: 'CandidateCommitments'
}, },
AbridgedHostConfiguration: {
maxCodeSize: 'u32',
maxHeadDataSize: 'u32',
maxUpwardQueueCount: 'u32',
maxUpwardQueueSize: 'u32',
maxUpwardMessageSize: 'u32',
maxUpwardMessageNumPerCandidate: 'u32',
hrmpMaxMessageNumPerCandidate: 'u32',
validationUpgradeFrequency: 'BlockNumber',
validationUpgradeDelay: 'BlockNumber'
},
AbridgedHrmpChannel: {
maxCapacity: 'u32',
maxTotalSize: 'u32',
maxMessageSize: 'u32',
msgCount: 'u32',
totalSize: 'u32',
mqcHead: 'Option<Hash>'
},
AssignmentId: 'AccountId', AssignmentId: 'AccountId',
AssignmentKind: { AssignmentKind: {
_enum: { _enum: {
@@ -49,7 +72,6 @@ export default {
validatorIndices: 'BitVec' validatorIndices: 'BitVec'
}, },
AuthorityDiscoveryId: 'AccountId', AuthorityDiscoveryId: 'AccountId',
AuctionIndex: 'u32',
AvailabilityBitfield: 'BitVec', AvailabilityBitfield: 'BitVec',
AvailabilityBitfieldRecord: { AvailabilityBitfieldRecord: {
bitfield: 'AvailabilityBitfield', bitfield: 'AvailabilityBitfield',
@@ -60,12 +82,6 @@ export default {
validityVotes: 'Vec<ValidityAttestation>', validityVotes: 'Vec<ValidityAttestation>',
validatorIndices: 'BitVec' validatorIndices: 'BitVec'
}, },
Bidder: {
_enum: {
New: 'NewBidder',
Existing: 'ParaId'
}
},
BufferedSessionChange: { BufferedSessionChange: {
applyAt: 'BlockNumber', applyAt: 'BlockNumber',
validators: 'Vec<ValidatorId>', validators: 'Vec<ValidatorId>',
@@ -83,11 +99,11 @@ export default {
CandidateDescriptor: { CandidateDescriptor: {
paraId: 'ParaId', paraId: 'ParaId',
relayParent: 'Hash', relayParent: 'Hash',
collatorId: 'Hash', collatorId: 'CollatorId',
persistedValidationDataHash: 'Hash', persistedValidationDataHash: 'Hash',
povHash: 'Hash', povHash: 'Hash',
erasureRoot: 'Hash', erasureRoot: 'Hash',
signature: 'Signature' signature: 'CollatorSignature'
}, },
CandidateHash: 'Hash', CandidateHash: 'Hash',
CandidatePendingAvailability: { CandidatePendingAvailability: {
@@ -103,7 +119,7 @@ export default {
descriptor: 'CandidateDescriptor', descriptor: 'CandidateDescriptor',
commitmentsHash: 'Hash' commitmentsHash: 'Hash'
}, },
CollatorId: '[u8; 32]', CollatorId: 'H256',
CollatorSignature: 'Signature', CollatorSignature: 'Signature',
CommittedCandidateReceipt: { CommittedCandidateReceipt: {
descriptor: 'CandidateDescriptor', descriptor: 'CandidateDescriptor',
@@ -138,12 +154,29 @@ export default {
}, },
HeadData: 'Bytes', HeadData: 'Bytes',
HostConfiguration: { HostConfiguration: {
validationUpgradeFrequency: 'BlockNumber',
validationUpgradeDelay: 'BlockNumber',
acceptancePeriod: 'BlockNumber',
maxCodeSize: 'u32', maxCodeSize: 'u32',
maxHeadDataSize: 'u32', maxHeadDataSize: 'u32',
maxUpwardQueueCount: 'u32',
maxUpwardQueueSize: 'u32',
maxUpwardMessageSize: 'u32',
maxUpwardMessageNumPerCandidate: 'u32',
hrmpMaxMessageNumPerCandidate: 'u32',
validationUpgradeFrequency: 'BlockNumber',
validationUpgradeDelay: 'BlockNumber',
maxPovSize: 'u32', maxPovSize: 'u32',
maxDownwardMessageSize: 'u32',
preferredDispatchableUpwardMessagesStepWeight: 'Weight',
hrmpMaxParachainOutboundChannels: 'u32',
hrmpMaxParathreadOutboundChannels: 'u32',
hrmpOpenRequestTtl: 'u32',
hrmpSenderDeposit: 'Balance',
hrmpRecipientDeposit: 'Balance',
hrmpChannelMaxCapacity: 'u32',
hrmpChannelMaxTotalSize: 'u32',
hrmpMaxParachainInboundChannels: 'u32',
hrmpMaxParathreadInboundChannels: 'u32',
hrmpChannelMaxMessageSize: 'u32',
acceptancePeriod: 'BlockNumber',
parathreadCores: 'u32', parathreadCores: 'u32',
parathreadRetries: 'u32', parathreadRetries: 'u32',
groupRotationFrequency: 'BlockNumber', groupRotationFrequency: 'BlockNumber',
@@ -156,46 +189,7 @@ export default {
nDelayTranches: 'u32', nDelayTranches: 'u32',
zerothDelayTrancheWidth: 'u32', zerothDelayTrancheWidth: 'u32',
neededApprovals: 'u32', neededApprovals: 'u32',
relayVrfModuloSamples: 'u32', relayVrfModuloSamples: 'u32'
maxUpwardQueueCount: 'u32',
maxUpwardQueueSize: 'u32',
maxDownwardMessageSize: 'u32',
preferredDispatchableUpwardMessagesStepWeight: 'Weight',
maxUpwardMessageSize: 'u32',
maxUpwardMessageNumPerCandidate: 'u32',
hrmpOpenRequestTtl: 'u32',
hrmpSenderDeposit: 'Balance',
hrmpRecipientDeposit: 'Balance',
hrmpChannelMaxCapacity: 'u32',
hrmpChannelMaxTotalSize: 'u32',
hrmpMaxParachainInboundChannels: 'u32',
hrmpMaxParathreadInboundChannels: 'u32',
hrmpChannelMaxMessageSize: 'u32',
hrmpMaxParachainOutboundChannels: 'u32',
hrmpMaxParathreadOutboundChannels: 'u32',
hrmpMaxMessageNumPerCandidate: 'u32'
},
HrmpChannel: {
senderDeposit: 'Balance',
recipientDeposit: 'Balance',
maxCapacity: 'u32',
maxTotalSize: 'u32',
maxMessageSize: 'u32',
msgCount: 'u32',
totalSize: 'u32',
mqcHead: 'Option<Hash>'
},
HrmpChannelId: {
sender: 'u32',
receiver: 'u32'
},
HrmpOpenChannelRequest: {
confirmed: 'bool',
age: 'SessionIndex',
senderDeposit: 'Balance',
maxMessageSize: 'u32',
maxCapacity: 'u32',
maxTotalSize: 'u32'
}, },
InboundDownwardMessage: { InboundDownwardMessage: {
pubSentAt: 'BlockNumber', pubSentAt: 'BlockNumber',
@@ -206,24 +200,6 @@ export default {
data: 'Bytes' data: 'Bytes'
}, },
InboundHrmpMessages: 'Vec<InboundHrmpMessage>', InboundHrmpMessages: 'Vec<InboundHrmpMessage>',
IncomingParachain: {
_enum: {
Unset: 'NewBidder',
Fixed: 'IncomingParachainFixed',
Deploy: 'IncomingParachainDeploy'
}
},
IncomingParachainFixed: {
codeHash: 'Hash',
codeSize: 'u32',
initialHeadData: 'HeadData'
},
IncomingParachainDeploy: {
code: 'ValidationCode',
initialHeadData: 'HeadData'
},
LeasePeriod: 'BlockNumber',
LeasePeriodOf: 'LeasePeriod',
LocalValidationData: { LocalValidationData: {
parentHead: 'HeadData', parentHead: 'HeadData',
balance: 'Balance', balance: 'Balance',
@@ -233,10 +209,6 @@ export default {
downwardMessages: 'Vec<InboundDownwardMessage>', downwardMessages: 'Vec<InboundDownwardMessage>',
horizontalMessages: 'BTreeMap<ParaId, InboundHrmpMessages>' horizontalMessages: 'BTreeMap<ParaId, InboundHrmpMessages>'
}, },
NewBidder: {
who: 'AccountId',
sub: 'SubId'
},
OutboundHrmpMessage: { OutboundHrmpMessage: {
recipient: 'u32', recipient: 'u32',
data: 'Bytes' data: 'Bytes'
@@ -244,6 +216,11 @@ export default {
ParachainDispatchOrigin: { ParachainDispatchOrigin: {
_enum: ['Signed', 'Parachain', 'Root'] _enum: ['Signed', 'Parachain', 'Root']
}, },
ParaGenesisArgs: {
genesisHead: 'Bytes',
validationCode: 'Bytes',
parachain: 'bool'
},
ParaId: 'u32', ParaId: 'u32',
ParaInfo: { ParaInfo: {
scheduling: 'Scheduling' scheduling: 'Scheduling'
@@ -267,6 +244,7 @@ export default {
PersistedValidationData: { PersistedValidationData: {
parentHead: 'HeadData', parentHead: 'HeadData',
blockNumber: 'BlockNumber', blockNumber: 'BlockNumber',
relayStorageRoot: 'Hash',
hrmpMqcHeads: 'Vec<(u32, Hash)>', hrmpMqcHeads: 'Vec<(u32, Hash)>',
dmqMqcHead: 'Hash', dmqMqcHead: 'Hash',
maxPovSize: 'u32' maxPovSize: 'u32'
@@ -290,7 +268,7 @@ export default {
validators: 'Vec<ValidatorId>', validators: 'Vec<ValidatorId>',
discoveryKeys: 'Vec<AuthorityDiscoveryId>', discoveryKeys: 'Vec<AuthorityDiscoveryId>',
assignmentKeys: 'Vec<AssignmentId>', assignmentKeys: 'Vec<AssignmentId>',
validatorGroups: 'Vec<ValidatorGroup>', validatorGroups: 'Vec<SessionInfoValidatorGroup>',
nCores: 'u32', nCores: 'u32',
zerothDelayTrancheWidth: 'u32', zerothDelayTrancheWidth: 'u32',
relayVrfModuloSamples: 'u32', relayVrfModuloSamples: 'u32',
@@ -298,19 +276,17 @@ export default {
noShowSlots: 'u32', noShowSlots: 'u32',
neededApprovals: 'u32' neededApprovals: 'u32'
}, },
SessionInfoValidatorGroup: 'Vec<u32>', // ValidatorIndex (u16 in staking)
SignedAvailabilityBitfield: { SignedAvailabilityBitfield: {
payload: 'BitVec', payload: 'BitVec',
validatorIndex: 'u32', validatorIndex: 'u32', // ValidatorIndex for inclusion
signature: 'Signature' signature: 'ValidatorSignature'
}, },
SignedAvailabilityBitfields: 'Vec<SignedAvailabilityBitfield>', SignedAvailabilityBitfields: 'Vec<SignedAvailabilityBitfield>',
SigningContext: { SigningContext: {
sessionIndex: 'SessionIndex', sessionIndex: 'SessionIndex',
parentHash: 'Hash' parentHash: 'Hash'
}, },
SlotRange: {
_enum: ['ZeroZero', 'ZeroOne', 'ZeroTwo', 'ZeroThree', 'OneOne', 'OneTwo', 'OneThree', 'TwoTwo', 'TwoThree', 'ThreeThree']
},
Statement: { Statement: {
_enum: { _enum: {
Never: 'Null', // starts at 1 Never: 'Null', // starts at 1
@@ -319,7 +295,6 @@ export default {
Invalid: 'Hash' Invalid: 'Hash'
} }
}, },
SubId: 'u32',
TransientValidationData: { TransientValidationData: {
maxCodeSize: 'u32', maxCodeSize: 'u32',
maxHeadDataSize: 'u32', maxHeadDataSize: 'u32',
@@ -338,7 +313,10 @@ export default {
persisted: 'PersistedValidationData', persisted: 'PersistedValidationData',
transient: 'TransientValidationData' transient: 'TransientValidationData'
}, },
ValidatorGroup: 'Vec<ValidatorIndex>', ValidationDataType: {
validationData: 'ValidationData',
relayChainState: 'Vec<Bytes>'
},
ValidatorSignature: 'Signature', ValidatorSignature: 'Signature',
ValidityAttestation: { ValidityAttestation: {
_enum: { _enum: {
@@ -352,8 +330,6 @@ export default {
V0: 'Xcm' V0: 'Xcm'
} }
}, },
WinningData: `[WinningDataEntry; ${SLOT_RANGE_COUNT}]`,
WinningDataEntry: 'Option<Bidder>',
WithdrawAsset: { WithdrawAsset: {
assets: 'Vec<MultiAsset>', assets: 'Vec<MultiAsset>',
effects: 'Vec<Order>' effects: 'Vec<Order>'
@@ -0,0 +1,30 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
export default {
HrmpChannel: {
maxCapacity: 'u32',
maxTotalSize: 'u32',
maxMessageSize: 'u32',
msgCount: 'u32',
totalSize: 'u32',
mqcHead: 'Option<Hash>',
senderDeposit: 'Balance',
recipientDeposit: 'Balance'
},
HrmpChannelId: {
sender: 'u32',
receiver: 'u32'
},
HrmpOpenChannelRequest: {
confirmed: 'bool',
age: 'SessionIndex',
senderDeposit: 'Balance',
maxMessageSize: 'u32',
maxCapacity: 'u32',
maxTotalSize: 'u32'
}
};
@@ -0,0 +1,48 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
// order important in structs... :)
/* eslint-disable sort-keys */
const SLOT_RANGE_COUNT = 10;
export default {
AuctionIndex: 'u32',
Bidder: {
_enum: {
New: 'NewBidder',
Existing: 'ParaId'
}
},
IncomingParachain: {
_enum: {
Unset: 'NewBidder',
Fixed: 'IncomingParachainFixed',
Deploy: 'IncomingParachainDeploy'
}
},
IncomingParachainDeploy: {
code: 'ValidationCode',
initialHeadData: 'HeadData'
},
IncomingParachainFixed: {
codeHash: 'Hash',
codeSize: 'u32',
initialHeadData: 'HeadData'
},
LeasePeriod: 'BlockNumber',
LeasePeriodOf: 'BlockNumber',
NewBidder: {
who: 'AccountId',
sub: 'SubId'
},
NewBidderOption: 'Option<NewBidder>',
SlotRange: {
_enum: ['ZeroZero', 'ZeroOne', 'ZeroTwo', 'ZeroThree', 'OneOne', 'OneTwo', 'OneThree', 'TwoTwo', 'TwoThree', 'ThreeThree']
},
SubId: 'u32',
WinningData: `[WinningDataEntry; ${SLOT_RANGE_COUNT}]`,
WinningDataEntry: 'Option<Bidder>',
WinnersData: 'Vec<WinnersDataTuple>',
WinnersDataTuple: '(NewBidderOption, ParaId, BalanceOf, SlotRange)'
};
@@ -4,9 +4,8 @@
import type { BTreeMap, BitVec, Bytes, Compact, Enum, Option, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types'; import type { BTreeMap, BitVec, Bytes, Compact, Enum, Option, Struct, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types';
import type { ITuple } from '@polkadot/types/types'; import type { ITuple } from '@polkadot/types/types';
import type { Signature } from '@polkadot/types/interfaces/extrinsics'; import type { Signature } from '@polkadot/types/interfaces/extrinsics';
import type { AccountId, Balance, BlockNumber, Hash, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime'; import type { AccountId, Balance, BalanceOf, BlockNumber, H256, Hash, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
import type { MembershipProof, SessionIndex } from '@polkadot/types/interfaces/session'; import type { MembershipProof, SessionIndex } from '@polkadot/types/interfaces/session';
import type { ValidatorIndex } from '@polkadot/types/interfaces/staking';
/** @name AbridgedCandidateReceipt */ /** @name AbridgedCandidateReceipt */
export interface AbridgedCandidateReceipt extends Struct { export interface AbridgedCandidateReceipt extends Struct {
@@ -19,6 +18,29 @@ export interface AbridgedCandidateReceipt extends Struct {
readonly commitments: CandidateCommitments; readonly commitments: CandidateCommitments;
} }
/** @name AbridgedHostConfiguration */
export interface AbridgedHostConfiguration extends Struct {
readonly maxCodeSize: u32;
readonly maxHeadDataSize: u32;
readonly maxUpwardQueueCount: u32;
readonly maxUpwardQueueSize: u32;
readonly maxUpwardMessageSize: u32;
readonly maxUpwardMessageNumPerCandidate: u32;
readonly hrmpMaxMessageNumPerCandidate: u32;
readonly validationUpgradeFrequency: BlockNumber;
readonly validationUpgradeDelay: BlockNumber;
}
/** @name AbridgedHrmpChannel */
export interface AbridgedHrmpChannel extends Struct {
readonly maxCapacity: u32;
readonly maxTotalSize: u32;
readonly maxMessageSize: u32;
readonly msgCount: u32;
readonly totalSize: u32;
readonly mqcHead: Option<Hash>;
}
/** @name AbstractFungible */ /** @name AbstractFungible */
export interface AbstractFungible extends Struct { export interface AbstractFungible extends Struct {
readonly id: Bytes; readonly id: Bytes;
@@ -149,11 +171,11 @@ export interface CandidateCommitments extends Struct {
export interface CandidateDescriptor extends Struct { export interface CandidateDescriptor extends Struct {
readonly paraId: ParaId; readonly paraId: ParaId;
readonly relayParent: Hash; readonly relayParent: Hash;
readonly collatorId: Hash; readonly collatorId: CollatorId;
readonly persistedValidationDataHash: Hash; readonly persistedValidationDataHash: Hash;
readonly povHash: Hash; readonly povHash: Hash;
readonly erasureRoot: Hash; readonly erasureRoot: Hash;
readonly signature: Signature; readonly signature: CollatorSignature;
} }
/** @name CandidateHash */ /** @name CandidateHash */
@@ -177,7 +199,7 @@ export interface CandidateReceipt extends Struct {
} }
/** @name CollatorId */ /** @name CollatorId */
export interface CollatorId extends U8aFixed {} export interface CollatorId extends H256 {}
/** @name CollatorSignature */ /** @name CollatorSignature */
export interface CollatorSignature extends Signature {} export interface CollatorSignature extends Signature {}
@@ -264,12 +286,29 @@ export interface HeadData extends Bytes {}
/** @name HostConfiguration */ /** @name HostConfiguration */
export interface HostConfiguration extends Struct { export interface HostConfiguration extends Struct {
readonly validationUpgradeFrequency: BlockNumber;
readonly validationUpgradeDelay: BlockNumber;
readonly acceptancePeriod: BlockNumber;
readonly maxCodeSize: u32; readonly maxCodeSize: u32;
readonly maxHeadDataSize: u32; readonly maxHeadDataSize: u32;
readonly maxUpwardQueueCount: u32;
readonly maxUpwardQueueSize: u32;
readonly maxUpwardMessageSize: u32;
readonly maxUpwardMessageNumPerCandidate: u32;
readonly hrmpMaxMessageNumPerCandidate: u32;
readonly validationUpgradeFrequency: BlockNumber;
readonly validationUpgradeDelay: BlockNumber;
readonly maxPovSize: u32; readonly maxPovSize: u32;
readonly maxDownwardMessageSize: u32;
readonly preferredDispatchableUpwardMessagesStepWeight: Weight;
readonly hrmpMaxParachainOutboundChannels: u32;
readonly hrmpMaxParathreadOutboundChannels: u32;
readonly hrmpOpenRequestTtl: u32;
readonly hrmpSenderDeposit: Balance;
readonly hrmpRecipientDeposit: Balance;
readonly hrmpChannelMaxCapacity: u32;
readonly hrmpChannelMaxTotalSize: u32;
readonly hrmpMaxParachainInboundChannels: u32;
readonly hrmpMaxParathreadInboundChannels: u32;
readonly hrmpChannelMaxMessageSize: u32;
readonly acceptancePeriod: BlockNumber;
readonly parathreadCores: u32; readonly parathreadCores: u32;
readonly parathreadRetries: u32; readonly parathreadRetries: u32;
readonly groupRotationFrequency: BlockNumber; readonly groupRotationFrequency: BlockNumber;
@@ -283,35 +322,18 @@ export interface HostConfiguration extends Struct {
readonly zerothDelayTrancheWidth: u32; readonly zerothDelayTrancheWidth: u32;
readonly neededApprovals: u32; readonly neededApprovals: u32;
readonly relayVrfModuloSamples: u32; readonly relayVrfModuloSamples: u32;
readonly maxUpwardQueueCount: u32;
readonly maxUpwardQueueSize: u32;
readonly maxDownwardMessageSize: u32;
readonly preferredDispatchableUpwardMessagesStepWeight: Weight;
readonly maxUpwardMessageSize: u32;
readonly maxUpwardMessageNumPerCandidate: u32;
readonly hrmpOpenRequestTtl: u32;
readonly hrmpSenderDeposit: Balance;
readonly hrmpRecipientDeposit: Balance;
readonly hrmpChannelMaxCapacity: u32;
readonly hrmpChannelMaxTotalSize: u32;
readonly hrmpMaxParachainInboundChannels: u32;
readonly hrmpMaxParathreadInboundChannels: u32;
readonly hrmpChannelMaxMessageSize: u32;
readonly hrmpMaxParachainOutboundChannels: u32;
readonly hrmpMaxParathreadOutboundChannels: u32;
readonly hrmpMaxMessageNumPerCandidate: u32;
} }
/** @name HrmpChannel */ /** @name HrmpChannel */
export interface HrmpChannel extends Struct { export interface HrmpChannel extends Struct {
readonly senderDeposit: Balance;
readonly recipientDeposit: Balance;
readonly maxCapacity: u32; readonly maxCapacity: u32;
readonly maxTotalSize: u32; readonly maxTotalSize: u32;
readonly maxMessageSize: u32; readonly maxMessageSize: u32;
readonly msgCount: u32; readonly msgCount: u32;
readonly totalSize: u32; readonly totalSize: u32;
readonly mqcHead: Option<Hash>; readonly mqcHead: Option<Hash>;
readonly senderDeposit: Balance;
readonly recipientDeposit: Balance;
} }
/** @name HrmpChannelId */ /** @name HrmpChannelId */
@@ -406,7 +428,7 @@ export interface Junction extends Enum {
export interface LeasePeriod extends BlockNumber {} export interface LeasePeriod extends BlockNumber {}
/** @name LeasePeriodOf */ /** @name LeasePeriodOf */
export interface LeasePeriodOf extends LeasePeriod {} export interface LeasePeriodOf extends BlockNumber {}
/** @name LocalValidationData */ /** @name LocalValidationData */
export interface LocalValidationData extends Struct { export interface LocalValidationData extends Struct {
@@ -473,6 +495,9 @@ export interface NewBidder extends Struct {
readonly sub: SubId; readonly sub: SubId;
} }
/** @name NewBidderOption */
export interface NewBidderOption extends Option<NewBidder> {}
/** @name Order */ /** @name Order */
export interface Order extends Enum { export interface Order extends Enum {
readonly isNull: boolean; readonly isNull: boolean;
@@ -513,13 +538,20 @@ export interface ParachainDispatchOrigin extends Enum {
/** @name ParachainProposal */ /** @name ParachainProposal */
export interface ParachainProposal extends Struct { export interface ParachainProposal extends Struct {
readonly proposer: AccountId; readonly proposer: AccountId;
readonly validationFunction: ValidationCode; readonly validationCode: ValidationCode;
readonly initialHeadState: HeadData; readonly genesisHead: HeadData;
readonly validators: Vec<ValidatorId>; readonly validators: Vec<ValidatorId>;
readonly name: Bytes; readonly name: Bytes;
readonly balance: Balance; readonly balance: Balance;
} }
/** @name ParaGenesisArgs */
export interface ParaGenesisArgs extends Struct {
readonly genesisHead: Bytes;
readonly validationCode: Bytes;
readonly parachain: bool;
}
/** @name ParaId */ /** @name ParaId */
export interface ParaId extends u32 {} export interface ParaId extends u32 {}
@@ -559,6 +591,7 @@ export interface ParathreadEntry extends Struct {
export interface PersistedValidationData extends Struct { export interface PersistedValidationData extends Struct {
readonly parentHead: HeadData; readonly parentHead: HeadData;
readonly blockNumber: BlockNumber; readonly blockNumber: BlockNumber;
readonly relayStorageRoot: Hash;
readonly hrmpMqcHeads: Vec<ITuple<[u32, Hash]>>; readonly hrmpMqcHeads: Vec<ITuple<[u32, Hash]>>;
readonly dmqMqcHead: Hash; readonly dmqMqcHead: Hash;
readonly maxPovSize: u32; readonly maxPovSize: u32;
@@ -625,7 +658,7 @@ export interface SessionInfo extends Struct {
readonly validators: Vec<ValidatorId>; readonly validators: Vec<ValidatorId>;
readonly discoveryKeys: Vec<AuthorityDiscoveryId>; readonly discoveryKeys: Vec<AuthorityDiscoveryId>;
readonly assignmentKeys: Vec<AssignmentId>; readonly assignmentKeys: Vec<AssignmentId>;
readonly validatorGroups: Vec<ValidatorGroup>; readonly validatorGroups: Vec<SessionInfoValidatorGroup>;
readonly nCores: u32; readonly nCores: u32;
readonly zerothDelayTrancheWidth: u32; readonly zerothDelayTrancheWidth: u32;
readonly relayVrfModuloSamples: u32; readonly relayVrfModuloSamples: u32;
@@ -634,11 +667,14 @@ export interface SessionInfo extends Struct {
readonly neededApprovals: u32; readonly neededApprovals: u32;
} }
/** @name SessionInfoValidatorGroup */
export interface SessionInfoValidatorGroup extends Vec<u32> {}
/** @name SignedAvailabilityBitfield */ /** @name SignedAvailabilityBitfield */
export interface SignedAvailabilityBitfield extends Struct { export interface SignedAvailabilityBitfield extends Struct {
readonly payload: BitVec; readonly payload: BitVec;
readonly validatorIndex: u32; readonly validatorIndex: u32;
readonly signature: Signature; readonly signature: ValidatorSignature;
} }
/** @name SignedAvailabilityBitfields */ /** @name SignedAvailabilityBitfields */
@@ -711,6 +747,12 @@ export interface ValidationData extends Struct {
readonly transient: TransientValidationData; readonly transient: TransientValidationData;
} }
/** @name ValidationDataType */
export interface ValidationDataType extends Struct {
readonly validationData: ValidationData;
readonly relayChainState: Vec<Bytes>;
}
/** @name ValidationFunctionParams */ /** @name ValidationFunctionParams */
export interface ValidationFunctionParams extends Struct { export interface ValidationFunctionParams extends Struct {
readonly maxCodeSize: u32; readonly maxCodeSize: u32;
@@ -718,9 +760,6 @@ export interface ValidationFunctionParams extends Struct {
readonly codeUpgradeAllowed: Option<RelayChainBlockNumber>; readonly codeUpgradeAllowed: Option<RelayChainBlockNumber>;
} }
/** @name ValidatorGroup */
export interface ValidatorGroup extends Vec<ValidatorIndex> {}
/** @name ValidatorSignature */ /** @name ValidatorSignature */
export interface ValidatorSignature extends Signature {} export interface ValidatorSignature extends Signature {}
@@ -751,6 +790,12 @@ export interface VersionedXcm extends Enum {
readonly asV0: Xcm; readonly asV0: Xcm;
} }
/** @name WinnersData */
export interface WinnersData extends Vec<WinnersDataTuple> {}
/** @name WinnersDataTuple */
export interface WinnersDataTuple extends ITuple<[NewBidderOption, ParaId, BalanceOf, SlotRange]> {}
/** @name WinningData */ /** @name WinningData */
export interface WinningData extends Vec<WinningDataEntry> {} export interface WinningData extends Vec<WinningDataEntry> {}
@@ -86,7 +86,7 @@ export default {
LookupTarget: 'AccountId', LookupTarget: 'AccountId',
ModuleId: 'LockIdentifier', ModuleId: 'LockIdentifier',
MultiAddress: 'GenericMultiAddress', MultiAddress: 'GenericMultiAddress',
Moment: 'u64', Moment: 'UInt<64, Moment>',
OpaqueCall: 'Bytes', OpaqueCall: 'Bytes',
Origin: 'DoNotConstruct<Origin>', Origin: 'DoNotConstruct<Origin>',
OriginCaller: { OriginCaller: {
@@ -120,6 +120,7 @@ export default {
StorageData: 'Bytes', StorageData: 'Bytes',
TransactionPriority: 'u64', TransactionPriority: 'u64',
ValidatorId: 'AccountId', ValidatorId: 'AccountId',
ValidatorIdOf: 'ValidatorId',
Weight: 'u64', Weight: 'u64',
WeightMultiplier: 'Fixed64', WeightMultiplier: 'Fixed64',
@@ -166,7 +166,7 @@ export interface LookupTarget extends AccountId {}
export interface ModuleId extends LockIdentifier {} export interface ModuleId extends LockIdentifier {}
/** @name Moment */ /** @name Moment */
export interface Moment extends u64 {} export interface Moment extends UInt {}
/** @name MultiAddress */ /** @name MultiAddress */
export interface MultiAddress extends GenericMultiAddress {} export interface MultiAddress extends GenericMultiAddress {}
@@ -267,6 +267,9 @@ export interface U32F32 extends UInt {}
/** @name ValidatorId */ /** @name ValidatorId */
export interface ValidatorId extends AccountId {} export interface ValidatorId extends AccountId {}
/** @name ValidatorIdOf */
export interface ValidatorIdOf extends ValidatorId {}
/** @name Weight */ /** @name Weight */
export interface Weight extends u64 {} export interface Weight extends u64 {}
@@ -24,10 +24,10 @@ const keyTypes = {
SessionKeys4: '(AccountId, AccountId, AccountId, AccountId)', SessionKeys4: '(AccountId, AccountId, AccountId, AccountId)',
// CC3 // CC3
SessionKeys5: '(AccountId, AccountId, AccountId, AccountId, AccountId)', SessionKeys5: '(AccountId, AccountId, AccountId, AccountId, AccountId)',
SessionKeys6: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)', SessionKeys6: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)',
SessionKeys7: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)', SessionKeys7: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)',
SessionKeys8: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)', SessionKeys8: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)',
SessionKeys9: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)' SessionKeys9: '(AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId)'
}; };
export default { export default {
@@ -41,16 +41,16 @@ export interface SessionKeys4 extends ITuple<[AccountId, AccountId, AccountId, A
export interface SessionKeys5 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId]> {} export interface SessionKeys5 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId]> {}
/** @name SessionKeys6 */ /** @name SessionKeys6 */
export interface SessionKeys6 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {} export interface SessionKeys6 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {}
/** @name SessionKeys7 */ /** @name SessionKeys7 */
export interface SessionKeys7 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {} export interface SessionKeys7 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {}
/** @name SessionKeys8 */ /** @name SessionKeys8 */
export interface SessionKeys8 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {} export interface SessionKeys8 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {}
/** @name SessionKeys9 */ /** @name SessionKeys9 */
export interface SessionKeys9 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {} export interface SessionKeys9 extends ITuple<[AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId, AccountId]> {}
/** @name ValidatorCount */ /** @name ValidatorCount */
export interface ValidatorCount extends u32 {} export interface ValidatorCount extends u32 {}
+2
View File
@@ -19,6 +19,7 @@ export * from './genericAsset/types';
export * from './grandpa/types'; export * from './grandpa/types';
export * from './identity/types'; export * from './identity/types';
export * from './imOnline/types'; export * from './imOnline/types';
export * from './lottery/types';
export * from './offences/types'; export * from './offences/types';
export * from './proxy/types'; export * from './proxy/types';
export * from './recovery/types'; export * from './recovery/types';
@@ -35,6 +36,7 @@ export * from './utility/types';
export * from './vesting/types'; export * from './vesting/types';
export * from './attestations/types'; export * from './attestations/types';
export * from './claims/types'; export * from './claims/types';
export * from './crowdloan/types';
export * from './parachains/types'; export * from './parachains/types';
export * from './poll/types'; export * from './poll/types';
export * from './purchase/types'; export * from './purchase/types';
@@ -0,0 +1,32 @@
// Copyright 2017-2021 @polkadot/types authors & contributors
// SPDX-License-Identifier: Apache-2.0
import { hexToU8a } from '@polkadot/util';
import { TypeRegistry } from '../create';
import { BitVec } from './';
// form Inclusion BitVec<lsb0, u8>
const TESTS = ['0x00', '0x0817', '0x0837', '0x087b', '0x0c33'];
const registry = new TypeRegistry();
describe('BitVec', (): void => {
TESTS.forEach((test): void => {
describe(test, (): void => {
const input = hexToU8a(test);
it('has the right encodedLength', (): void => {
expect(
new BitVec(registry, input).encodedLength
).toEqual((test.length - 2) / 2);
});
// FIXME These do not align at all
it.skip('re-encodes to the same input value', (): void => {
expect(
new BitVec(registry, input).toU8a()
).toEqual(input);
});
});
});
});
+1 -1
View File
@@ -8,7 +8,7 @@ import type { Hash } from '../interfaces/runtime';
import type { AnyTuple, ArgsDef, Codec } from './codec'; import type { AnyTuple, ArgsDef, Codec } from './codec';
export interface ICompact<T> extends Codec { export interface ICompact<T> extends Codec {
toBigInt (): BigInt; toBigInt (): bigint;
toBn (): BN; toBn (): BN;
toNumber (): number; toNumber (): number;
unwrap (): T; unwrap (): T;
+5 -2
View File
@@ -4,6 +4,7 @@
import type BN from 'bn.js'; import type BN from 'bn.js';
import type { Metadata } from '@polkadot/metadata'; import type { Metadata } from '@polkadot/metadata';
import type { Observable } from '@polkadot/x-rxjs'; import type { Observable } from '@polkadot/x-rxjs';
import type { ExtDef } from '../extrinsic/signedExtensions/types';
import type { H256 } from '../interfaces/runtime'; import type { H256 } from '../interfaces/runtime';
import type { ChainProperties } from '../interfaces/system'; import type { ChainProperties } from '../interfaces/system';
import type { CallFunction } from './calls'; import type { CallFunction } from './calls';
@@ -29,6 +30,8 @@ export type RegistryTypes = Record<string, Constructor | string | Record<string,
export interface RegistryError { export interface RegistryError {
documentation: string[]; documentation: string[];
index: number; index: number;
// compat
method: string;
name: string; name: string;
section: string; section: string;
} }
@@ -111,6 +114,6 @@ export interface Registry {
register (arg1: string | Constructor | RegistryTypes, arg2?: Constructor): void; register (arg1: string | Constructor | RegistryTypes, arg2?: Constructor): void;
setChainProperties (properties?: ChainProperties): void; setChainProperties (properties?: ChainProperties): void;
setHasher (hasher?: (data: Uint8Array) => Uint8Array): void; setHasher (hasher?: (data: Uint8Array) => Uint8Array): void;
setMetadata (metadata: Metadata, signedExtensions?: string[]): void; setMetadata (metadata: Metadata, signedExtensions?: string[], userExtensions?: Record<string, ExtDef>): void;
setSignedExtensions (signedExtensions?: string[]): void; setSignedExtensions (signedExtensions?: string[], userExtensions?: Record<string, ExtDef>): void;
} }
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@polkadot/x-rxjs", "name": "@polkadot/x-rxjs",
"version": "3.3.1", "version": "3.5.1",
"description": "A pass-through interface for RxJs (allowing node + mjs usage)", "description": "A pass-through interface for RxJs (allowing node + mjs usage)",
"main": "index.js", "main": "index.js",
"sideEffects": false, "sideEffects": false,
+312 -364
View File
File diff suppressed because it is too large Load Diff