Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f0d11b026 | ||
|
|
0c997d2850 | ||
|
|
cb0beea7cd | ||
|
|
4ed783878d | ||
|
|
3846b5cc18 | ||
|
|
57b8915101 | ||
|
|
4f3f7e8dff | ||
|
|
a42c266a35 | ||
|
|
b03b2db3f8 | ||
|
|
5347db445d | ||
|
|
2a15b65385 | ||
|
|
7f1952acfc | ||
|
|
d8920b4bac | ||
|
|
3b46505027 | ||
|
|
ba3ac3f73d | ||
|
|
81d460ccc8 | ||
|
|
e6bb6c49b3 | ||
|
|
82ffa8a6e2 | ||
|
|
adc1af1f21 | ||
|
|
a05d6ad7dc | ||
|
|
be592f53b8 | ||
|
|
8e74eca435 | ||
|
|
8a28d2cf46 | ||
|
|
d36886fcbf | ||
|
|
3bbc9fbf6e | ||
|
|
1d4539f3ef | ||
|
|
215b20f7db | ||
|
|
c034b54822 | ||
|
|
261ca2149d | ||
|
|
eaa67c8ea6 | ||
|
|
db287d6997 | ||
|
|
b85bf7e41c | ||
|
|
84b82dd9b5 | ||
|
|
3df5b01375 | ||
|
|
2e6a59e2a0 | ||
|
|
2f91561166 | ||
|
|
b307772be2 | ||
|
|
d14d2ccc86 | ||
|
|
0f26ec47e2 | ||
|
|
40065e300b | ||
|
|
bbdb8a317f | ||
|
|
668085262c | ||
|
|
508400684a | ||
|
|
3273556f7b | ||
|
|
d36144bf36 | ||
|
|
444479011e | ||
|
|
8ac713abcf | ||
|
|
728bc5294f | ||
|
|
fd2f331bdf | ||
|
|
2aebbb89cb | ||
|
|
532c011495 | ||
|
|
e2802df9ce | ||
|
|
cc181e2cc3 | ||
|
|
1b8ba41715 | ||
|
|
648be9aecb | ||
|
|
292af97dc9 | ||
|
|
bcdd537214 | ||
|
|
514c5e4825 | ||
|
|
9b9581487d | ||
|
|
d443f31a9a | ||
|
|
3951da5df3 | ||
|
|
5f3a1e5b24 | ||
|
|
b1a6ccd425 | ||
|
|
adc40e581f | ||
|
|
c6b0b0c161 | ||
|
|
bf5b14580b | ||
|
|
088c02862b | ||
|
|
a05980900e | ||
|
|
77019def08 | ||
|
|
ae6a3307b1 | ||
|
|
8cb15c6a87 | ||
|
|
389dbb58a9 | ||
|
|
2d02f61fa7 | ||
|
|
7497ac723f | ||
|
|
711a145e1e | ||
|
|
05e3db01ba | ||
|
|
6158c07e0a |
+3
-3
@@ -1,4 +1,4 @@
|
||||
29
|
||||
30
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
@@ -19,7 +19,7 @@
|
||||
3.10.2
|
||||
4.0.2
|
||||
4.0.3
|
||||
|
||||
4.6.2
|
||||
4.7.2
|
||||
4.9.2
|
||||
4.9.2
|
||||
4.11.2
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
name: 'Lock Threads'
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '3 0/5 * * *'
|
||||
|
||||
jobs:
|
||||
lock:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v2
|
||||
with:
|
||||
github-token: ${{ secrets.GH_PAT_BOT }}
|
||||
issue-lock-inactive-days: '7'
|
||||
issue-lock-comment: >
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue
|
||||
if you think you have a related problem or query.
|
||||
pr-lock-inactive-days: '2'
|
||||
pr-lock-comment: >
|
||||
This pull request has been automatically locked since there
|
||||
has not been any recent activity after it was closed.
|
||||
Please open a new issue for related bugs.
|
||||
@@ -6,11 +6,11 @@ on:
|
||||
|
||||
jobs:
|
||||
master:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]')"
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/api'"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@@ -25,10 +25,3 @@ jobs:
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
yarn ${{ matrix.step }}
|
||||
|
||||
dummy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: dummy
|
||||
run: |
|
||||
echo "Dummy skip step"
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
name: Semgrep
|
||||
on:
|
||||
pull_request: {}
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
check:
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && (!github.event.issue.pull_request || github.event.pull_request.head.repo.full_name == github.repository)"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: returntocorp/semgrep-action@v1
|
||||
with:
|
||||
auditOn: push
|
||||
publishToken: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||
publishDeployment: 1395
|
||||
@@ -0,0 +1,17 @@
|
||||
name: 'Close stale issues and PRs'
|
||||
on:
|
||||
schedule:
|
||||
- cron: '2 2 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v3
|
||||
with:
|
||||
repo-token: ${{ secrets.GH_PAT_BOT }}
|
||||
stale-issue-message: 'This issue has been open for 21 days with no activity and is not labelled as an enhancement. It will be closed in 7 days.'
|
||||
stale-issue-label: 'stale'
|
||||
exempt-issue-labels: '-size-l,-size-m,-size-s,-size-xl,-size-xs,[bug]'
|
||||
days-before-stale: 21
|
||||
days-before-close: 7
|
||||
+7
-9
File diff suppressed because one or more lines are too long
+7
-9
File diff suppressed because one or more lines are too long
Vendored
-55
File diff suppressed because one or more lines are too long
+591
File diff suppressed because one or more lines are too long
+1
-1
@@ -10,4 +10,4 @@ plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.4.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
|
||||
|
||||
+44
-1
@@ -1,8 +1,51 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.13.1 Jun 6, 2021
|
||||
|
||||
Upgrade priority: Medium. Required for users connecting to Statemine and future Kusama upgrades.
|
||||
|
||||
Changes:
|
||||
|
||||
- Overrides for `westmint` spec (same as `statemint`)
|
||||
- Adjust `tx.session.setKeys` TS augmentation to allow `string` & `Uint8Array` keys
|
||||
- Add & adjust types for latest Cumulus code
|
||||
- Added 9031-9033 upgrade block for Westend
|
||||
- Update static metadata to latest Substrate
|
||||
- Optimize map retrieval with split page sizes for keys & values
|
||||
- Sanitizing `BN` imports to `type`-only as required
|
||||
|
||||
|
||||
## 4.12.1 May 30, 2021
|
||||
|
||||
Upgrade priority: Low. Internal adjustment only, no major external usage changes.
|
||||
|
||||
Changelog:
|
||||
|
||||
- Update `FundInfo` type with Polkadot (Thanks to https://github.com/arjanz)
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow storage queries with default keys values
|
||||
- Align identity `Data` to limit to 32 bytes in the `Raw` enum (as per Substrate)
|
||||
- Align static (test & docs-only) metadata with latest Substrate master
|
||||
- Added 9030 upgrade blocks for Kusama & Westend
|
||||
- Cleanup of Eth pallet RPC definitions
|
||||
- Cleanup README for `@polkadot/rpc-core` (recommended for internal-usage only)
|
||||
- Cleanup internal tests (no dangling handles, cater for Jest 27)
|
||||
|
||||
|
||||
## 4.11.2 May 24, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended where users are having TS mismatches with type definitions created on older versions.
|
||||
|
||||
Changes:
|
||||
|
||||
- Add backwards-compatible TS-only `AugmentedQueryDoubleMap` type (unused now in type generation)
|
||||
|
||||
|
||||
## 4.11.1 May 23, 2021
|
||||
|
||||
Upgrade priority. Low. Recommended for users using staking entries on Polkadot and users of Substrate master.
|
||||
Upgrade priority: Low. Recommended for users using staking entries on Polkadot and users of Substrate master.
|
||||
|
||||
Changes:
|
||||
|
||||
|
||||
+6
-6
@@ -8,7 +8,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.2.4"
|
||||
"typescript": "^4.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -20,19 +20,19 @@
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"postinstall": "polkadot-dev-yarn-only",
|
||||
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:one": "polkadot-dev-run-test",
|
||||
"test": "polkadot-dev-run-test --coverage --detectOpenHandles --forceExit --runInBand --testPathIgnorePatterns e2e",
|
||||
"test:one": "polkadot-dev-run-test --detectOpenHandles --forceExit",
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/register": "^7.13.16",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/dev": "^0.62.16",
|
||||
"@polkadot/ts": "^0.3.66",
|
||||
"@polkadot/dev": "^0.62.38",
|
||||
"@polkadot/ts": "^0.3.86",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.23",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "4.11.1"
|
||||
"version": "4.13.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
@@ -20,10 +20,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api": "4.11.1",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"@polkadot/api": "4.13.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/x-rxjs": "^6.7.1",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
@@ -8,8 +9,6 @@ import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { Bytes } from '@polkadot/types';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '4.13.1' };
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
@@ -20,16 +20,16 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api": "4.11.1",
|
||||
"@polkadot/rpc-core": "4.11.1",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"@polkadot/api": "4.13.1",
|
||||
"@polkadot/rpc-core": "4.13.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/util-crypto": "^6.7.1",
|
||||
"@polkadot/x-rxjs": "^6.7.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.5.1",
|
||||
"@polkadot/rpc-provider": "4.11.1"
|
||||
"@polkadot/keyring": "^6.7.1",
|
||||
"@polkadot/rpc-provider": "4.13.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveContractFees } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, Vote, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveDemocracyLock } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { BN_ZERO, isUndefined } from '@polkadot/util';
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { ReferendumIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { of } from '@polkadot/x-rxjs';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option, Vec } from '@polkadot/types';
|
||||
import type { AccountId, ReferendumInfo, ReferendumInfoTo239, Vote, Voting, VotingDelegating, VotingDirectVote } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveBalancesAccount, DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { bnSqrt } from '@polkadot/util';
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@ describe('derive', (): void => {
|
||||
api.isReady.subscribe(() => done());
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
testFunction(api)('accounts', 'idAndIndex', []);
|
||||
testFunction(api)('accounts', 'idToIndex', []);
|
||||
testFunction(api)('accounts', 'indexes', []);
|
||||
@@ -80,7 +84,11 @@ describe('derive', (): void => {
|
||||
});
|
||||
|
||||
beforeAll((done): void => {
|
||||
api.isReady.subscribe((): void => done());
|
||||
api.isReady.subscribe(() => done());
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
// override
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '4.13.1' };
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { Option, u32 } from '@polkadot/types';
|
||||
import type { ActiveEraInfo, EraIndex } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { map } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import type { AccountId, EraIndex, StakingLedger } from '@polkadot/types/interfaces';
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { DeriveEraPoints, DeriveEraPrefs, DeriveEraRewards, DeriveEraValPrefs, DeriveStakerExposure, DeriveStakerReward, DeriveStakerRewardValidator } from '../types';
|
||||
import type { DeriveStakingQuery } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
|
||||
import { combineLatest, of } from '@polkadot/x-rxjs';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
@@ -20,16 +20,16 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api-derive": "4.11.1",
|
||||
"@polkadot/keyring": "^6.5.1",
|
||||
"@polkadot/metadata": "4.11.1",
|
||||
"@polkadot/rpc-core": "4.11.1",
|
||||
"@polkadot/rpc-provider": "4.11.1",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/types-known": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"@polkadot/api-derive": "4.13.1",
|
||||
"@polkadot/keyring": "^6.7.1",
|
||||
"@polkadot/metadata": "4.13.1",
|
||||
"@polkadot/rpc-core": "4.13.1",
|
||||
"@polkadot/rpc-provider": "4.13.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/types-known": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/util-crypto": "^6.7.1",
|
||||
"@polkadot/x-rxjs": "^6.7.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
enactmentPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Minimum voting period allowed for an emergency referendum.
|
||||
* Minimum voting period allowed for a fast-track referendum.
|
||||
**/
|
||||
fastTrackVotingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -169,6 +169,9 @@ declare module '@polkadot/api/types/consts' {
|
||||
launchPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of votes for an account.
|
||||
*
|
||||
* Also used to compute weight, an overly big value can
|
||||
* lead to extrinsic with very big weight: see `delegate` for instance.
|
||||
**/
|
||||
maxVotes: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -364,14 +367,20 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a multisig execution or to store
|
||||
* a dispatch call for later.
|
||||
*
|
||||
* This is held for an additional storage item whose value size is
|
||||
* `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is
|
||||
* `32 + sizeof(AccountId)` bytes.
|
||||
**/
|
||||
depositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount of currency needed per unit threshold when creating a multisig execution.
|
||||
*
|
||||
* This is held for adding 32 bytes more into a pre-existing storage value.
|
||||
**/
|
||||
depositFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum amount of signatories allowed for a given multisig.
|
||||
* The maximum amount of signatories allowed in the multisig.
|
||||
**/
|
||||
maxSignatories: u16 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -400,7 +409,7 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The maximum amount of proxies allowed for a single account.
|
||||
**/
|
||||
maxProxies: u16 & AugmentedConst<ApiType>;
|
||||
maxProxies: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a proxy.
|
||||
*
|
||||
|
||||
@@ -136,6 +136,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Account liquidity restrictions prevent withdrawal
|
||||
**/
|
||||
LiquidityRestrictions: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Number of named reserves exceed MaxReserves
|
||||
**/
|
||||
TooManyReserves: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Vesting balance too high to send value
|
||||
**/
|
||||
@@ -205,6 +209,13 @@ declare module '@polkadot/api/types/errors' {
|
||||
* current schedule.
|
||||
**/
|
||||
CodeTooLarge: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A tombstone exist at the specified address.
|
||||
*
|
||||
* Tombstone cannot be called. Anyone can use `seal_restore_to` in order to revive
|
||||
* the contract, though.
|
||||
**/
|
||||
ContractIsTombstone: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A contract could not be evicted because it has enough balance to pay rent.
|
||||
*
|
||||
@@ -212,6 +223,10 @@ declare module '@polkadot/api/types/errors' {
|
||||
* contract has enough balance to pay for its rent.
|
||||
**/
|
||||
ContractNotEvictable: AugmentedError<ApiType>;
|
||||
/**
|
||||
* No contract was found at the specified address.
|
||||
**/
|
||||
ContractNotFound: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Contract trapped during execution.
|
||||
**/
|
||||
@@ -284,11 +299,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* is rejected.
|
||||
**/
|
||||
NoChainExtension: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The contract that was called is either no contract at all (a plain account)
|
||||
* or is a tombstone.
|
||||
**/
|
||||
NotCallable: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A buffer outside of sandbox memory was passed to a contract API function.
|
||||
**/
|
||||
@@ -311,6 +321,15 @@ declare module '@polkadot/api/types/errors' {
|
||||
* of a tombstone.
|
||||
**/
|
||||
ReentranceDenied: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The called contract does not have enough balance to pay for its storage.
|
||||
*
|
||||
* The contract ran out of balance and is therefore eligible for eviction into a
|
||||
* tombstone. Anyone can evict the contract by submitting a `claim_surcharge`
|
||||
* extrinsic. Alternatively, a plain balance transfer can be used in order to
|
||||
* increase the contracts funds so that it can be called again.
|
||||
**/
|
||||
RentNotPaid: AugmentedError<ApiType>;
|
||||
/**
|
||||
* A storage modification exhausted the 32bit type that holds the storage size.
|
||||
*
|
||||
@@ -1355,6 +1374,64 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
transactionStorage: {
|
||||
/**
|
||||
* Attempted to call `store` outside of block execution.
|
||||
**/
|
||||
BadContext: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Double proof check in the block.
|
||||
**/
|
||||
DoubleCheck: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Attempting to store empty transaction
|
||||
**/
|
||||
EmptyTransaction: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Insufficient account balance.
|
||||
**/
|
||||
InsufficientFunds: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Proof failed verification.
|
||||
**/
|
||||
InvalidProof: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Missing storage proof.
|
||||
**/
|
||||
MissingProof: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Unable to verify proof becasue state data is missing.
|
||||
**/
|
||||
MissingStateData: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Invalid configuration.
|
||||
**/
|
||||
NotConfigured: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Storage proof was not checked in the block.
|
||||
**/
|
||||
ProofNotChecked: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Renewed extrinsic is not found.
|
||||
**/
|
||||
RenewedNotFound: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Too many transactions in the block.
|
||||
**/
|
||||
TooManyTransactions: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Transaction is too large.
|
||||
**/
|
||||
TransactionTooLarge: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Proof was not expected in this block.
|
||||
**/
|
||||
UnexpectedProof: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
/**
|
||||
* Proposer's balance is too low.
|
||||
@@ -1373,6 +1450,52 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
uniques: {
|
||||
/**
|
||||
* The asset instance ID has already been used for an asset.
|
||||
**/
|
||||
AlreadyExists: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Invalid witness data given.
|
||||
**/
|
||||
BadWitness: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The asset instance or class is frozen.
|
||||
**/
|
||||
Frozen: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The asset ID is already taken.
|
||||
**/
|
||||
InUse: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There is no delegate approved.
|
||||
**/
|
||||
NoDelegate: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The signing account has no permission to do the operation.
|
||||
**/
|
||||
NoPermission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* No approval exists that would allow the transfer.
|
||||
**/
|
||||
Unapproved: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The given asset ID is unknown.
|
||||
**/
|
||||
Unknown: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The delegate turned out to be different to what was expected.
|
||||
**/
|
||||
WrongDelegate: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The owner turned out to be different to what was expected.
|
||||
**/
|
||||
WrongOwner: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
/**
|
||||
* Amount being transferred is too low to create a vesting schedule.
|
||||
|
||||
@@ -21,6 +21,7 @@ import type { IdentificationTuple, SessionIndex } from '@polkadot/types/interfac
|
||||
import type { ElectionCompute, EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
import type { DispatchError, DispatchInfo, DispatchResult } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { ClassId, InstanceId } from '@polkadot/types/interfaces/uniques';
|
||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
|
||||
@@ -995,6 +996,24 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
transactionStorage: {
|
||||
/**
|
||||
* Storage proof was successfully checked.
|
||||
**/
|
||||
ProofChecked: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Renewed data under specified index.
|
||||
**/
|
||||
Renewed: AugmentedEvent<ApiType, [u32]>;
|
||||
/**
|
||||
* Stored data under specified index.
|
||||
**/
|
||||
Stored: AugmentedEvent<ApiType, [u32]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
/**
|
||||
* Some funds have been allocated. \[proposal_index, award, beneficiary\]
|
||||
@@ -1030,6 +1049,108 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
uniques: {
|
||||
/**
|
||||
* An approval for a `delegate` account to transfer the `instance` of an asset `class` was
|
||||
* cancelled by its `owner`.
|
||||
* \[ class, instance, owner, delegate \]
|
||||
**/
|
||||
ApprovalCancelled: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
|
||||
/**
|
||||
* An `instance` of an asset `class` has been approved by the `owner` for transfer by a
|
||||
* `delegate`.
|
||||
* \[ class, instance, owner, delegate \]
|
||||
**/
|
||||
ApprovedTransfer: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
|
||||
/**
|
||||
* An asset `class` has had its attributes changed by the `Force` origin.
|
||||
* \[ class \]
|
||||
**/
|
||||
AssetStatusChanged: AugmentedEvent<ApiType, [ClassId]>;
|
||||
/**
|
||||
* Attribute metadata has been cleared for an asset class or instance.
|
||||
* \[ class, maybe_instance, key, maybe_value \]
|
||||
**/
|
||||
AttributeCleared: AugmentedEvent<ApiType, [ClassId, Option<InstanceId>, Bytes]>;
|
||||
/**
|
||||
* New attribute metadata has been set for an asset class or instance.
|
||||
* \[ class, maybe_instance, key, value \]
|
||||
**/
|
||||
AttributeSet: AugmentedEvent<ApiType, [ClassId, Option<InstanceId>, Bytes, Bytes]>;
|
||||
/**
|
||||
* An asset `instance` was destroyed. \[ class, instance, owner \]
|
||||
**/
|
||||
Burned: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
|
||||
/**
|
||||
* Some asset `class` was frozen. \[ class \]
|
||||
**/
|
||||
ClassFrozen: AugmentedEvent<ApiType, [ClassId]>;
|
||||
/**
|
||||
* Metadata has been cleared for an asset class. \[ class \]
|
||||
**/
|
||||
ClassMetadataCleared: AugmentedEvent<ApiType, [ClassId]>;
|
||||
/**
|
||||
* New metadata has been set for an asset class. \[ class, data, is_frozen \]
|
||||
**/
|
||||
ClassMetadataSet: AugmentedEvent<ApiType, [ClassId, Bytes, bool]>;
|
||||
/**
|
||||
* Some asset `class` was thawed. \[ class \]
|
||||
**/
|
||||
ClassThawed: AugmentedEvent<ApiType, [ClassId]>;
|
||||
/**
|
||||
* An asset class was created. \[ class, creator, owner \]
|
||||
**/
|
||||
Created: AugmentedEvent<ApiType, [ClassId, AccountId, AccountId]>;
|
||||
/**
|
||||
* An asset `class` was destroyed. \[ class \]
|
||||
**/
|
||||
Destroyed: AugmentedEvent<ApiType, [ClassId]>;
|
||||
/**
|
||||
* An asset class was force-created. \[ class, owner \]
|
||||
**/
|
||||
ForceCreated: AugmentedEvent<ApiType, [ClassId, AccountId]>;
|
||||
/**
|
||||
* Some asset `instance` was frozen. \[ class, instance \]
|
||||
**/
|
||||
Frozen: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* An asset `instace` was issued. \[ class, instance, owner \]
|
||||
**/
|
||||
Issued: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
|
||||
/**
|
||||
* Metadata has been cleared for an asset instance. \[ class, instance \]
|
||||
**/
|
||||
MetadataCleared: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* New metadata has been set for an asset instance.
|
||||
* \[ class, instance, data, is_frozen \]
|
||||
**/
|
||||
MetadataSet: AugmentedEvent<ApiType, [ClassId, InstanceId, Bytes, bool]>;
|
||||
/**
|
||||
* The owner changed \[ class, new_owner \]
|
||||
**/
|
||||
OwnerChanged: AugmentedEvent<ApiType, [ClassId, AccountId]>;
|
||||
/**
|
||||
* Metadata has been cleared for an asset instance. \[ class, successful_instances \]
|
||||
**/
|
||||
Redeposited: AugmentedEvent<ApiType, [ClassId, Vec<InstanceId>]>;
|
||||
/**
|
||||
* The management team changed \[ class, issuer, admin, freezer \]
|
||||
**/
|
||||
TeamChanged: AugmentedEvent<ApiType, [ClassId, AccountId, AccountId, AccountId]>;
|
||||
/**
|
||||
* Some asset `instance` was thawed. \[ class, instance \]
|
||||
**/
|
||||
Thawed: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* An asset `instace` was transferred. \[ class, instance, from, to \]
|
||||
**/
|
||||
Transferred: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
/**
|
||||
* Batch of dispatches completed fully with no error.
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
|
||||
import type { AssetApproval, AssetBalance, AssetDetails, AssetMetadata } from '@polkadot/types/interfaces/assets';
|
||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { BabeAuthorityWeight, BabeEpochConfiguration, MaybeRandomness, NextConfigDescriptor, Randomness } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock } from '@polkadot/types/interfaces/balances';
|
||||
import type { AccountData, BalanceLock, ReserveData } from '@polkadot/types/interfaces/balances';
|
||||
import type { ProposalIndex, Votes } from '@polkadot/types/interfaces/collective';
|
||||
import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
|
||||
import type { CodeHash, ContractInfo, DeletedContract, PrefabWasmModule } from '@polkadot/types/interfaces/contracts';
|
||||
@@ -20,14 +20,15 @@ import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lotter
|
||||
import type { Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import type { ProxyAnnouncement, ProxyDefinition } from '@polkadot/types/interfaces/proxy';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, Slot, TransactionInfo, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import type { ActiveEraInfo, ElectionPhase, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { ActiveEraInfo, ElectionPhase, ElectionScore, EraIndex, EraRewardPoints, Exposure, Forcing, Nominations, ReadySolution, RewardDestination, RoundSnapshot, SeatHolder, SlashingSpans, SolutionOrSnapshotSize, SpanIndex, SpanRecord, StakingLedger, UnappliedSlash, ValidatorPrefs, Voter } from '@polkadot/types/interfaces/staking';
|
||||
import type { AccountInfo, ConsumedWeight, DigestOf, EventIndex, EventRecord, LastRuntimeUpgradeInfo, Phase } from '@polkadot/types/interfaces/system';
|
||||
import type { Bounty, BountyIndex, OpenTip, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import type { ClassDetails, ClassId, ClassMetadata, DepositBalanceOf, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
|
||||
import type { Multisig } from '@polkadot/types/interfaces/utility';
|
||||
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
@@ -188,6 +189,10 @@ declare module '@polkadot/api/types/storage' {
|
||||
* NOTE: Should only be accessed when setting, changing and freeing a lock.
|
||||
**/
|
||||
locks: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<BalanceLock>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Named reserves on some account balances.
|
||||
**/
|
||||
reserves: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Vec<ReserveData>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Storage version of the pallet.
|
||||
*
|
||||
@@ -378,6 +383,13 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Only exists when [`Snapshot`] is present.
|
||||
**/
|
||||
desiredTargets: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The minimum score that each 'untrusted' solution must attain in order to be considered
|
||||
* feasible.
|
||||
*
|
||||
* Can be set via `set_minimum_untrusted_score`.
|
||||
**/
|
||||
minimumUntrustedScore: AugmentedQuery<ApiType, () => Observable<Option<ElectionScore>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Current best solution, signed or unsigned, queued to be returned upon `elect`.
|
||||
**/
|
||||
@@ -1199,6 +1211,46 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
transactionStorage: {
|
||||
blockTransactions: AugmentedQuery<ApiType, () => Observable<Vec<TransactionInfo>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Storage fee per byte.
|
||||
**/
|
||||
byteFee: AugmentedQuery<ApiType, () => Observable<Option<BalanceOf>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Count indexed chunks for each block.
|
||||
**/
|
||||
chunkCount: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<u32>, [BlockNumber]> & QueryableStorageEntry<ApiType, [BlockNumber]>;
|
||||
/**
|
||||
* Storage fee per transaction.
|
||||
**/
|
||||
entryFee: AugmentedQuery<ApiType, () => Observable<Option<BalanceOf>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Maximum number of indexed transactions in the block.
|
||||
**/
|
||||
maxBlockTransactions: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Maximum data set in a single transaction in bytes.
|
||||
**/
|
||||
maxTransactionSize: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Was the proof checked in this block?
|
||||
**/
|
||||
proofChecked: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Storage period for data in blocks. Should match `sp_storage_proof::DEFAULT_STORAGE_PERIOD`
|
||||
* for block authoring.
|
||||
**/
|
||||
storagePeriod: AugmentedQuery<ApiType, () => Observable<BlockNumber>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Collection of transaction metadata by block number.
|
||||
**/
|
||||
transactions: AugmentedQuery<ApiType, (arg: BlockNumber | AnyNumber | Uint8Array) => Observable<Option<Vec<TransactionInfo>>>, [BlockNumber]> & QueryableStorageEntry<ApiType, [BlockNumber]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
/**
|
||||
* Proposal indices that have been approved but not yet awarded.
|
||||
@@ -1217,6 +1269,37 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
uniques: {
|
||||
/**
|
||||
* The assets held by any given account; set out this way so that assets owned by a single
|
||||
* account can be enumerated.
|
||||
**/
|
||||
account: AugmentedQuery<ApiType, (arg1: AccountId | string | Uint8Array, arg2: ClassId | AnyNumber | Uint8Array, arg3: InstanceId | AnyNumber | Uint8Array) => Observable<Option<ITuple<[]>>>, [AccountId, ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [AccountId, ClassId, InstanceId]>;
|
||||
/**
|
||||
* The assets in existence and their ownership details.
|
||||
**/
|
||||
asset: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: InstanceId | AnyNumber | Uint8Array) => Observable<Option<InstanceDetails>>, [ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* Metadata of an asset class.
|
||||
**/
|
||||
attribute: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: Option<InstanceId> | null | object | string | Uint8Array, arg3: Bytes | string | Uint8Array) => Observable<Option<ITuple<[Bytes, DepositBalanceOf]>>>, [ClassId, Option<InstanceId>, Bytes]> & QueryableStorageEntry<ApiType, [ClassId, Option<InstanceId>, Bytes]>;
|
||||
/**
|
||||
* Details of an asset class.
|
||||
**/
|
||||
class: AugmentedQuery<ApiType, (arg: ClassId | AnyNumber | Uint8Array) => Observable<Option<ClassDetails>>, [ClassId]> & QueryableStorageEntry<ApiType, [ClassId]>;
|
||||
/**
|
||||
* Metadata of an asset class.
|
||||
**/
|
||||
classMetadataOf: AugmentedQuery<ApiType, (arg: ClassId | AnyNumber | Uint8Array) => Observable<Option<ClassMetadata>>, [ClassId]> & QueryableStorageEntry<ApiType, [ClassId]>;
|
||||
/**
|
||||
* Metadata of an asset instance.
|
||||
**/
|
||||
instanceMetadataOf: AugmentedQuery<ApiType, (arg1: ClassId | AnyNumber | Uint8Array, arg2: InstanceId | AnyNumber | Uint8Array) => Observable<Option<InstanceMetadata>>, [ClassId, InstanceId]> & QueryableStorageEntry<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
/**
|
||||
* Information regarding the vesting of a given account.
|
||||
|
||||
@@ -153,7 +153,7 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||
**/
|
||||
accounts: AugmentedRpc<() => Observable<Vec<H160>>>;
|
||||
/**
|
||||
* Returns balance of the given account.
|
||||
* Returns the blockNumber
|
||||
**/
|
||||
blockNumber: AugmentedRpc<() => Observable<U256>>;
|
||||
/**
|
||||
|
||||
+427
-14
@@ -15,13 +15,14 @@ import type { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/in
|
||||
import type { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
||||
import type { Heartbeat } from '@polkadot/types/interfaces/imOnline';
|
||||
import type { ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Perquintill, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIndex, AssetId, Balance, BalanceOf, BlockNumber, Call, CallHashOf, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Perquintill, TransactionStorageProof, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { Keys } from '@polkadot/types/interfaces/session';
|
||||
import type { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
import type { EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { ElectionScore, EraIndex, RawSolution, RewardDestination, SolutionOrSnapshotSize, ValidatorPrefs } from '@polkadot/types/interfaces/staking';
|
||||
import type { Key } from '@polkadot/types/interfaces/system';
|
||||
import type { BountyIndex } from '@polkadot/types/interfaces/treasury';
|
||||
import type { ClassId, DestroyWitness, InstanceId } from '@polkadot/types/interfaces/uniques';
|
||||
import type { Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
@@ -208,8 +209,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `owner`: The owner of this class of assets. The owner has full superuser permissions
|
||||
* over this asset, but may later change and configure the permissions using `transfer_ownership`
|
||||
* and `set_team`.
|
||||
* - `max_zombies`: The total number of accounts which may hold assets in this class yet
|
||||
* have no existential deposit.
|
||||
* - `min_balance`: The minimum balance of this new asset that any single account must
|
||||
* have. If an account's balance is reduced below this, then it collapses to zero.
|
||||
*
|
||||
@@ -253,8 +252,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* to zero.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
* Modes: Pre-existence of `dest`; Post-existence of `source`; Prior & post zombie-status
|
||||
* of `source`; Account pre-existence of `dest`.
|
||||
* Modes: Pre-existence of `dest`; Post-existence of `source`; Account pre-existence of
|
||||
* `dest`.
|
||||
**/
|
||||
forceTransfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, LookupSource, Compact<TAssetBalance>]>;
|
||||
/**
|
||||
@@ -291,7 +290,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `beneficiary`: The account to be credited with the minted assets.
|
||||
* - `amount`: The amount of the asset to be minted.
|
||||
*
|
||||
* Emits `Destroyed` event when successful.
|
||||
* Emits `Issued` event when successful.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
* Modes: Pre-existing balance of `beneficiary`; Account pre-existence of `beneficiary`.
|
||||
@@ -349,7 +348,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Admin of the asset `id`.
|
||||
*
|
||||
* - `id`: The identifier of the asset to be frozen.
|
||||
* - `id`: The identifier of the asset to be thawed.
|
||||
*
|
||||
* Emits `Thawed`.
|
||||
*
|
||||
@@ -373,8 +372,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* to zero.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
|
||||
* of sender; Account pre-existence of `target`.
|
||||
* Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
|
||||
* `target`.
|
||||
**/
|
||||
transfer: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
||||
/**
|
||||
@@ -415,8 +414,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* to zero.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
* Modes: Pre-existence of `target`; Post-existence of sender; Prior & post zombie-status
|
||||
* of sender; Account pre-existence of `target`.
|
||||
* Modes: Pre-existence of `target`; Post-existence of sender; Account pre-existence of
|
||||
* `target`.
|
||||
**/
|
||||
transferKeepAlive: AugmentedSubmittable<(id: Compact<AssetId> | AnyNumber | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: Compact<TAssetBalance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<AssetId>, LookupSource, Compact<TAssetBalance>]>;
|
||||
/**
|
||||
@@ -699,7 +698,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* producer fails to do so, a regular users will be allowed to claim the reward.
|
||||
*
|
||||
* In case of a successful eviction no fees are charged from the sender. However, the
|
||||
* reward is capped by the total amount of rent that was payed by the contract while
|
||||
* reward is capped by the total amount of rent that was paid by the contract while
|
||||
* it was alive.
|
||||
*
|
||||
* If contract is not evicted as a result of this call, [`Error::ContractNotEvictable`]
|
||||
@@ -1222,6 +1221,14 @@ declare module '@polkadot/api/types/submittable' {
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
/**
|
||||
* Set a new value for `MinimumUntrustedScore`.
|
||||
*
|
||||
* Dispatch origin must be aligned with `T::ForceOrigin`.
|
||||
*
|
||||
* This check can be turned off by setting the value to `None`.
|
||||
**/
|
||||
setMinimumUntrustedScore: AugmentedSubmittable<(maybeNextScore: Option<ElectionScore> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<ElectionScore>]>;
|
||||
/**
|
||||
* Submit a solution for the unsigned phase.
|
||||
*
|
||||
@@ -2538,7 +2545,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWrites per key id: `KeyOwner`
|
||||
* # </weight>
|
||||
**/
|
||||
setKeys: AugmentedSubmittable<(keys: Keys, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Keys, Bytes]>;
|
||||
setKeys: AugmentedSubmittable<(keys: Keys | string | Uint8Array, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Keys, Bytes]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -3830,6 +3837,41 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
transactionStorage: {
|
||||
/**
|
||||
* Check storage proof for block number `block_number() - StoragePeriod`.
|
||||
* If such block does not exist the proof is expected to be `None`.
|
||||
* # <weight>
|
||||
* - Linear w.r.t the number of indexed transactions in the proved block for random probing.
|
||||
* There's a DB read for each transaction.
|
||||
* Here we assume a maximum of 100 probed transactions.
|
||||
* # </weight>
|
||||
**/
|
||||
checkProof: AugmentedSubmittable<(proof: TransactionStorageProof | { chunk?: any; proof?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [TransactionStorageProof]>;
|
||||
/**
|
||||
* Renew previously stored data. Parameters are the block number that contains
|
||||
* previous `store` or `renew` call and transaction index within that block.
|
||||
* Transaction index is emitted in the `Stored` or `Renewed` event.
|
||||
* Applies same fees as `store`.
|
||||
* # <weight>
|
||||
* - Constant.
|
||||
* # </weight>
|
||||
**/
|
||||
renew: AugmentedSubmittable<(block: BlockNumber | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [BlockNumber, u32]>;
|
||||
/**
|
||||
* Index and store data on chain. Minimum data size is 1 bytes, maximum is `MaxTransactionSize`.
|
||||
* Data will be removed after `STORAGE_PERIOD` blocks, unless `renew` is called.
|
||||
* # <weight>
|
||||
* - n*log(n) of data size, as all data is pushed to an in-memory trie.
|
||||
* Additionally contains a DB write.
|
||||
* # </weight>
|
||||
**/
|
||||
store: AugmentedSubmittable<(data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
treasury: {
|
||||
/**
|
||||
* Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
|
||||
@@ -3873,6 +3915,377 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
uniques: {
|
||||
/**
|
||||
* Approve an instance to be transferred by a delegated third-party account.
|
||||
*
|
||||
* Origin must be Signed and must be the owner of the asset `instance`.
|
||||
*
|
||||
* - `class`: The class of the asset to be approved for delegated transfer.
|
||||
* - `instance`: The instance of the asset to be approved for delegated transfer.
|
||||
* - `delegate`: The account to delegate permission to transfer the asset.
|
||||
*
|
||||
* Emits `ApprovedTransfer` on success.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
approveTransfer: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, delegate: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, LookupSource]>;
|
||||
/**
|
||||
* Destroy a single asset instance.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Admin of the asset `class`.
|
||||
*
|
||||
* - `class`: The class of the asset to be burned.
|
||||
* - `instance`: The instance of the asset to be burned.
|
||||
* - `check_owner`: If `Some` then the operation will fail with `WrongOwner` unless the
|
||||
* asset is owned by this value.
|
||||
*
|
||||
* Emits `Burned` with the actual amount burned.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
* Modes: `check_owner.is_some()`.
|
||||
**/
|
||||
burn: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, checkOwner: Option<LookupSource> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, Option<LookupSource>]>;
|
||||
/**
|
||||
* Cancel the prior approval for the transfer of an asset by a delegate.
|
||||
*
|
||||
* Origin must be either:
|
||||
* - the `Force` origin;
|
||||
* - `Signed` with the signer being the Admin of the asset `class`;
|
||||
* - `Signed` with the signer being the Owner of the asset `instance`;
|
||||
*
|
||||
* Arguments:
|
||||
* - `class`: The class of the asset of whose approval will be cancelled.
|
||||
* - `instance`: The instance of the asset of whose approval will be cancelled.
|
||||
* - `maybe_check_delegate`: If `Some` will ensure that the given account is the one to
|
||||
* which permission of transfer is delegated.
|
||||
*
|
||||
* Emits `ApprovalCancelled` on success.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
cancelApproval: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, maybeCheckDelegate: Option<LookupSource> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, Option<LookupSource>]>;
|
||||
/**
|
||||
* Set an attribute for an asset class or instance.
|
||||
*
|
||||
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
|
||||
* asset `class`.
|
||||
*
|
||||
* If the origin is Signed, then funds of signer are reserved according to the formula:
|
||||
* `MetadataDepositBase + DepositPerByte * (key.len + value.len)` taking into
|
||||
* account any already reserved funds.
|
||||
*
|
||||
* - `class`: The identifier of the asset class whose instance's metadata to set.
|
||||
* - `instance`: The identifier of the asset instance whose metadata to set.
|
||||
* - `key`: The key of the attribute.
|
||||
* - `value`: The value to which to set the attribute.
|
||||
*
|
||||
* Emits `AttributeSet`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
clearAttribute: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, maybeInstance: Option<InstanceId> | null | object | string | Uint8Array, key: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Option<InstanceId>, Bytes]>;
|
||||
/**
|
||||
* Clear the metadata for an asset class.
|
||||
*
|
||||
* Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of
|
||||
* the asset `class`.
|
||||
*
|
||||
* Any deposit is freed for the asset class owner.
|
||||
*
|
||||
* - `class`: The identifier of the asset class whose metadata to clear.
|
||||
*
|
||||
* Emits `ClassMetadataCleared`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
clearClassMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>]>;
|
||||
/**
|
||||
* Clear the metadata for an asset instance.
|
||||
*
|
||||
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
|
||||
* asset `instance`.
|
||||
*
|
||||
* Any deposit is freed for the asset class owner.
|
||||
*
|
||||
* - `class`: The identifier of the asset class whose instance's metadata to clear.
|
||||
* - `instance`: The identifier of the asset instance whose metadata to clear.
|
||||
*
|
||||
* Emits `MetadataCleared`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
clearMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>]>;
|
||||
/**
|
||||
* Issue a new class of non-fungible assets from a public origin.
|
||||
*
|
||||
* This new asset class has no assets initially and its owner is the origin.
|
||||
*
|
||||
* The origin must be Signed and the sender must have sufficient funds free.
|
||||
*
|
||||
* `AssetDeposit` funds of sender are reserved.
|
||||
*
|
||||
* Parameters:
|
||||
* - `class`: The identifier of the new asset class. This must not be currently in use.
|
||||
* - `admin`: The admin of this class of assets. The admin is the initial address of each
|
||||
* member of the asset class's admin team.
|
||||
*
|
||||
* Emits `Created` event when successful.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
create: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource]>;
|
||||
/**
|
||||
* Destroy a class of fungible assets.
|
||||
*
|
||||
* The origin must conform to `ForceOrigin` or must be `Signed` and the sender must be the
|
||||
* owner of the asset `class`.
|
||||
*
|
||||
* - `class`: The identifier of the asset class to be destroyed.
|
||||
* - `witness`: Information on the instances minted in the asset class. This must be
|
||||
* correct.
|
||||
*
|
||||
* Emits `Destroyed` event when successful.
|
||||
*
|
||||
* Weight: `O(n + m)` where:
|
||||
* - `n = witness.instances`
|
||||
* - `m = witness.instance_metdadatas`
|
||||
* - `a = witness.attributes`
|
||||
**/
|
||||
destroy: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, witness: DestroyWitness | { instances?: any; instanceMetadatas?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, DestroyWitness]>;
|
||||
/**
|
||||
* Alter the attributes of a given asset.
|
||||
*
|
||||
* Origin must be `ForceOrigin`.
|
||||
*
|
||||
* - `class`: The identifier of the asset.
|
||||
* - `owner`: The new Owner of this asset.
|
||||
* - `issuer`: The new Issuer of this asset.
|
||||
* - `admin`: The new Admin of this asset.
|
||||
* - `freezer`: The new Freezer of this asset.
|
||||
* - `free_holding`: Whether a deposit is taken for holding an instance of this asset
|
||||
* class.
|
||||
* - `is_frozen`: Whether this asset class is frozen except for permissioned/admin
|
||||
* instructions.
|
||||
*
|
||||
* Emits `AssetStatusChanged` with the identity of the asset.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
forceAssetStatus: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, issuer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freezer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freeHolding: bool | boolean | Uint8Array, isFrozen: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource, LookupSource, LookupSource, LookupSource, bool, bool]>;
|
||||
/**
|
||||
* Issue a new class of non-fungible assets from a privileged origin.
|
||||
*
|
||||
* This new asset class has no assets initially.
|
||||
*
|
||||
* The origin must conform to `ForceOrigin`.
|
||||
*
|
||||
* Unlike `create`, no funds are reserved.
|
||||
*
|
||||
* - `class`: The identifier of the new asset. This must not be currently in use.
|
||||
* - `owner`: The owner of this class of assets. The owner has full superuser permissions
|
||||
* over this asset, but may later change and configure the permissions using
|
||||
* `transfer_ownership` and `set_team`.
|
||||
*
|
||||
* Emits `ForceCreated` event when successful.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
forceCreate: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freeHolding: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource, bool]>;
|
||||
/**
|
||||
* Disallow further unprivileged transfer of an asset instance.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Freezer of the asset `class`.
|
||||
*
|
||||
* - `class`: The class of the asset to be frozen.
|
||||
* - `instance`: The instance of the asset to be frozen.
|
||||
*
|
||||
* Emits `Frozen`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
freeze: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>]>;
|
||||
/**
|
||||
* Disallow further unprivileged transfers for a whole asset class.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Freezer of the asset `class`.
|
||||
*
|
||||
* - `class`: The asset class to be frozen.
|
||||
*
|
||||
* Emits `ClassFrozen`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
freezeClass: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>]>;
|
||||
/**
|
||||
* Mint an asset instance of a particular class.
|
||||
*
|
||||
* The origin must be Signed and the sender must be the Issuer of the asset `class`.
|
||||
*
|
||||
* - `class`: The class of the asset to be minted.
|
||||
* - `instance`: The instance value of the asset to be minted.
|
||||
* - `beneficiary`: The initial owner of the minted asset.
|
||||
*
|
||||
* Emits `Issued` event when successful.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
mint: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, LookupSource]>;
|
||||
/**
|
||||
* Reevaluate the deposits on some assets.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Owner of the asset `class`.
|
||||
*
|
||||
* - `class`: The class of the asset to be frozen.
|
||||
* - `instances`: The instances of the asset class whose deposits will be reevaluated.
|
||||
*
|
||||
* NOTE: This exists as a best-effort function. Any asset instances which are unknown or
|
||||
* in the case that the owner account does not have reservable funds to pay for a
|
||||
* deposit increase are ignored. Generally the owner isn't going to call this on instances
|
||||
* whose existing deposit is less than the refreshed deposit as it would only cost them,
|
||||
* so it's of little consequence.
|
||||
*
|
||||
* It will still return an error in the case that the class is unknown of the signer is
|
||||
* not permitted to call it.
|
||||
*
|
||||
* Weight: `O(instances.len())`
|
||||
**/
|
||||
redeposit: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instances: Vec<InstanceId> | (InstanceId | AnyNumber | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Vec<InstanceId>]>;
|
||||
/**
|
||||
* Set an attribute for an asset class or instance.
|
||||
*
|
||||
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
|
||||
* asset `class`.
|
||||
*
|
||||
* If the origin is Signed, then funds of signer are reserved according to the formula:
|
||||
* `MetadataDepositBase + DepositPerByte * (key.len + value.len)` taking into
|
||||
* account any already reserved funds.
|
||||
*
|
||||
* - `class`: The identifier of the asset class whose instance's metadata to set.
|
||||
* - `maybe_instance`: The identifier of the asset instance whose metadata to set.
|
||||
* - `key`: The key of the attribute.
|
||||
* - `value`: The value to which to set the attribute.
|
||||
*
|
||||
* Emits `AttributeSet`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
setAttribute: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, maybeInstance: Option<InstanceId> | null | object | string | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Option<InstanceId>, Bytes, Bytes]>;
|
||||
/**
|
||||
* Set the metadata for an asset class.
|
||||
*
|
||||
* Origin must be either `ForceOrigin` or `Signed` and the sender should be the Owner of
|
||||
* the asset `class`.
|
||||
*
|
||||
* If the origin is `Signed`, then funds of signer are reserved according to the formula:
|
||||
* `MetadataDepositBase + DepositPerByte * data.len` taking into
|
||||
* account any already reserved funds.
|
||||
*
|
||||
* - `class`: The identifier of the asset whose metadata to update.
|
||||
* - `data`: The general information of this asset. Limited in length by `StringLimit`.
|
||||
* - `is_frozen`: Whether the metadata should be frozen against further changes.
|
||||
*
|
||||
* Emits `ClassMetadataSet`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
setClassMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array, isFrozen: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Bytes, bool]>;
|
||||
/**
|
||||
* Set the metadata for an asset instance.
|
||||
*
|
||||
* Origin must be either `ForceOrigin` or Signed and the sender should be the Owner of the
|
||||
* asset `class`.
|
||||
*
|
||||
* If the origin is Signed, then funds of signer are reserved according to the formula:
|
||||
* `MetadataDepositBase + DepositPerByte * data.len` taking into
|
||||
* account any already reserved funds.
|
||||
*
|
||||
* - `class`: The identifier of the asset class whose instance's metadata to set.
|
||||
* - `instance`: The identifier of the asset instance whose metadata to set.
|
||||
* - `data`: The general information of this asset. Limited in length by `StringLimit`.
|
||||
* - `is_frozen`: Whether the metadata should be frozen against further changes.
|
||||
*
|
||||
* Emits `MetadataSet`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
setMetadata: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array, isFrozen: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, Bytes, bool]>;
|
||||
/**
|
||||
* Change the Issuer, Admin and Freezer of an asset class.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Owner of the asset `class`.
|
||||
*
|
||||
* - `class`: The asset class whose team should be changed.
|
||||
* - `issuer`: The new Issuer of this asset class.
|
||||
* - `admin`: The new Admin of this asset class.
|
||||
* - `freezer`: The new Freezer of this asset class.
|
||||
*
|
||||
* Emits `TeamChanged`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
setTeam: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, issuer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, admin: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freezer: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource, LookupSource, LookupSource]>;
|
||||
/**
|
||||
* Re-allow unprivileged transfer of an asset instance.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Freezer of the asset `class`.
|
||||
*
|
||||
* - `class`: The class of the asset to be thawed.
|
||||
* - `instance`: The instance of the asset to be thawed.
|
||||
*
|
||||
* Emits `Thawed`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
thaw: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>]>;
|
||||
/**
|
||||
* Re-allow unprivileged transfers for a whole asset class.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Admin of the asset `class`.
|
||||
*
|
||||
* - `class`: The class to be thawed.
|
||||
*
|
||||
* Emits `ClassThawed`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
thawClass: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>]>;
|
||||
/**
|
||||
* Move an asset from the sender account to another.
|
||||
*
|
||||
* Origin must be Signed and the signing account must be either:
|
||||
* - the Admin of the asset `class`;
|
||||
* - the Owner of the asset `instance`;
|
||||
* - the approved delegate for the asset `instance` (in this case, the approval is reset).
|
||||
*
|
||||
* Arguments:
|
||||
* - `class`: The class of the asset to be transferred.
|
||||
* - `instance`: The instance of the asset to be transferred.
|
||||
* - `dest`: The account to receive ownership of the asset.
|
||||
*
|
||||
* Emits `Transferred`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
transfer: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, instance: Compact<InstanceId> | AnyNumber | Uint8Array, dest: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, Compact<InstanceId>, LookupSource]>;
|
||||
/**
|
||||
* Change the Owner of an asset class.
|
||||
*
|
||||
* Origin must be Signed and the sender should be the Owner of the asset `class`.
|
||||
*
|
||||
* - `class`: The asset class whose owner should be changed.
|
||||
* - `owner`: The new Owner of this asset class.
|
||||
*
|
||||
* Emits `OwnerChanged`.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
transferOwnership: AugmentedSubmittable<(clazz: Compact<ClassId> | AnyNumber | Uint8Array, owner: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<ClassId>, LookupSource]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
[key: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
/**
|
||||
* Send a call through an indexed pseudonym of the sender.
|
||||
|
||||
@@ -39,7 +39,8 @@ interface MetaDecoration {
|
||||
}
|
||||
|
||||
// the max amount of keys/values that we will retrieve at once
|
||||
const PAGE_SIZE = 256;
|
||||
const PAGE_SIZE_K = 768; // limited since the trie lookups are heavy
|
||||
const PAGE_SIZE_V = 256; // limited since the data may be very large
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
@@ -471,15 +472,14 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return of([]);
|
||||
}
|
||||
|
||||
const queryCall = this.hasSubscriptions
|
||||
? this._rpcCore.state.subscribeStorage
|
||||
: this._rpcCore.state.queryStorageAt;
|
||||
|
||||
return combineLatest(
|
||||
arrayChunk(keys, PAGE_SIZE).map((keys) =>
|
||||
(this.hasSubscriptions
|
||||
? this._rpcCore.state.subscribeStorage
|
||||
: this._rpcCore.state.queryStorageAt
|
||||
)(keys)
|
||||
)
|
||||
arrayChunk(keys, PAGE_SIZE_V).map((keys) => queryCall(keys))
|
||||
).pipe(
|
||||
map((valsArr): Codec[] => arrayFlatten(valsArr))
|
||||
map(arrayFlatten)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -488,25 +488,22 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
const headKey = iterKey(...args).toHex();
|
||||
const startSubject = new BehaviorSubject<string>(headKey);
|
||||
const query = at
|
||||
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey, at)
|
||||
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE, startKey);
|
||||
const queryCall = at
|
||||
? (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey, at)
|
||||
: (startKey: string) => this._rpcCore.state.getKeysPaged(headKey, PAGE_SIZE_K, startKey);
|
||||
|
||||
return startSubject.pipe(
|
||||
switchMap((startKey) =>
|
||||
query(startKey).pipe(
|
||||
map((keys) => keys.map((key) => key.setMeta(meta, section, method)))
|
||||
)
|
||||
),
|
||||
switchMap(queryCall),
|
||||
map((keys) => keys.map((key) => key.setMeta(meta, section, method))),
|
||||
tap((keys): void => {
|
||||
setTimeout((): void => {
|
||||
keys.length === PAGE_SIZE
|
||||
? startSubject.next(keys[PAGE_SIZE - 1].toHex())
|
||||
keys.length === PAGE_SIZE_K
|
||||
? startSubject.next(keys[PAGE_SIZE_K - 1].toHex())
|
||||
: startSubject.complete();
|
||||
}, 0);
|
||||
}),
|
||||
toArray(), // toArray since we want to startSubject to be completed
|
||||
map((keysArr: StorageKey[][]) => arrayFlatten(keysArr))
|
||||
map(arrayFlatten)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -528,7 +525,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return this._retrieveMapKeys(entry, at, args).pipe(
|
||||
switchMap((keys) =>
|
||||
keys.length
|
||||
? combineLatest(arrayChunk(keys, PAGE_SIZE).map(query)).pipe(
|
||||
? combineLatest(arrayChunk(keys, PAGE_SIZE_V).map(query)).pipe(
|
||||
map((valsArr) =>
|
||||
arrayFlatten(valsArr).map((value, index): [StorageKey, Codec] => [keys[index], value])
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { RpcInterfaceMethod } from '@polkadot/rpc-core/types';
|
||||
import type { Text } from '@polkadot/types';
|
||||
import type { ChainProperties, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
@@ -9,8 +10,6 @@ import type { Observable, Subscription } from '@polkadot/x-rxjs';
|
||||
import type { ApiBase, ApiOptions, ApiTypes, DecorateMethod } from '../types';
|
||||
import type { VersionedRegistry } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { Metadata } from '@polkadot/metadata';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { getSpecAlias, getSpecExtensions, getSpecHasher, getSpecRpc, getSpecTypes, getUpgradeVersion } from '@polkadot/types-known';
|
||||
@@ -349,13 +348,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
}
|
||||
|
||||
this.#healthTimer = setInterval((): void => {
|
||||
this._rpcCore.system.health().toPromise().catch((error) => l.warn(`Health keepalive check failed: ${(error as Error).message}`));
|
||||
this._rpcCore.system.health().toPromise().catch(() => undefined);
|
||||
}, KEEPALIVE_INTERVAL);
|
||||
} catch (_error) {
|
||||
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
|
||||
|
||||
l.error(error);
|
||||
l.error(_error);
|
||||
|
||||
this.emit('error', error);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '4.13.1' };
|
||||
|
||||
@@ -48,6 +48,10 @@ describe('ApiPromise', (): void => {
|
||||
provider = new MockProvider(registry);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
describe('initialization', (): void => {
|
||||
it('Create API instance with metadata map and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
|
||||
const rpcData = await provider.send<string>('state_getMetadata', []);
|
||||
@@ -62,6 +66,8 @@ describe('ApiPromise', (): void => {
|
||||
expect(api.query).toBeDefined();
|
||||
expect(api.tx).toBeDefined();
|
||||
expect(api.derive).toBeDefined();
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
it('Create API instance without metadata and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
|
||||
@@ -75,6 +81,8 @@ describe('ApiPromise', (): void => {
|
||||
expect(api.query).toBeDefined();
|
||||
expect(api.tx).toBeDefined();
|
||||
expect(api.derive).toBeDefined();
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
it('Create API instance will error on failure to await ready', async (): Promise<void> => {
|
||||
@@ -88,12 +96,17 @@ describe('ApiPromise', (): void => {
|
||||
}
|
||||
}
|
||||
|
||||
const api = new ErrorApiPromise();
|
||||
|
||||
try {
|
||||
await new ErrorApiPromise().isReadyOrError;
|
||||
await api.isReadyOrError;
|
||||
|
||||
fail('Expected an error but none occurred.');
|
||||
} catch {
|
||||
// Pass
|
||||
}
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -103,31 +116,35 @@ describe('ApiPromise', (): void => {
|
||||
const SIG = '0x659effefbbe5ab4d7136ebb5084b959eb424e32b862307371be4721ac2c46334245af4f1476c36c5e5aff04396c2fdd2ce561ec90382821d4aa071b559b1db0f';
|
||||
|
||||
it('signs data using a specified keyring', async (): Promise<void> => {
|
||||
const api = new ApiPromise({ provider, registry });
|
||||
const api = await ApiPromise.create({ provider, registry });
|
||||
const sig = await api.sign(aliceEd, TEST);
|
||||
|
||||
expect(
|
||||
await api.sign(aliceEd, TEST)
|
||||
).toEqual(SIG);
|
||||
expect(sig).toEqual(SIG);
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
it('signs data using an external signer', async (): Promise<void> => {
|
||||
const api = new ApiPromise({
|
||||
const api = await ApiPromise.create({
|
||||
provider,
|
||||
registry,
|
||||
signer: new SingleAccountSigner(registry, aliceEd)
|
||||
});
|
||||
const sig = await api.sign(ADDR, TEST);
|
||||
|
||||
expect(
|
||||
await api.sign(ADDR, TEST)
|
||||
).toEqual(SIG);
|
||||
expect(sig).toEqual(SIG);
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
describe('decorator.signAsync', (): void => {
|
||||
it('signs a transfer using an external signer', async (): Promise<void> => {
|
||||
const { transfer } = await createTransfer();
|
||||
const { api, transfer } = await createTransfer();
|
||||
|
||||
expect(transfer.signature.toHex()).toEqual(TRANSFER_SIG);
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -137,6 +154,8 @@ describe('ApiPromise', (): void => {
|
||||
|
||||
expect(api.tx(transfer.toHex()).signature.toHex()).toEqual(TRANSFER_SIG);
|
||||
expect(api.tx(transfer).signature.toHex()).toEqual(TRANSFER_SIG);
|
||||
|
||||
await api.disconnect();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from '@polkadot/x-rxjs';
|
||||
import type { SubmittableExtrinsic } from '../submittable/types';
|
||||
|
||||
import { createTestPairs } from '@polkadot/keyring/testingPairs';
|
||||
import { MockProvider } from '@polkadot/rpc-provider/mock';
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { map, switchMap } from '@polkadot/x-rxjs/operators';
|
||||
|
||||
import { SingleAccountSigner } from '../../test/util';
|
||||
import { ApiRx } from '.';
|
||||
|
||||
describe('ApiRx', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const keyring = createTestPairs({ type: 'ed25519' });
|
||||
let provider: MockProvider;
|
||||
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(3000000);
|
||||
provider = new MockProvider(registry);
|
||||
});
|
||||
|
||||
describe('decorator.signAsync', (): void => {
|
||||
it('signs a transfer using an external signer', (): void => {
|
||||
const signer = new SingleAccountSigner(registry, keyring.alice_session);
|
||||
|
||||
ApiRx.create({ provider, registry, signer }).pipe(
|
||||
switchMap((api: ApiRx): Observable<SubmittableExtrinsic<'rxjs'>> =>
|
||||
api.tx.balances
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAsync(keyring.alice_session, {})
|
||||
),
|
||||
map((tx: SubmittableExtrinsic<'rxjs'>): void => {
|
||||
expect(tx.signature.toHex()).toEqual(
|
||||
'0x97f3cfe5088fcd575313e983f45d02b0f630e7b94ff9a3ac50e20cd096a8f554fda73d42ead891b5a1d3ce5607d83f20b0c6570b555e949cfb5763d0abcd590b'
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('allows the second argument to signAsync to be omitted', () => {
|
||||
const signer = new SingleAccountSigner(registry, keyring.alice_session);
|
||||
|
||||
ApiRx.create({ provider, registry, signer }).pipe(
|
||||
switchMap((api: ApiRx): Observable<SubmittableExtrinsic<'rxjs'>> =>
|
||||
api.tx.balances
|
||||
.transfer(keyring.eve.address, 12345)
|
||||
.signAsync(keyring.alice_session)
|
||||
),
|
||||
map((tx: SubmittableExtrinsic<'rxjs'>): void => {
|
||||
expect(tx.signature.toHex()).toEqual(
|
||||
'0x97f3cfe5088fcd575313e983f45d02b0f630e7b94ff9a3ac50e20cd096a8f554fda73d42ead891b5a1d3ce5607d83f20b0c6570b555e949cfb5763d0abcd590b'
|
||||
);
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -82,3 +82,6 @@ export type QueryableStorageMulti<ApiType extends ApiTypes> =
|
||||
export interface AugmentedQueries<ApiType extends ApiTypes> { }
|
||||
|
||||
export type AugmentedQuery<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = MethodResult<ApiType, F> & StorageEntryBase<ApiType, F, A>;
|
||||
|
||||
// backwards compatibility-only
|
||||
export type AugmentedQueryDoubleMap<ApiType extends ApiTypes, F extends AnyFunction, A extends AnyTuple = AnyTuple> = AugmentedQuery<ApiType, F, A>;
|
||||
|
||||
@@ -3,21 +3,24 @@
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
function createApi (): Promise<ApiPromise> {
|
||||
jest.setTimeout(30000);
|
||||
process.env.NODE_ENV = 'test';
|
||||
describe('misc online tests', (): void => {
|
||||
let api: ApiPromise;
|
||||
|
||||
const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
|
||||
// const provider = new WsProvider('wss://westend-rpc.polkadot.io/');
|
||||
// const provider = new WsProvider('ws://127.0.0.1:9944/');
|
||||
beforeEach(async () => {
|
||||
jest.setTimeout(30000);
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
return new ApiPromise({ provider }).isReady;
|
||||
}
|
||||
// const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
|
||||
const provider = new WsProvider('wss://westend-rpc.polkadot.io/');
|
||||
|
||||
api = await ApiPromise.create({ provider });
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await api.disconnect();
|
||||
});
|
||||
|
||||
describe('misc quick tests', (): void => {
|
||||
it.skip('retrieves balances correctly', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
console.error(JSON.stringify(
|
||||
await api.query.system.account('FPzukZw2mphWsXDqdkNzLaxnanjZEWH9i2vqwobTdtde5me')
|
||||
));
|
||||
@@ -27,8 +30,6 @@ describe('misc quick tests', (): void => {
|
||||
});
|
||||
|
||||
it.skip('handles map keys', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
console.time('map.keys');
|
||||
|
||||
const keys = await api.query.system.account.keys();
|
||||
@@ -39,8 +40,6 @@ describe('misc quick tests', (): void => {
|
||||
});
|
||||
|
||||
it.skip('handles map entries', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
console.time('map.entries');
|
||||
|
||||
const entries = await api.query.system.account.entries(); // api.query.indices.accounts.entries();
|
||||
@@ -51,7 +50,6 @@ describe('misc quick tests', (): void => {
|
||||
});
|
||||
|
||||
it.skip('handles doublemap entries', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
const activeEra = await api.query.staking.activeEra();
|
||||
|
||||
console.error(JSON.stringify(
|
||||
@@ -60,26 +58,12 @@ describe('misc quick tests', (): void => {
|
||||
});
|
||||
|
||||
it.skip('does something in society', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
console.error(JSON.stringify(
|
||||
await api.query.society.defenderVotes('Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9')
|
||||
));
|
||||
});
|
||||
|
||||
it.skip('allows for range queries', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
const header = await api.rpc.chain.getHeader();
|
||||
|
||||
console.error(JSON.stringify(
|
||||
(await api.query.staking.activeEra.range([header.parentHash, header.hash], 'Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9'))
|
||||
.map(([block, value]) => [block, value.toRawType(), value.toHuman()])
|
||||
));
|
||||
});
|
||||
|
||||
it('expose rpc and rx definition', async (): Promise<void> => {
|
||||
const api = await createApi();
|
||||
|
||||
it('expose rpc and rx definition', (): void => {
|
||||
console.error(api.rpc.payment.queryFeeDetails.meta);
|
||||
|
||||
console.error(api.rx.rpc.chain.getBlock.meta);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
@@ -20,13 +20,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/types-known": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/types-known": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/util-crypto": "^6.7.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.5.1"
|
||||
"@polkadot/keyring": "^6.7.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
// Copyright 2017-2021 @polkadot/metadata authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||
import type BN from 'bn.js';
|
||||
import type { StorageEntryMetadataLatest, StorageHasher } from '@polkadot/types/interfaces/metadata';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { Codec, Registry } from '@polkadot/types/types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { Raw } from '@polkadot/types/codec';
|
||||
import { StorageKey, Type } from '@polkadot/types/primitive';
|
||||
import { assert, compactAddLength, compactStripLength, isNull, isUndefined, stringCamelCase, stringify, stringLowerFirst, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { assert, compactAddLength, compactStripLength, isUndefined, stringCamelCase, stringLowerFirst, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { xxhashAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { getHasher } from './getHasher';
|
||||
@@ -31,33 +30,27 @@ interface IterFn {
|
||||
meta: StorageEntryMetadataLatest;
|
||||
}
|
||||
|
||||
type CreateArgType = boolean | string | number | null | BN | BigInt | Uint8Array | Codec;
|
||||
|
||||
type U8aHasher = (input: Uint8Array) => Uint8Array;
|
||||
|
||||
function createPrefixedKey ({ method, prefix }: CreateItemFn): Uint8Array {
|
||||
return u8aConcat(xxhashAsU8a(prefix, 128), xxhashAsU8a(method, 128));
|
||||
}
|
||||
|
||||
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
|
||||
const { method, section } = itemFn;
|
||||
type Arg = boolean | string | number | null | BN | BigInt | Uint8Array | Codec;
|
||||
|
||||
/** @internal */
|
||||
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: StorageHasher[], args: Arg[]): Uint8Array {
|
||||
return u8aConcat(
|
||||
createPrefixedKey(itemFn),
|
||||
...keys.map((type, index): Uint8Array => {
|
||||
const arg = args[index];
|
||||
|
||||
assert(!isUndefined(arg) && !isNull(arg), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} has a null or undefined argument at position ${index}`);
|
||||
|
||||
return hashers[index](registry.createType(type.toString() as 'Raw', arg).toU8a());
|
||||
})
|
||||
xxhashAsU8a(itemFn.prefix, 128),
|
||||
xxhashAsU8a(itemFn.method, 128),
|
||||
...keys.map((type, index) =>
|
||||
getHasher(hashers[index])(
|
||||
registry.createType(type.toString() as 'Raw', args[index]).toU8a()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: U8aHasher[], args: CreateArgType[]): Uint8Array {
|
||||
/** @internal */
|
||||
function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: StorageHasher[], args: Arg[]): Uint8Array {
|
||||
const { method, section } = itemFn;
|
||||
|
||||
assert(Array.isArray(args) && args.length === keys.length, () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, found ${stringify(args)}`);
|
||||
assert(Array.isArray(args), () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, provided in tuple format`);
|
||||
assert(args.filter((a) => !isUndefined(a)).length === keys.length, () => `Call to ${stringCamelCase(section || 'unknown')}.${stringCamelCase(method || 'unknown')} needs ${keys.length} arguments, found [${args.join(', ')}]`);
|
||||
|
||||
// as per createKey, always add the length prefix (underlying it is Bytes)
|
||||
return compactAddLength(
|
||||
@@ -65,9 +58,8 @@ function createKey (registry: Registry, itemFn: CreateItemFn, keys: Type[], hash
|
||||
);
|
||||
}
|
||||
|
||||
// attach the metadata to expand to a StorageFunction
|
||||
/** @internal */
|
||||
function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _storageFn: (arg?: CreateArgType | CreateArgType[]) => Uint8Array): StorageEntry {
|
||||
function expandWithMeta ({ meta, method, prefix, section }: CreateItemFn, _storageFn: (arg?: Arg | Arg[]) => Uint8Array): StorageEntry {
|
||||
const storageFn = _storageFn as StorageEntry;
|
||||
|
||||
storageFn.meta = meta;
|
||||
@@ -107,7 +99,6 @@ function extendHeadMeta (registry: Registry, { meta: { documentation, name, type
|
||||
registry.createType('StorageKey', iterFn(...args), { method, section });
|
||||
}
|
||||
|
||||
// attach the full list hashing for prefixed maps
|
||||
/** @internal */
|
||||
function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn: StorageEntry): StorageEntry {
|
||||
const { meta: { type }, method, section } = itemFn;
|
||||
@@ -124,16 +115,16 @@ function extendPrefixedMap (registry: Registry, itemFn: CreateItemFn, storageFn:
|
||||
|
||||
if (args.length) {
|
||||
if (type.isDoubleMap) {
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, [type.asDoubleMap.key1], [getHasher(type.asDoubleMap.hasher)], args as CreateArgType[]));
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, [type.asDoubleMap.key1], [type.asDoubleMap.hasher], args as Arg[]));
|
||||
} else if (type.isNMap) {
|
||||
const keys = [...type.asNMap.keyVec];
|
||||
const hashers = type.asNMap.hashers.map((h) => getHasher(h));
|
||||
const hashers = [...type.asNMap.hashers];
|
||||
|
||||
// remove the last entry
|
||||
keys.pop();
|
||||
hashers.pop();
|
||||
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, keys, hashers, args as CreateArgType[]));
|
||||
return new Raw(registry, createKeyRaw(registry, itemFn, keys, hashers, args as Arg[]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,16 +142,16 @@ export function createFunction (registry: Registry, itemFn: CreateItemFn, option
|
||||
// - storage.system.account(address)
|
||||
// - storage.timestamp.blockPeriod()
|
||||
// For higher-map queries the params are passed in as an tuple, [key1, key2]
|
||||
const storageFn = expandWithMeta(itemFn, (arg?: CreateArgType | CreateArgType[]) =>
|
||||
const storageFn = expandWithMeta(itemFn, (arg?: Arg | Arg[]) =>
|
||||
type.isPlain
|
||||
? options.skipHashing
|
||||
? compactAddLength(u8aToU8a(options.key))
|
||||
: createKey(registry, itemFn, [], [], [])
|
||||
: type.isMap
|
||||
? createKey(registry, itemFn, [type.asMap.key], [getHasher(type.asMap.hasher)], [arg as CreateArgType])
|
||||
? createKey(registry, itemFn, [type.asMap.key], [type.asMap.hasher], [arg as Arg])
|
||||
: type.isDoubleMap
|
||||
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [getHasher(type.asDoubleMap.hasher), getHasher(type.asDoubleMap.key2Hasher)], arg as CreateArgType[])
|
||||
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers.map((h) => getHasher(h)), arg as CreateArgType[])
|
||||
? createKey(registry, itemFn, [type.asDoubleMap.key1, type.asDoubleMap.key2], [type.asDoubleMap.hasher, type.asDoubleMap.key2Hasher], arg as Arg[])
|
||||
: createKey(registry, itemFn, type.asNMap.keyVec, type.asNMap.hashers, arg as Arg[])
|
||||
);
|
||||
|
||||
if (type.isMap || type.isDoubleMap || type.isNMap) {
|
||||
|
||||
@@ -12,34 +12,36 @@ import { decorateStorage } from '..';
|
||||
const keyring = createTestPairs({ type: 'ed25519' });
|
||||
|
||||
describe('decorateStorage', (): void => {
|
||||
describe('latest', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
const registry = new TypeRegistry();
|
||||
const metadata = new Metadata(registry, rpcMetadata);
|
||||
|
||||
registry.setMetadata(metadata);
|
||||
registry.setMetadata(metadata);
|
||||
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect(() => query.balances.account()).toThrowError('Call to balances.account has a null or undefined argument at position 0');
|
||||
});
|
||||
it('should throw if the storage function expects an argument', (): void => {
|
||||
expect(() => query.balances.account()).toThrowError('Call to balances.account needs 1 arguments, found []');
|
||||
});
|
||||
|
||||
it('should throw if the storage function expects multiple arguments', (): void => {
|
||||
expect(() => query.staking.erasStakers([1])).toThrowError('Call to staking.erasStakers needs 2 arguments, found [1]');
|
||||
});
|
||||
it('should throw if the storage function expects multiple arguments', (): void => {
|
||||
expect(() => query.staking.erasStakers([1])).toThrowError('Call to staking.erasStakers needs 2 arguments, found [1]');
|
||||
});
|
||||
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect(() => query.timestamp.now()).not.toThrow();
|
||||
});
|
||||
it('should throw if the storage function expects tuple arguments', (): void => {
|
||||
expect(() => query.staking.erasStakers(1)).toThrowError('Call to staking.erasStakers needs 2 arguments, provided in tuple format');
|
||||
});
|
||||
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
query.system.account(keyring.alice.address)
|
||||
)
|
||||
).toEqual(
|
||||
'0x410126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
|
||||
);
|
||||
});
|
||||
it('should return a value if the storage function does not expect an argument', (): void => {
|
||||
expect(() => query.timestamp.now()).not.toThrow();
|
||||
});
|
||||
|
||||
it('should return the correct length-prefixed storage key', (): void => {
|
||||
expect(
|
||||
u8aToHex(
|
||||
query.system.account(keyring.alice.address)
|
||||
)
|
||||
).toEqual(
|
||||
'0x410126aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da9de1e86a9a8c739864cf3cc5ec2bea59fd43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/metadata', version: '4.13.1' };
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,72 +1,3 @@
|
||||
# @polkadot/rpc-core
|
||||
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot network client.
|
||||
|
||||
## Usage
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
yarn add @polkadot/rpc-core
|
||||
```
|
||||
|
||||
Initialization -
|
||||
|
||||
```js
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider/ws';
|
||||
|
||||
const provider = new WsProvider('http://127.0.0.1:9944');
|
||||
const rpc = new Rpc(provider);
|
||||
```
|
||||
|
||||
Retrieving the block header object for a given block header hash (a 0x-prefixed hex string with length of 64) -
|
||||
|
||||
```js
|
||||
rpc.chain
|
||||
.getHeader('0x1234567890')
|
||||
.subscribe(
|
||||
(header) => console.log(header),
|
||||
(error) => console.error('error:', error)
|
||||
);
|
||||
```
|
||||
|
||||
Retrieving the best block number, parent hash, state root hash, extrinsics root hash, and digest (once-off) -
|
||||
|
||||
```js
|
||||
rpc.chain
|
||||
.getHead()
|
||||
.pipe(
|
||||
switchMap((headerHash) => {
|
||||
return rpc.chain.getHeader(headerHash);
|
||||
})
|
||||
)
|
||||
.subscribe(
|
||||
(header) => {
|
||||
console.log(`best #${header.number.toString()}`);
|
||||
console.log(`parentHash: ${header.parentHash.toString()}`);
|
||||
console.log(`stateRoot: ${header.stateRoot.toString()}`);
|
||||
console.log(`extrinsicsRoot: ${header.extrinsicsRoot.toString()}`);
|
||||
console.log(`digest: ${header.digest.toString()}`);
|
||||
},
|
||||
(error) => {
|
||||
console.error('error:', error);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
Retrieving best header via subscription -
|
||||
|
||||
```js
|
||||
api.chain
|
||||
rpc
|
||||
.subscribeNewHeads()
|
||||
.subscribe(
|
||||
(header) => {
|
||||
console.log(`best #${header.number}`);
|
||||
},
|
||||
(error) => {
|
||||
console.error('error subscribing:', error);
|
||||
}
|
||||
);
|
||||
```
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot network client. It is only used internally to the API.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
@@ -20,13 +20,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/metadata": "4.11.1",
|
||||
"@polkadot/rpc-provider": "4.11.1",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1"
|
||||
"@polkadot/metadata": "4.13.1",
|
||||
"@polkadot/rpc-provider": "4.13.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/x-rxjs": "^6.7.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.5.1"
|
||||
"@polkadot/keyring": "^6.7.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,16 @@ import { RpcCore } from '.';
|
||||
describe('Cached Observables', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
let rpc: RpcCore & RpcInterface;
|
||||
let provider: MockProvider;
|
||||
const keyring = createTestPairs();
|
||||
|
||||
beforeEach((): void => {
|
||||
rpc = new RpcCore('123', registry, new MockProvider(registry)) as (RpcCore & RpcInterface);
|
||||
provider = new MockProvider(registry);
|
||||
rpc = new RpcCore('123', registry, provider) as (RpcCore & RpcInterface);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('creates a single observable for subscriptions (multiple calls)', (): void => {
|
||||
|
||||
@@ -16,8 +16,9 @@ describe('Api', (): void => {
|
||||
).toThrow(/Expected Provider/);
|
||||
});
|
||||
|
||||
it('allows for the definition of user RPCs', (): void => {
|
||||
const rpc = new RpcCore('567', registry, new MockProvider(registry), {
|
||||
it('allows for the definition of user RPCs', async () => {
|
||||
const provider = new MockProvider(registry);
|
||||
const rpc = new RpcCore('567', registry, provider, {
|
||||
testing: {
|
||||
foo: {
|
||||
description: 'foo',
|
||||
@@ -42,5 +43,7 @@ describe('Api', (): void => {
|
||||
section: 'testing',
|
||||
type: 'Balance'
|
||||
});
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '4.13.1' };
|
||||
|
||||
@@ -13,9 +13,15 @@ import { RpcCore } from '.';
|
||||
describe('replay', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
let rpc: RpcCore & RpcInterface;
|
||||
let provider: MockProvider;
|
||||
|
||||
beforeEach((): void => {
|
||||
rpc = new RpcCore('653', registry, new MockProvider(registry)) as (RpcCore & RpcInterface);
|
||||
provider = new MockProvider(registry);
|
||||
rpc = new RpcCore('653', registry, provider) as (RpcCore & RpcInterface);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('subscribes via the rpc section', (done): void => {
|
||||
|
||||
@@ -6,28 +6,39 @@ import { of, timer } from '@polkadot/x-rxjs';
|
||||
import { drr } from '.';
|
||||
|
||||
describe('drr', (): void => {
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(15000);
|
||||
});
|
||||
|
||||
it('should not fire twice the same value', (done): void => {
|
||||
let count = 0;
|
||||
|
||||
of(1, 1).pipe(drr()).subscribe((): void => { ++count; });
|
||||
const sub = of(1, 1).pipe(drr({ delay: 500 })).subscribe((): void => { ++count; });
|
||||
|
||||
setTimeout((): void => {
|
||||
expect(count).toBe(1);
|
||||
done();
|
||||
sub.unsubscribe();
|
||||
|
||||
setTimeout(done, 2000);
|
||||
}, 50);
|
||||
});
|
||||
|
||||
it('should be a ReplaySubject(1)', (done): void => {
|
||||
const obs = timer(0, 100).pipe(drr()); // Starts at 0, increments every 100ms
|
||||
const obs = timer(0, 100).pipe(drr({ delay: 500 })); // Starts at 0, increments every 100ms
|
||||
|
||||
obs.subscribe(); // Fire the observable
|
||||
const sub = obs.subscribe(); // Fire the observable
|
||||
|
||||
// Subscribe another time after some time, i.e. after the observable has fired
|
||||
setTimeout((): void => {
|
||||
obs.subscribe((value): void => {
|
||||
const sub = obs.subscribe((value): void => {
|
||||
expect(value > 1).toBe(true);
|
||||
done();
|
||||
|
||||
setTimeout(done, 2000);
|
||||
});
|
||||
|
||||
sub.unsubscribe();
|
||||
}, 500);
|
||||
|
||||
sub.unsubscribe();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
@@ -20,19 +20,19 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/x-fetch": "^6.5.1",
|
||||
"@polkadot/x-global": "^6.5.1",
|
||||
"@polkadot/x-ws": "^6.5.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/util-crypto": "^6.7.1",
|
||||
"@polkadot/x-fetch": "^6.7.1",
|
||||
"@polkadot/x-global": "^6.7.1",
|
||||
"@polkadot/x-ws": "^6.7.1",
|
||||
"bn.js": "^4.11.9",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.5.1",
|
||||
"@polkadot/metadata": "4.11.1",
|
||||
"@polkadot/keyring": "^6.7.1",
|
||||
"@polkadot/metadata": "4.13.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.0.11"
|
||||
"nock": "^13.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ export class MockProvider implements ProviderInterface {
|
||||
|
||||
private emitter = new EventEmitter();
|
||||
|
||||
private intervalId?: NodeJS.Timeout | null;
|
||||
|
||||
public isUpdating = true;
|
||||
|
||||
private registry: Registry;
|
||||
@@ -104,8 +106,12 @@ export class MockProvider implements ProviderInterface {
|
||||
// noop
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/require-await
|
||||
public async disconnect (): Promise<void> {
|
||||
// noop
|
||||
if (this.intervalId) {
|
||||
clearInterval(this.intervalId);
|
||||
this.intervalId = null;
|
||||
}
|
||||
}
|
||||
|
||||
public get isConnected (): boolean {
|
||||
@@ -175,7 +181,7 @@ export class MockProvider implements ProviderInterface {
|
||||
const query = decorateStorage(this.registry, metadata.asLatest, metadata.version);
|
||||
|
||||
// Do something every 1 seconds
|
||||
setInterval((): void => {
|
||||
this.intervalId = setInterval((): void => {
|
||||
if (!this.isUpdating) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@ describe('on', (): void => {
|
||||
mock = new MockProvider(registry);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await mock.disconnect();
|
||||
});
|
||||
|
||||
it('it emits both connected and disconnected events', (done): void => {
|
||||
const events: Record<string, boolean> = { connected: false, disconnected: false };
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ describe('send', (): void => {
|
||||
mock = new MockProvider(registry);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await mock.disconnect();
|
||||
});
|
||||
|
||||
it('fails on non-supported methods', (): Promise<any> => {
|
||||
return mock
|
||||
.send('something_invalid', [])
|
||||
|
||||
@@ -13,6 +13,10 @@ describe('subscribe', (): void => {
|
||||
mock = new MockProvider(registry);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await mock.disconnect();
|
||||
});
|
||||
|
||||
it('fails on unknown methods', (): Promise<number | void> => {
|
||||
return mock
|
||||
.subscribe('test', 'test_notFound')
|
||||
@@ -29,28 +33,28 @@ describe('subscribe', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
it('calls back with the last known value', (done): Promise<number> => {
|
||||
it('calls back with the last known value', (done): void => {
|
||||
mock.isUpdating = false;
|
||||
mock.subscriptions.chain_subscribeNewHead.lastValue = 'testValue';
|
||||
|
||||
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, value: string): void => {
|
||||
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, value: string): void => {
|
||||
expect(value).toEqual('testValue');
|
||||
done();
|
||||
});
|
||||
}).catch(console.error);
|
||||
});
|
||||
|
||||
it('calls back with new headers', (done): Promise<number> => {
|
||||
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
|
||||
it('calls back with new headers', (done): void => {
|
||||
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
|
||||
if (header.number === 4) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
}).catch(console.error);
|
||||
});
|
||||
|
||||
it('handles errors withing callbacks gracefully', (done): Promise<number> => {
|
||||
it('handles errors withing callbacks gracefully', (done): void => {
|
||||
let hasThrown = false;
|
||||
|
||||
return mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
|
||||
mock.subscribe('chain_newHead', 'chain_subscribeNewHead', (_: any, header: { number: number }): void => {
|
||||
if (!hasThrown) {
|
||||
hasThrown = true;
|
||||
|
||||
@@ -60,6 +64,6 @@ describe('subscribe', (): void => {
|
||||
if (header.number === 3) {
|
||||
done();
|
||||
}
|
||||
});
|
||||
}).catch(console.error);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,6 +20,10 @@ describe('unsubscribe', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await mock.disconnect();
|
||||
});
|
||||
|
||||
it('fails on unknown ids', (): Promise<boolean> => {
|
||||
return mock
|
||||
.unsubscribe('chain_newHead', 'chain_subscribeNewHead', 5)
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '4.13.1' };
|
||||
|
||||
@@ -3,9 +3,11 @@
|
||||
|
||||
import type { Mock } from './../mock/types';
|
||||
|
||||
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { WsProvider } from './';
|
||||
|
||||
const TEST_WS_URL = 'ws://localhost-connect.spec.ts:9988';
|
||||
|
||||
function sleepMs (ms = 0): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
@@ -15,7 +17,7 @@ describe('onConnect', (): void => {
|
||||
|
||||
beforeEach((): void => {
|
||||
jest.setTimeout(30000);
|
||||
mocks = [mockWs([])];
|
||||
mocks = [mockWs([], TEST_WS_URL)];
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
@@ -27,9 +29,19 @@ describe('onConnect', (): void => {
|
||||
});
|
||||
});
|
||||
|
||||
it('Does not connect when autoConnect is false', (): void => {
|
||||
it('Does not connect when autoConnect is false', async () => {
|
||||
const provider: WsProvider = new WsProvider(TEST_WS_URL, 0);
|
||||
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
expect(provider.isConnected).toBe(false);
|
||||
|
||||
await provider.connect();
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
expect(provider.isConnected).toBe(true);
|
||||
|
||||
await provider.disconnect();
|
||||
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
expect(provider.isConnected).toBe(false);
|
||||
});
|
||||
|
||||
@@ -38,6 +50,8 @@ describe('onConnect', (): void => {
|
||||
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
expect(provider.isConnected).toBe(true);
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('Creates a new WebSocket instance by calling the connect() method', async () => {
|
||||
@@ -50,7 +64,9 @@ describe('onConnect', (): void => {
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
|
||||
expect(provider.isConnected).toBe(true);
|
||||
expect(mocks[0].server.clients().length).toBe(1);
|
||||
expect(mocks[0].server.clients()).toHaveLength(1);
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('Connects to first endpoint when an array is given', async () => {
|
||||
@@ -60,22 +76,26 @@ describe('onConnect', (): void => {
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
|
||||
expect(provider.isConnected).toBe(true);
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('Connects to the second endpoint when the first is unreachable', async () => {
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
jest.spyOn(console, 'error').mockImplementation((): void => {});
|
||||
|
||||
const endpoints: string[] = ['ws://localhost:9956', TEST_WS_URL];
|
||||
const endpoints: string[] = ['ws://localhost-connect.spec.ts:9956', TEST_WS_URL];
|
||||
const provider: WsProvider = new WsProvider(endpoints, 1);
|
||||
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
|
||||
expect(provider.isConnected).toBe(true);
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('Connects to the second endpoint when the first is dropped', async () => {
|
||||
const endpoints: string[] = [TEST_WS_URL, 'ws://localhost:9957'];
|
||||
const endpoints: string[] = [TEST_WS_URL, 'ws://localhost-connect.spec.ts:9957'];
|
||||
|
||||
mocks.push(mockWs([], endpoints[1]));
|
||||
|
||||
@@ -83,26 +103,27 @@ describe('onConnect', (): void => {
|
||||
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
// Check that first server is connected
|
||||
expect(mocks[0].server.clients().length).toBe(1);
|
||||
expect(mocks[1].server.clients().length).toBe(0);
|
||||
expect(mocks[0].server.clients()).toHaveLength(1);
|
||||
expect(mocks[1].server.clients()).toHaveLength(0);
|
||||
|
||||
// Close connection from first server
|
||||
mocks[0].server.clients()[0].close();
|
||||
await sleepMs(100);
|
||||
|
||||
// Check that second server is connected
|
||||
expect(mocks[1].server.clients().length).toBe(1);
|
||||
expect(mocks[1].server.clients()).toHaveLength(1);
|
||||
expect(provider.isConnected).toBe(true);
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
|
||||
it('Round-robin of endpoints on WsProvider', async () => {
|
||||
const rounds = 5;
|
||||
const endpoints: string[] = [
|
||||
TEST_WS_URL,
|
||||
'ws://localhost:9956',
|
||||
'ws://localhost:9957',
|
||||
'ws://invalid:9956',
|
||||
'ws://localhost:9958'
|
||||
'ws://localhost-connect.spec.ts:9956',
|
||||
'ws://localhost-connect.spec.ts:9957',
|
||||
'ws://invalid-connect.spec.ts:9956',
|
||||
'ws://localhost-connect.spec.ts:9958'
|
||||
];
|
||||
|
||||
mocks.push(mockWs([], endpoints[1]));
|
||||
@@ -117,18 +138,20 @@ describe('onConnect', (): void => {
|
||||
];
|
||||
const provider: WsProvider = new WsProvider(endpoints, 1);
|
||||
|
||||
for (let round = 0; round < rounds; round++) {
|
||||
for (let index = 0; index < mocks.length; index++) {
|
||||
for (let round = 0; round < 5; round++) {
|
||||
for (let mock = 0; mock < mocks.length; mock++) {
|
||||
await sleepMs(100); // Hack to give the provider time to connect
|
||||
|
||||
// Check that first server is connected and the next one isn't
|
||||
expect(mocks[index].server.clients().length).toBe(1);
|
||||
expect(mockNext[index].server.clients().length).toBe(0);
|
||||
expect(mocks[mock].server.clients()).toHaveLength(1);
|
||||
expect(mockNext[mock].server.clients()).toHaveLength(0);
|
||||
expect(provider.isConnected).toBe(true);
|
||||
|
||||
// Close connection from first server
|
||||
mocks[index].server.clients()[0].close();
|
||||
mocks[mock].server.clients()[0].close();
|
||||
}
|
||||
}
|
||||
|
||||
await provider.disconnect();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,25 +1,32 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Mock } from './../mock/types';
|
||||
import { WsProvider } from './';
|
||||
|
||||
let ws: WsProvider;
|
||||
const TEST_WS_URL = 'ws://localhost-index.spec.ts:9977';
|
||||
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createWs (requests: any[], autoConnect: number | undefined = 1000): WsProvider {
|
||||
mock = mockWs(requests);
|
||||
ws = new WsProvider(TEST_WS_URL, autoConnect);
|
||||
function createWs (requests: any[], autoConnect = 1000, headers?: Record<string, string>): WsProvider {
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
provider = new WsProvider(TEST_WS_URL, autoConnect, headers);
|
||||
|
||||
return ws;
|
||||
return provider;
|
||||
}
|
||||
|
||||
describe('Ws', (): void => {
|
||||
afterEach((): void => {
|
||||
afterEach(async () => {
|
||||
if (mock) {
|
||||
mock.done();
|
||||
}
|
||||
|
||||
if (provider) {
|
||||
await provider.disconnect();
|
||||
provider = null;
|
||||
}
|
||||
});
|
||||
|
||||
it('returns the connected state', (): void => {
|
||||
@@ -28,10 +35,8 @@ describe('Ws', (): void => {
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows you to initialize the provider with custom headers', (): void => {
|
||||
expect(
|
||||
(): WsProvider => new WsProvider(TEST_WS_URL, 1000, { foo: 'bar' })
|
||||
).not.toThrow();
|
||||
it('allows you to initialize the provider with custom headers', () => {
|
||||
createWs([], 100, { foo: 'bar' });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,10 +47,9 @@ describe('Endpoint Parsing', (): void => {
|
||||
});
|
||||
|
||||
it('Throws when WsProvider endpoint is an invalid string', () => {
|
||||
expect(() => {
|
||||
/* eslint-disable no-new */
|
||||
new WsProvider('http://127.0.0.1:9955', 0);
|
||||
}).toThrowError(/^Endpoint should start with /);
|
||||
expect(
|
||||
() => new WsProvider('http://127.0.0.1:9955', 0)
|
||||
).toThrowError(/^Endpoint should start with /);
|
||||
});
|
||||
|
||||
it('Succeeds when WsProvider endpoint is a valid array', () => {
|
||||
@@ -58,18 +62,16 @@ describe('Endpoint Parsing', (): void => {
|
||||
it('Throws when WsProvider endpoint is an empty array', () => {
|
||||
const endpoints: string[] = [];
|
||||
|
||||
expect(() => {
|
||||
/* eslint-disable no-new */
|
||||
new WsProvider(endpoints, 0);
|
||||
}).toThrowError('WsProvider requires at least one Endpoint');
|
||||
expect(
|
||||
() => new WsProvider(endpoints, 0)
|
||||
).toThrowError('WsProvider requires at least one Endpoint');
|
||||
});
|
||||
|
||||
it('Throws when WsProvider endpoint is an invalid array', () => {
|
||||
const endpoints: string[] = ['ws://127.0.0.1:9955', 'http://bad.co:9944', 'ws://mychain.com:9933'];
|
||||
|
||||
expect(() => {
|
||||
/* eslint-disable no-new */
|
||||
new WsProvider(endpoints, 0);
|
||||
}).toThrowError(/^Endpoint should start with /);
|
||||
expect(
|
||||
() => new WsProvider(endpoints, 0)
|
||||
).toThrowError(/^Endpoint should start with /);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,17 +3,19 @@
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
|
||||
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Global, Mock } from './../mock/types';
|
||||
import { WsProvider } from './';
|
||||
|
||||
declare const global: Global;
|
||||
|
||||
let provider: WsProvider;
|
||||
const TEST_WS_URL = 'ws://localhost-send.spec.ts:9965';
|
||||
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createMock (requests: any[]): void {
|
||||
mock = mockWs(requests);
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
}
|
||||
|
||||
function createWs (autoConnect = 1000): Promise<WsProvider> {
|
||||
@@ -29,12 +31,17 @@ describe('send', (): void => {
|
||||
globalWs = global.WebSocket;
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
afterEach(async () => {
|
||||
global.WebSocket = globalWs;
|
||||
|
||||
if (mock) {
|
||||
mock.done();
|
||||
}
|
||||
|
||||
if (provider) {
|
||||
await provider.disconnect();
|
||||
provider = null;
|
||||
}
|
||||
});
|
||||
|
||||
it('handles internal errors', (): Promise<any> => {
|
||||
|
||||
@@ -6,13 +6,13 @@ import { WsProvider } from './';
|
||||
describe('state', (): void => {
|
||||
it('requires an ws:// prefixed endpoint', (): void => {
|
||||
expect(
|
||||
(): WsProvider => new WsProvider('http://', 0)
|
||||
() => new WsProvider('http://', 0)
|
||||
).toThrow(/with 'ws/);
|
||||
});
|
||||
|
||||
it('allows wss:// endpoints', (): void => {
|
||||
expect(
|
||||
(): WsProvider => new WsProvider('wss://', 0)
|
||||
() => new WsProvider('wss://', 0)
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,23 +3,25 @@
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
|
||||
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Global, Mock } from './../mock/types';
|
||||
import { WsProvider } from './';
|
||||
|
||||
declare const global: Global;
|
||||
|
||||
let ws: WsProvider;
|
||||
const TEST_WS_URL = 'ws://localhost-subscribe.test.ts:9933';
|
||||
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createMock (requests: any[]): void {
|
||||
mock = mockWs(requests);
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
}
|
||||
|
||||
function createWs (autoConnect = 1000): Promise<WsProvider> {
|
||||
ws = new WsProvider(TEST_WS_URL, autoConnect);
|
||||
provider = new WsProvider(TEST_WS_URL, autoConnect);
|
||||
|
||||
return ws.isReady;
|
||||
return provider.isReady;
|
||||
}
|
||||
|
||||
describe('subscribe', (): void => {
|
||||
@@ -29,12 +31,17 @@ describe('subscribe', (): void => {
|
||||
globalWs = global.WebSocket;
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
afterEach(async () => {
|
||||
global.WebSocket = globalWs;
|
||||
|
||||
if (mock) {
|
||||
mock.done();
|
||||
}
|
||||
|
||||
if (provider) {
|
||||
await provider.disconnect();
|
||||
provider = null;
|
||||
}
|
||||
});
|
||||
|
||||
it('adds subscriptions', (): Promise<void> => {
|
||||
|
||||
@@ -3,23 +3,25 @@
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
|
||||
import { mockWs, TEST_WS_URL } from '../../test/mockWs';
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Global, Mock } from './../mock/types';
|
||||
import { WsProvider } from './';
|
||||
|
||||
declare const global: Global;
|
||||
|
||||
let ws: WsProvider;
|
||||
const TEST_WS_URL = 'ws://localhost-unsubscribe.test.ts:9933';
|
||||
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createMock (requests: any): void {
|
||||
mock = mockWs(requests);
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
}
|
||||
|
||||
function createWs (autoConnect = 1000): Promise<WsProvider> {
|
||||
ws = new WsProvider(TEST_WS_URL, autoConnect);
|
||||
provider = new WsProvider(TEST_WS_URL, autoConnect);
|
||||
|
||||
return ws.isReady;
|
||||
return provider.isReady;
|
||||
}
|
||||
|
||||
describe('subscribe', (): void => {
|
||||
@@ -29,12 +31,17 @@ describe('subscribe', (): void => {
|
||||
globalWs = global.WebSocket;
|
||||
});
|
||||
|
||||
afterEach((): void => {
|
||||
afterEach(async () => {
|
||||
global.WebSocket = globalWs;
|
||||
|
||||
if (mock) {
|
||||
mock.done();
|
||||
}
|
||||
|
||||
if (provider) {
|
||||
await provider.disconnect();
|
||||
provider = null;
|
||||
}
|
||||
});
|
||||
|
||||
it('removes subscriptions', (): Promise<boolean> => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
@@ -29,11 +29,11 @@
|
||||
"@babel/core": "^7.14.3",
|
||||
"@babel/register": "^7.13.16",
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/api": "4.11.1",
|
||||
"@polkadot/metadata": "4.11.1",
|
||||
"@polkadot/rpc-provider": "4.11.1",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/api": "4.13.1",
|
||||
"@polkadot/metadata": "4.13.1",
|
||||
"@polkadot/rpc-provider": "4.13.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.0.1"
|
||||
|
||||
@@ -14,6 +14,7 @@ import { stringCamelCase } from '@polkadot/util';
|
||||
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, writeFile } from '../util';
|
||||
|
||||
const MAPPED_NAMES: Record<string, string> = {
|
||||
class: 'clazz',
|
||||
new: 'updated'
|
||||
};
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '4.13.1' };
|
||||
|
||||
@@ -74,6 +74,9 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
|
||||
setImports(definitions, imports, ['IExtrinsic']);
|
||||
|
||||
return ['IExtrinsic'];
|
||||
} else if (type === 'Keys') {
|
||||
// This one is weird... surely it should popup as a Tuple? (but either way better as defined hex)
|
||||
return ['Keys', 'string', 'Uint8Array'];
|
||||
} else if (type === 'StorageKey') {
|
||||
// TODO We can do better
|
||||
return ['StorageKey', 'string', 'Uint8Array', 'any'];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
@@ -20,9 +20,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/networks": "^6.5.1",
|
||||
"@polkadot/types": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/networks": "^6.7.1",
|
||||
"@polkadot/types": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '4.13.1' };
|
||||
|
||||
@@ -24,7 +24,8 @@ const typesSpec: Record<string, OverrideVersionedType[]> = {
|
||||
shell,
|
||||
statemine: statemint,
|
||||
statemint,
|
||||
westend
|
||||
westend,
|
||||
westmint: statemint
|
||||
};
|
||||
|
||||
export default typesSpec;
|
||||
|
||||
@@ -12,7 +12,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[2201991, 1062], [2671528, 2005], [2704202, 2007], [2728002, 2008], [2832534, 2011],
|
||||
[2962294, 2012], [3240000, 2013], [3274408, 2015], [3323565, 2019], [3534175, 2022],
|
||||
[3860281, 2023], [4143129, 2024], [4401242, 2025], [4841367, 2026], [5961600, 2027],
|
||||
[6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010]
|
||||
[6137912, 2028], [6561855, 2029], [7100891, 2030], [7468792, 9010], [7668600, 9030]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -9,7 +9,8 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[1030162, 31], [1119657, 32], [1199282, 33], [1342534, 34], [1392263, 35],
|
||||
[1431703, 36], [1433369, 37], [1490972, 41], [2087397, 43], [2316688, 44],
|
||||
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49],
|
||||
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010]
|
||||
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010], [5784566, 9030],
|
||||
[5879822, 9031], [5896856, 9032], [5897316, 9033]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "4.11.1",
|
||||
"version": "4.13.1",
|
||||
"type": "module",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
@@ -20,14 +20,14 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.0",
|
||||
"@polkadot/metadata": "4.11.1",
|
||||
"@polkadot/util": "^6.5.1",
|
||||
"@polkadot/util-crypto": "^6.5.1",
|
||||
"@polkadot/x-rxjs": "^6.5.1",
|
||||
"@polkadot/metadata": "4.13.1",
|
||||
"@polkadot/util": "^6.7.1",
|
||||
"@polkadot/util-crypto": "^6.7.1",
|
||||
"@polkadot/x-rxjs": "^6.7.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^6.5.1"
|
||||
"@polkadot/keyring": "^6.7.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import type { RawAuraPreDigest } from '@polkadot/types/interfaces/aura';
|
||||
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
|
||||
import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
|
||||
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
|
||||
import type { BeefyCommitment, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BridgedBlockHash, BridgedBlockNumber, BridgedHeader, InitializationData } from '@polkadot/types/interfaces/bridges';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
@@ -36,14 +36,14 @@ import type { DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMap
|
||||
import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
|
||||
import type { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayBlockNumber, RelayChainBlockNumber, RelayChainHash, RelayHash, Remark, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidateInfo, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayBlockNumber, RelayChainBlockNumber, RelayChainHash, RelayHash, Remark, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import type { FeeDetails, InclusionFee, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { Approvals } from '@polkadot/types/interfaces/poll';
|
||||
import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionPriority, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
|
||||
import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
@@ -269,6 +269,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<CandidateCommitments>': Option<CandidateCommitments>;
|
||||
'Option<CandidateDescriptor>': Option<CandidateDescriptor>;
|
||||
'Option<CandidateHash>': Option<CandidateHash>;
|
||||
'Option<CandidateInfo>': Option<CandidateInfo>;
|
||||
'Option<CandidatePendingAvailability>': Option<CandidatePendingAvailability>;
|
||||
'Option<CandidateReceipt>': Option<CandidateReceipt>;
|
||||
'Option<ChainProperties>': Option<ChainProperties>;
|
||||
@@ -785,6 +786,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<ReportedRoundStates>': Option<ReportedRoundStates>;
|
||||
'Option<Reporter>': Option<Reporter>;
|
||||
'Option<ReportIdOf>': Option<ReportIdOf>;
|
||||
'Option<ReserveData>': Option<ReserveData>;
|
||||
'Option<ReserveIdentifier>': Option<ReserveIdentifier>;
|
||||
'Option<Retriable>': Option<Retriable>;
|
||||
'Option<RewardDestination>': Option<RewardDestination>;
|
||||
'Option<RewardPoint>': Option<RewardPoint>;
|
||||
@@ -921,7 +924,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Option<TombstoneContractInfo>': Option<TombstoneContractInfo>;
|
||||
'Option<TraceBlockResponse>': Option<TraceBlockResponse>;
|
||||
'Option<TraceError>': Option<TraceError>;
|
||||
'Option<TransactionInfo>': Option<TransactionInfo>;
|
||||
'Option<TransactionPriority>': Option<TransactionPriority>;
|
||||
'Option<TransactionStorageProof>': Option<TransactionStorageProof>;
|
||||
'Option<TransactionValidityError>': Option<TransactionValidityError>;
|
||||
'Option<TransientValidationData>': Option<TransientValidationData>;
|
||||
'Option<TreasuryProposal>': Option<TreasuryProposal>;
|
||||
@@ -1137,6 +1142,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<CandidateCommitments>': Vec<CandidateCommitments>;
|
||||
'Vec<CandidateDescriptor>': Vec<CandidateDescriptor>;
|
||||
'Vec<CandidateHash>': Vec<CandidateHash>;
|
||||
'Vec<CandidateInfo>': Vec<CandidateInfo>;
|
||||
'Vec<CandidatePendingAvailability>': Vec<CandidatePendingAvailability>;
|
||||
'Vec<CandidateReceipt>': Vec<CandidateReceipt>;
|
||||
'Vec<ChainProperties>': Vec<ChainProperties>;
|
||||
@@ -1653,6 +1659,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<ReportedRoundStates>': Vec<ReportedRoundStates>;
|
||||
'Vec<Reporter>': Vec<Reporter>;
|
||||
'Vec<ReportIdOf>': Vec<ReportIdOf>;
|
||||
'Vec<ReserveData>': Vec<ReserveData>;
|
||||
'Vec<ReserveIdentifier>': Vec<ReserveIdentifier>;
|
||||
'Vec<Retriable>': Vec<Retriable>;
|
||||
'Vec<RewardDestination>': Vec<RewardDestination>;
|
||||
'Vec<RewardPoint>': Vec<RewardPoint>;
|
||||
@@ -1789,7 +1797,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Vec<TombstoneContractInfo>': Vec<TombstoneContractInfo>;
|
||||
'Vec<TraceBlockResponse>': Vec<TraceBlockResponse>;
|
||||
'Vec<TraceError>': Vec<TraceError>;
|
||||
'Vec<TransactionInfo>': Vec<TransactionInfo>;
|
||||
'Vec<TransactionPriority>': Vec<TransactionPriority>;
|
||||
'Vec<TransactionStorageProof>': Vec<TransactionStorageProof>;
|
||||
'Vec<TransactionValidityError>': Vec<TransactionValidityError>;
|
||||
'Vec<TransientValidationData>': Vec<TransientValidationData>;
|
||||
'Vec<TreasuryProposal>': Vec<TreasuryProposal>;
|
||||
@@ -2005,6 +2015,7 @@ declare module '@polkadot/types/types/registry' {
|
||||
CandidateCommitments: CandidateCommitments;
|
||||
CandidateDescriptor: CandidateDescriptor;
|
||||
CandidateHash: CandidateHash;
|
||||
CandidateInfo: CandidateInfo;
|
||||
CandidatePendingAvailability: CandidatePendingAvailability;
|
||||
CandidateReceipt: CandidateReceipt;
|
||||
ChainProperties: ChainProperties;
|
||||
@@ -2521,6 +2532,8 @@ declare module '@polkadot/types/types/registry' {
|
||||
ReportedRoundStates: ReportedRoundStates;
|
||||
Reporter: Reporter;
|
||||
ReportIdOf: ReportIdOf;
|
||||
ReserveData: ReserveData;
|
||||
ReserveIdentifier: ReserveIdentifier;
|
||||
Retriable: Retriable;
|
||||
RewardDestination: RewardDestination;
|
||||
RewardPoint: RewardPoint;
|
||||
@@ -2657,7 +2670,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
TombstoneContractInfo: TombstoneContractInfo;
|
||||
TraceBlockResponse: TraceBlockResponse;
|
||||
TraceError: TraceError;
|
||||
TransactionInfo: TransactionInfo;
|
||||
TransactionPriority: TransactionPriority;
|
||||
TransactionStorageProof: TransactionStorageProof;
|
||||
TransactionValidityError: TransactionValidityError;
|
||||
TransientValidationData: TransientValidationData;
|
||||
TreasuryProposal: TreasuryProposal;
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { CodecHash, Hash } from '../interfaces';
|
||||
import type { AnyJson, AnyNumber, Constructor, ICompact, InterfaceTypes, Registry } from '../types';
|
||||
import type { CompactEncodable } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
import { typeToConstructor } from './utils';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { alias, removeBounded, removeColons } from './sanitize';
|
||||
import { alias, flattenSingleTuple, removeColons, removeExtensions } from './sanitize';
|
||||
|
||||
describe('sanitize', (): void => {
|
||||
describe('alias', (): void => {
|
||||
@@ -60,14 +60,32 @@ describe('sanitize', (): void => {
|
||||
});
|
||||
|
||||
describe('bounded', (): void => {
|
||||
const fn = removeBounded();
|
||||
const fn = removeExtensions('Bounded', true);
|
||||
|
||||
it('correctly cleans up bounded values', (): void => {
|
||||
expect(fn('BoundedVec<u32, 256>')).toEqual('Vec<u32>');
|
||||
});
|
||||
|
||||
it('correctly cleans up nested bounded values', (): void => {
|
||||
expect(fn('BoundedBTreeMap<BoundedVec<BoundedVec<u32, 1>, 2>, BoundedBTreeSet<u32, BoundedVec<u64, 3>, 4>, 5>')).toEqual('BTreeMap<Vec<Vec<u32>>, BTreeSet<u32, Vec<u64>>>');
|
||||
expect(
|
||||
fn('BoundedBTreeMap<BoundedVec<BoundedVec<u32, 1>, 2>, BoundedBTreeSet<u32, BoundedVec<u64, 3>, 4>, 5>')
|
||||
).toEqual('BTreeMap<Vec<Vec<u32>>,BTreeSet<u32,Vec<u64>>>');
|
||||
});
|
||||
|
||||
it('cleans up values with trailing commas', (): void => {
|
||||
expect(
|
||||
flattenSingleTuple()(
|
||||
fn('(BoundedVec<Announcement<T::AccountId, CallHashOf<T>, T::BlockNumber>, T::MaxPending,>,BalanceOf<T>,)')
|
||||
)
|
||||
).toEqual('(Vec<Announcement<T::AccountId,CallHashOf<T>,T::BlockNumber>>,BalanceOf<T>)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('weak', (): void => {
|
||||
const fn = removeExtensions('Weak', false);
|
||||
|
||||
it('correctly cleans up weak values', (): void => {
|
||||
expect(fn('WeakVec<u32>')).toEqual('Vec<u32>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,9 @@ const mappings: Mapper[] = [
|
||||
// <T::Balance as HasCompact>
|
||||
cleanupCompact(),
|
||||
// Change BoundedVec<Type, Size> to Vec<Type>
|
||||
removeBounded(),
|
||||
removeExtensions('Bounded', true),
|
||||
// Change WeakVec<Type> to Vec<Type>
|
||||
removeExtensions('Weak', false),
|
||||
// Remove all the trait prefixes
|
||||
removeTraits(),
|
||||
// remove PairOf<T> -> (T, T)
|
||||
@@ -94,7 +96,11 @@ export function cleanupCompact (): Mapper {
|
||||
|
||||
export function flattenSingleTuple (): Mapper {
|
||||
return (value: string) =>
|
||||
value.replace(/\(([^,]+)\)/, '$1');
|
||||
value
|
||||
// tuples may have trailing commas, e.g. (u32, BlockNumber, )
|
||||
.replace(/,\)/g, ')')
|
||||
// change (u32) -> u32
|
||||
.replace(/\(([^,]+)\)/, '$1');
|
||||
}
|
||||
|
||||
function replaceTagWith (value: string, matcher: string, replacer: (inner: string) => string): string {
|
||||
@@ -114,14 +120,21 @@ function replaceTagWith (value: string, matcher: string, replacer: (inner: strin
|
||||
}
|
||||
}
|
||||
|
||||
// remove the Bounded* wrappers
|
||||
export function removeBounded (): Mapper {
|
||||
// remove the Bounded* or Weak* wrappers
|
||||
export function removeExtensions (type: string, isSized: boolean): Mapper {
|
||||
return (value: string) =>
|
||||
BOUNDED.reduce((value, tag) =>
|
||||
replaceTagWith(value, `Bounded${tag}<`, (inner: string): string => {
|
||||
const parts = inner.split(',');
|
||||
replaceTagWith(value, `${type}${tag}<`, (inner: string): string => {
|
||||
const parts = inner
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => s);
|
||||
|
||||
return `${tag}<${parts.filter((_, i) => i !== parts.length - 1).join(',')}>`;
|
||||
if (isSized) {
|
||||
parts.pop();
|
||||
}
|
||||
|
||||
return `${tag}<${parts.join(',')}>`;
|
||||
}), value
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { isBigInt, isBn, isHex, isNumber, isU8a, u8aConcat, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { AnyU8a, IExtrinsicEra, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { assert, bnToBn, formatNumber, hexToU8a, isHex, isObject, isU8a, u8aToBn, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Enum } from '../codec/Enum';
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import type { Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
|
||||
import { isBigInt, isBn, isHex, isNumber, isU8a, u8aConcat, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
|
||||
@@ -32,6 +32,11 @@ export default {
|
||||
Reasons: {
|
||||
_enum: ['Fee', 'Misc', 'All']
|
||||
},
|
||||
ReserveData: {
|
||||
id: 'ReserveIdentifier',
|
||||
amount: 'Balance'
|
||||
},
|
||||
ReserveIdentifier: '[u8; 8]',
|
||||
VestingSchedule: {
|
||||
offset: 'Balance',
|
||||
perBlock: 'Balance',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Enum, Set, Struct } from '@polkadot/types';
|
||||
import type { Enum, Set, Struct, U8aFixed } from '@polkadot/types';
|
||||
import type { Balance, BlockNumber, LockIdentifier } from '@polkadot/types/interfaces/runtime';
|
||||
|
||||
/** @name AccountData */
|
||||
@@ -40,6 +40,15 @@ export interface Reasons extends Enum {
|
||||
readonly isAll: boolean;
|
||||
}
|
||||
|
||||
/** @name ReserveData */
|
||||
export interface ReserveData extends Struct {
|
||||
readonly id: ReserveIdentifier;
|
||||
readonly amount: Balance;
|
||||
}
|
||||
|
||||
/** @name ReserveIdentifier */
|
||||
export interface ReserveIdentifier extends U8aFixed {}
|
||||
|
||||
/** @name VestingSchedule */
|
||||
export interface VestingSchedule extends Struct {
|
||||
readonly offset: Balance;
|
||||
|
||||
@@ -25,8 +25,8 @@ export default {
|
||||
end: 'BlockNumber',
|
||||
cap: 'Balance',
|
||||
lastContribution: 'LastContribution',
|
||||
firstSlot: 'LeasePeriod',
|
||||
lastSlot: 'LeasePeriod',
|
||||
firstPeriod: 'LeasePeriod',
|
||||
lastPeriod: 'LeasePeriod',
|
||||
trieIndex: 'TrieIndex'
|
||||
},
|
||||
TrieIndex: 'u32'
|
||||
|
||||
@@ -17,8 +17,8 @@ export interface FundInfo extends Struct {
|
||||
readonly end: BlockNumber;
|
||||
readonly cap: Balance;
|
||||
readonly lastContribution: LastContribution;
|
||||
readonly firstSlot: LeasePeriod;
|
||||
readonly lastSlot: LeasePeriod;
|
||||
readonly firstPeriod: LeasePeriod;
|
||||
readonly lastPeriod: LeasePeriod;
|
||||
readonly trieIndex: TrieIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,15 +50,22 @@ export const rpc: DefinitionsRpc = {
|
||||
type: 'Vec<H160>'
|
||||
},
|
||||
blockNumber: {
|
||||
description: 'Returns balance of the given account.',
|
||||
description: 'Returns the blockNumber',
|
||||
params: [],
|
||||
type: 'U256'
|
||||
},
|
||||
call: {
|
||||
description: 'Call contract, returning the output data.',
|
||||
params: [
|
||||
{ name: 'request', type: 'EthCallRequest' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'request',
|
||||
type: 'EthCallRequest'
|
||||
},
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'Bytes'
|
||||
},
|
||||
@@ -75,8 +82,15 @@ export const rpc: DefinitionsRpc = {
|
||||
estimateGas: {
|
||||
description: 'Estimate gas needed for execution of given contract.',
|
||||
params: [
|
||||
{ name: 'request', type: 'EthCallRequest' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'request',
|
||||
type: 'EthCallRequest'
|
||||
},
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
@@ -88,23 +102,39 @@ export const rpc: DefinitionsRpc = {
|
||||
getBalance: {
|
||||
description: 'Returns balance of the given account.',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'address',
|
||||
type: 'H160'
|
||||
},
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getBlockByHash: {
|
||||
description: 'Returns block with given hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ name: 'full', type: 'bool' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
},
|
||||
{
|
||||
name: 'full',
|
||||
type: 'bool'
|
||||
}
|
||||
],
|
||||
type: 'Option<EthRichBlock>'
|
||||
},
|
||||
getBlockByNumber: {
|
||||
description: 'Returns block with given number.',
|
||||
params: [
|
||||
{ name: 'block', type: 'BlockNumber' },
|
||||
{
|
||||
name: 'block',
|
||||
type: 'BlockNumber'
|
||||
},
|
||||
{ name: 'full', type: 'bool' }
|
||||
],
|
||||
type: 'Option<EthRichBlock>'
|
||||
@@ -112,129 +142,213 @@ export const rpc: DefinitionsRpc = {
|
||||
getBlockTransactionCountByHash: {
|
||||
description: 'Returns the number of transactions in a block with given hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getBlockTransactionCountByNumber: {
|
||||
description: 'Returns the number of transactions in a block with given block number.',
|
||||
params: [
|
||||
{ name: 'block', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'block',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getCode: {
|
||||
description: 'Returns the code at given address at given time (block number).',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'address',
|
||||
type: 'H160'
|
||||
},
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'Bytes'
|
||||
},
|
||||
getFilterChanges: {
|
||||
description: 'Returns filter changes since last poll.',
|
||||
params: [
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'EthFilterChanges'
|
||||
},
|
||||
getFilterLogs: {
|
||||
description: 'Returns all logs matching given filter (in a range \'from\' - \'to\').',
|
||||
params: [
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'Vec<EthLog>'
|
||||
},
|
||||
getLogs: {
|
||||
description: 'Returns logs matching given filter object.',
|
||||
params: [
|
||||
{ name: 'filter', type: 'EthFilter' }
|
||||
{
|
||||
name: 'filter',
|
||||
type: 'EthFilter'
|
||||
}
|
||||
],
|
||||
type: 'Vec<EthLog>'
|
||||
},
|
||||
getProof: {
|
||||
description: 'Returns proof for account and storage.',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ name: 'storageKeys', type: 'Vec<H256>' },
|
||||
{ name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'address',
|
||||
type: 'H160'
|
||||
},
|
||||
{
|
||||
name: 'storageKeys',
|
||||
type: 'Vec<H256>'
|
||||
},
|
||||
{
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'EthAccount'
|
||||
},
|
||||
getStorageAt: {
|
||||
description: 'Returns content of the storage at given address.',
|
||||
params: [
|
||||
{ name: 'address', type: 'H160' },
|
||||
{ name: 'index', type: 'U256' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'address',
|
||||
type: 'H160'
|
||||
},
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
},
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'H256'
|
||||
},
|
||||
getTransactionByBlockHashAndIndex: {
|
||||
description: 'Returns transaction at given block hash and index.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
},
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'EthTransaction'
|
||||
},
|
||||
getTransactionByBlockNumberAndIndex: {
|
||||
description: 'Returns transaction by given block number and index.',
|
||||
params: [
|
||||
{ name: 'number', type: 'BlockNumber' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
},
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'EthTransaction'
|
||||
},
|
||||
getTransactionByHash: {
|
||||
description: 'Get transaction by its hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
}
|
||||
],
|
||||
type: 'EthTransaction'
|
||||
},
|
||||
getTransactionCount: {
|
||||
description: 'Returns the number of transactions sent from given address at given time (block number).',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ isOptional: true, name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
},
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getTransactionReceipt: {
|
||||
description: 'Returns transaction receipt by transaction hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
}
|
||||
],
|
||||
type: 'EthReceipt'
|
||||
},
|
||||
getUncleByBlockHashAndIndex: {
|
||||
description: 'Returns an uncles at given block and index.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
},
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'EthRichBlock'
|
||||
},
|
||||
getUncleByBlockNumberAndIndex: {
|
||||
description: 'Returns an uncles at given block and index.',
|
||||
params: [
|
||||
{ name: 'number', type: 'BlockNumber' },
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
},
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'EthRichBlock'
|
||||
},
|
||||
getUncleCountByBlockHash: {
|
||||
description: 'Returns the number of uncles in a block with given hash.',
|
||||
params: [
|
||||
{ name: 'hash', type: 'H256' }
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
getUncleCountByBlockNumber: {
|
||||
description: 'Returns the number of uncles in a block with given block number.',
|
||||
params: [
|
||||
{ name: 'number', type: 'BlockNumber' }
|
||||
{
|
||||
name: 'number',
|
||||
type: 'BlockNumber'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
@@ -261,7 +375,10 @@ export const rpc: DefinitionsRpc = {
|
||||
newFilter: {
|
||||
description: 'Returns id of new filter.',
|
||||
params: [
|
||||
{ name: 'filter', type: 'EthFilter' }
|
||||
{
|
||||
name: 'filter',
|
||||
type: 'EthFilter'
|
||||
}
|
||||
],
|
||||
type: 'U256'
|
||||
},
|
||||
@@ -278,31 +395,52 @@ export const rpc: DefinitionsRpc = {
|
||||
sendRawTransaction: {
|
||||
description: 'Sends signed transaction, returning its hash.',
|
||||
params: [
|
||||
{ name: 'bytes', type: 'Bytes' }
|
||||
{
|
||||
name: 'bytes',
|
||||
type: 'Bytes'
|
||||
}
|
||||
],
|
||||
type: 'H256'
|
||||
},
|
||||
sendTransaction: {
|
||||
description: 'Sends transaction; will block waiting for signer to return the transaction hash',
|
||||
params: [
|
||||
{ name: 'tx', type: 'EthTransactionRequest' }
|
||||
{
|
||||
name: 'tx',
|
||||
type: 'EthTransactionRequest'
|
||||
}
|
||||
],
|
||||
type: 'H256'
|
||||
},
|
||||
submitHashrate: {
|
||||
description: 'Used for submitting mining hashrate.',
|
||||
params: [
|
||||
{ name: 'index', type: 'U256' },
|
||||
{ name: 'hash', type: 'H256' }
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
},
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'H256'
|
||||
}
|
||||
],
|
||||
type: 'bool'
|
||||
},
|
||||
submitWork: {
|
||||
description: 'Used for submitting a proof-of-work solution.',
|
||||
params: [
|
||||
{ name: 'nonce', type: 'H64' },
|
||||
{ name: 'headerHash', type: 'H256' },
|
||||
{ name: 'mixDigest', type: 'H256' }
|
||||
{
|
||||
name: 'nonce',
|
||||
type: 'H64'
|
||||
},
|
||||
{
|
||||
name: 'headerHash',
|
||||
type: 'H256'
|
||||
},
|
||||
{
|
||||
name: 'mixDigest',
|
||||
type: 'H256'
|
||||
}
|
||||
],
|
||||
type: 'bool'
|
||||
},
|
||||
@@ -310,7 +448,11 @@ export const rpc: DefinitionsRpc = {
|
||||
description: 'Subscribe to Eth subscription.',
|
||||
params: [
|
||||
{ name: 'kind', type: 'EthSubKind' },
|
||||
{ isOptional: true, name: 'params', type: 'EthSubParams' }
|
||||
{
|
||||
isOptional: true,
|
||||
name: 'params',
|
||||
type: 'EthSubParams'
|
||||
}
|
||||
],
|
||||
pubsub: [
|
||||
'subscription',
|
||||
@@ -327,7 +469,10 @@ export const rpc: DefinitionsRpc = {
|
||||
uninstallFilter: {
|
||||
description: 'Uninstalls filter.',
|
||||
params: [
|
||||
{ name: 'index', type: 'U256' }
|
||||
{
|
||||
name: 'index',
|
||||
type: 'U256'
|
||||
}
|
||||
],
|
||||
type: 'bool'
|
||||
}
|
||||
|
||||
@@ -114,6 +114,10 @@ export default {
|
||||
validationCodeHash: 'Hash'
|
||||
},
|
||||
CandidateHash: 'Hash',
|
||||
CandidateInfo: {
|
||||
who: 'AccountId',
|
||||
deposit: 'Balance'
|
||||
},
|
||||
CandidatePendingAvailability: {
|
||||
core: 'CoreIndex',
|
||||
hash: 'CandidateHash',
|
||||
|
||||
@@ -123,6 +123,12 @@ export interface CandidateDescriptor extends Struct {
|
||||
/** @name CandidateHash */
|
||||
export interface CandidateHash extends Hash {}
|
||||
|
||||
/** @name CandidateInfo */
|
||||
export interface CandidateInfo extends Struct {
|
||||
readonly who: AccountId;
|
||||
readonly deposit: Balance;
|
||||
}
|
||||
|
||||
/** @name CandidatePendingAvailability */
|
||||
export interface CandidatePendingAvailability extends Struct {
|
||||
readonly core: CoreIndex;
|
||||
|
||||
@@ -151,6 +151,19 @@ export default {
|
||||
trieNodes: 'Vec<Bytes>'
|
||||
},
|
||||
TransactionPriority: 'u64',
|
||||
TransactionInfo: {
|
||||
_alias: {
|
||||
dataSize: 'size'
|
||||
},
|
||||
chunkRoot: 'H256',
|
||||
contentHash: 'H256',
|
||||
dataSize: 'u32',
|
||||
blockChunks: 'u32'
|
||||
},
|
||||
TransactionStorageProof: {
|
||||
chunk: 'Vec<u8>',
|
||||
proof: 'Vec<Vec<u8>>'
|
||||
},
|
||||
ValidatorId: 'AccountId',
|
||||
ValidatorIdOf: 'ValidatorId',
|
||||
Weight: 'u64',
|
||||
|
||||
@@ -314,9 +314,23 @@ export interface StorageProof extends Struct {
|
||||
readonly trieNodes: Vec<Bytes>;
|
||||
}
|
||||
|
||||
/** @name TransactionInfo */
|
||||
export interface TransactionInfo extends Struct {
|
||||
readonly chunkRoot: H256;
|
||||
readonly contentHash: H256;
|
||||
readonly dataSize: u32;
|
||||
readonly blockChunks: u32;
|
||||
}
|
||||
|
||||
/** @name TransactionPriority */
|
||||
export interface TransactionPriority extends u64 {}
|
||||
|
||||
/** @name TransactionStorageProof */
|
||||
export interface TransactionStorageProof extends Struct {
|
||||
readonly chunk: Bytes;
|
||||
readonly proof: Vec<Bytes>;
|
||||
}
|
||||
|
||||
/** @name U32F32 */
|
||||
export interface U32F32 extends UInt {}
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types', version: '4.11.1' };
|
||||
export const packageInfo = { name: '@polkadot/types', version: '4.13.1' };
|
||||
|
||||
@@ -24,4 +24,20 @@ describe('Data', (): void => {
|
||||
new Data(registry, { Raw: '0x0102030405060708' }).toHex()
|
||||
).toEqual('0x090102030405060708');
|
||||
});
|
||||
|
||||
it('throws on a very long string (only 32 bytes)', (): void => {
|
||||
expect(
|
||||
() => new Data(registry, { Raw: 'this is some very long string that is added here that will fail' })
|
||||
).toThrow('Data.Raw values are limited to a maximum length of 32 bytes');
|
||||
});
|
||||
|
||||
it('encodes a large value correctly (max 32)', (): void => {
|
||||
expect(
|
||||
// without the assert (and above test), add extra bytes to the end to check the encoding
|
||||
new Data(registry, { Raw: '0x0102030405060708091011121314151617181920212223242526272829303132' }).toHex()
|
||||
).toEqual(
|
||||
// first byte is 32 + 1 === 33 === 0x21
|
||||
'0x210102030405060708091011121314151617181920212223242526272829303132'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { H256 } from '../interfaces/runtime';
|
||||
import type { Registry } from '../types';
|
||||
|
||||
import { isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import { assert, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { Enum } from '../codec/Enum';
|
||||
import { Bytes } from './Bytes';
|
||||
@@ -57,6 +57,8 @@ export class Data extends Enum {
|
||||
Keccak256: 'H256', // 4
|
||||
ShaThree256: 'H256' // 5
|
||||
}, ...decodeData(registry, value));
|
||||
|
||||
assert(!this.isRaw || this.asRaw.length <= 32, 'Data.Raw values are limited to a maximum length of 32 bytes');
|
||||
}
|
||||
|
||||
get asBlakeTwo256 (): H256 {
|
||||
@@ -122,7 +124,7 @@ export class Data extends Enum {
|
||||
const length = Math.min(data.length, 32);
|
||||
const u8a = new Uint8Array(length + 1);
|
||||
|
||||
u8a.set([data.length + 1], 0);
|
||||
u8a.set([length + 1], 0);
|
||||
u8a.set(data.subarray(0, length), 1);
|
||||
|
||||
return u8a;
|
||||
|
||||
@@ -32,30 +32,23 @@ const HASHER_MAP: Record<keyof typeof AllHashers, [number, boolean]> = {
|
||||
Twox64Concat: [8, true]
|
||||
};
|
||||
|
||||
function getStorageType (type: StorageEntryTypeLatest): [boolean, string] {
|
||||
if (type.isMap) {
|
||||
return [false, type.asMap.value.toString()];
|
||||
} else if (type.isDoubleMap) {
|
||||
return [false, type.asDoubleMap.value.toString()];
|
||||
} else if (type.isNMap) {
|
||||
return [false, type.asNMap.value.toString()];
|
||||
}
|
||||
|
||||
return [false, type.asPlain.toString()];
|
||||
}
|
||||
|
||||
// we unwrap the type here, turning into an output usable for createType
|
||||
/** @internal */
|
||||
export function unwrapStorageType (type: StorageEntryTypeLatest, isOptional?: boolean): keyof InterfaceTypes {
|
||||
const [hasWrapper, outputType] = getStorageType(type);
|
||||
const outputType = type.isPlain
|
||||
? type.asPlain.toString()
|
||||
: type.isMap
|
||||
? type.asMap.value.toString()
|
||||
: type.isDoubleMap
|
||||
? type.asDoubleMap.value.toString()
|
||||
: type.asNMap.value.toString();
|
||||
|
||||
return isOptional && !hasWrapper
|
||||
return isOptional
|
||||
? `Option<${outputType}>` as keyof InterfaceTypes
|
||||
: outputType as keyof InterfaceTypes;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeStorageKey (value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, any]): Decoded {
|
||||
function decodeStorageKey (value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, unknown]): Decoded {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
if (value instanceof StorageKey) {
|
||||
return {
|
||||
@@ -73,12 +66,12 @@ function decodeStorageKey (value?: AnyU8a | StorageKey | StorageEntry | [Storage
|
||||
section: value.section
|
||||
};
|
||||
} else if (Array.isArray(value)) {
|
||||
const [fn, ...arg] = value as [StorageEntry, ...any[]];
|
||||
const [fn, arg] = value;
|
||||
|
||||
assert(isFunction(fn), 'Expected function input for key construction');
|
||||
|
||||
return {
|
||||
key: fn(...arg),
|
||||
key: fn(arg),
|
||||
method: fn.method,
|
||||
section: fn.section
|
||||
};
|
||||
@@ -134,7 +127,7 @@ function decodeArgsFromMeta <A extends AnyTuple> (registry: Registry, value: Uin
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function getMeta (value: StorageKey | StorageEntry | [StorageEntry, any]): StorageEntryMetadataLatest | undefined {
|
||||
function getMeta (value: StorageKey | StorageEntry | [StorageEntry, unknown]): StorageEntryMetadataLatest | undefined {
|
||||
if (value instanceof StorageKey) {
|
||||
return value.meta;
|
||||
} else if (isFunction(value)) {
|
||||
@@ -149,7 +142,7 @@ function getMeta (value: StorageKey | StorageEntry | [StorageEntry, any]): Stora
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function getType (value: StorageKey | StorageEntry | [StorageEntry, any]): string {
|
||||
function getType (value: StorageKey | StorageEntry | [StorageEntry, unknown]): string {
|
||||
if (value instanceof StorageKey) {
|
||||
return value.outputType;
|
||||
} else if (isFunction(value)) {
|
||||
@@ -185,7 +178,7 @@ export class StorageKey<A extends AnyTuple = AnyTuple> extends Bytes implements
|
||||
|
||||
private _section?: string;
|
||||
|
||||
constructor (registry: Registry, value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, any], override: Partial<StorageKeyExtra> = {}) {
|
||||
constructor (registry: Registry, value?: AnyU8a | StorageKey | StorageEntry | [StorageEntry, unknown], override: Partial<StorageKeyExtra> = {}) {
|
||||
const { key, method, section } = decodeStorageKey(value);
|
||||
|
||||
super(registry, key);
|
||||
|
||||
Reference in New Issue
Block a user