Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3a57e14bc | ||
|
|
cc926596e5 | ||
|
|
5193e9c6d5 | ||
|
|
d3703c072b | ||
|
|
4dbcf310f3 | ||
|
|
f778bf32e5 | ||
|
|
7027e9f982 | ||
|
|
d13e58fb32 | ||
|
|
8f8e6d542f | ||
|
|
95c4f03bc3 | ||
|
|
45bba3a897 | ||
|
|
d202287889 | ||
|
|
0c338dfbce | ||
|
|
33c161f874 | ||
|
|
34d951d63e | ||
|
|
27c58b930b | ||
|
|
6d2f2affe8 | ||
|
|
e055438c59 | ||
|
|
19bf1a1b59 | ||
|
|
5577723b73 | ||
|
|
ba5f9d1d01 | ||
|
|
9d548f787f |
+52
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -7,5 +7,9 @@ nodeLinker: node-modules
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.2.2.cjs
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 2.1.1 Oct 5, 2020
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Remove unused documentation link (Thanks to https://github.com/roccomuso)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust RPC error formatting with string cleanups and a larger allowed range
|
||||
- Apply limit protection on `Text` & `Bytes`, protecting against OOM on erroneous decoding
|
||||
- Add `derive.staking.validatorsFrom` to determine validators nominated and own validators
|
||||
- Cleanup document generation without (currently unused) summary links
|
||||
- Rename static TRANSACTION_VERSION to EXTRINSIC_VERSION (Substrate alignment)
|
||||
- Bump Substrate metadata (tests, doc generation)
|
||||
|
||||
|
||||
## 2.0.1 Sep 28, 2020
|
||||
|
||||
Upgrade priority: Medium. Required for all teams building on Substrate 2.0 for full compatibility.
|
||||
|
||||
@@ -27,7 +27,6 @@ The API is split up into a number of internal packages -
|
||||
|
||||
Type definitions for interfaces as exposed by Polkadot & Substrate clients -
|
||||
|
||||
- [@polkadot/jsonrpc](packages/jsonrpc/) Definitions for JSONRPC endpoints
|
||||
- [@polkadot/types](packages/types/) Codecs for all Polkadot and Substrate primitives
|
||||
|
||||
## development
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"command": {
|
||||
"publish": {
|
||||
"allowBranch": "master"
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "2.0.1"
|
||||
}
|
||||
+6
-6
@@ -28,15 +28,15 @@
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/dev": "^0.55.54",
|
||||
"@polkadot/ts": "^0.3.47",
|
||||
"@polkadot/dev": "^0.57.8",
|
||||
"@polkadot/ts": "^0.3.49",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.14",
|
||||
"@vuepress/plugin-search": "^1.5.4",
|
||||
"copyfiles": "^2.3.0",
|
||||
"@vuepress/plugin-search": "^1.6.0",
|
||||
"copyfiles": "^2.4.0",
|
||||
"typedoc": "^0.19.2",
|
||||
"typedoc-plugin-markdown": "^3.0.2",
|
||||
"typedoc-plugin-markdown": "^3.0.7",
|
||||
"typedoc-plugin-no-inherit": "^1.2.0"
|
||||
},
|
||||
"version": "2.0.1"
|
||||
"version": "2.1.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,9 +27,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "2.0.1",
|
||||
"@polkadot/rpc-core": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/api": "2.1.1",
|
||||
"@polkadot/rpc-core": "2.1.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.3"
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# @polkadot/api-derive
|
||||
|
||||
Common functions used across Polkadot, derived from RPC calls and storage queries.
|
||||
|
||||
## Classes
|
||||
|
||||
[Classes](SUMMARY.md)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -28,10 +28,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "2.0.1",
|
||||
"@polkadot/rpc-core": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/api": "2.1.1",
|
||||
"@polkadot/rpc-core": "2.1.1",
|
||||
"@polkadot/rpc-provider": "2.1.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
|
||||
@@ -22,4 +22,5 @@ export * from './stakerRewards';
|
||||
export * from './stakerSlashes';
|
||||
export * from './stashes';
|
||||
export * from './validators';
|
||||
export * from './validatorsFrom';
|
||||
export * from './waitingInfo';
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { AccountId, Nominations } from '@polkadot/types/interfaces';
|
||||
import { DeriveStakingQuery } from '../types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { switchMap } from 'rxjs/operators';
|
||||
import { Option } from '@polkadot/types';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
* @description From a list of stashIds, staking ledgers for those acting as validators and those being nominated
|
||||
*/
|
||||
export function validatorsFrom (instanceId: string, api: ApiInterfaceRx): (stashIds: (Uint8Array | string)[]) => Observable<DeriveStakingQuery[]> {
|
||||
return memo(instanceId, (stashIds: (Uint8Array | string)[]): Observable<DeriveStakingQuery[]> =>
|
||||
api.query.staking.nominators.multi<Option<Nominations>>(stashIds).pipe(
|
||||
switchMap((optNoms) =>
|
||||
api.derive.staking.queryMulti(
|
||||
optNoms.reduce((validatorIds: AccountId[], optNom): AccountId[] => {
|
||||
return optNom.unwrapOrDefault().targets.reduce((validatorIds: AccountId[], targetId): AccountId[] => {
|
||||
if (!validatorIds.find((validatorId) => validatorId.eq(targetId))) {
|
||||
validatorIds.push(targetId);
|
||||
}
|
||||
|
||||
return validatorIds;
|
||||
}, validatorIds);
|
||||
}, [])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -98,6 +98,3 @@ Some of the users of the API (let us know if you are missing from the list), inc
|
||||
- [PolkaStats.io](https://polkastats.io), [PolkaStats frontend GitHub repository](https://github.com/Colm3na/polkastats-v2) and [PolkaStats backend GitHub repository](https://github.com/Colm3na/polkastats-backend-v2) Polkadot network statistics (currently Kusama and Alexander). Shows network information and staking details from validators and intentions.
|
||||
- [Polkadot API Server (GitHub)](https://github.com/SimplyVC/polkadot_api_server) A lightweight server for querying Polkadot nodes from any language, built primarily as a backend for [PANIC for Polkadot (GitHub)](https://github.com/SimplyVC/panic_polkadot/), a validator monitoring and alerting tool.
|
||||
- [Identity Registrar #1 from Chevdor on Westend, Kusama and Polkadot](https://www.chevdor.com/tags/registrar/)
|
||||
## Classes
|
||||
|
||||
[Classes](SUMMARY.md)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,13 +27,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api-derive": "2.0.1",
|
||||
"@polkadot/api-derive": "2.1.1",
|
||||
"@polkadot/keyring": "^3.5.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/rpc-core": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/types-known": "2.0.1",
|
||||
"@polkadot/metadata": "2.1.1",
|
||||
"@polkadot/rpc-core": "2.1.1",
|
||||
"@polkadot/rpc-provider": "2.1.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/types-known": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"bn.js": "^5.1.3",
|
||||
|
||||
@@ -1385,6 +1385,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Parameters:
|
||||
* - `proxy`: The account that the `caller` would like to make a proxy.
|
||||
* - `proxy_type`: The permissions allowed for this proxy account.
|
||||
* - `delay`: The announcement period required of the initial proxy. Will generally be
|
||||
* zero.
|
||||
*
|
||||
* # <weight>
|
||||
* Weight is a function of the number of proxies the user has (P).
|
||||
@@ -2584,7 +2586,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* transaction in the block.
|
||||
*
|
||||
* # <weight>
|
||||
* See `crate::weight` module.
|
||||
* See [`submit_election_solution`].
|
||||
* # </weight>
|
||||
**/
|
||||
submitElectionSolutionUnsigned: AugmentedSubmittable<(winners: Vec<ValidatorIndex> | (ValidatorIndex | AnyNumber | Uint8Array)[], compact: CompactAssignments | { votes1?: any; votes2?: any; votes3?: any; votes4?: any; votes5?: any; votes6?: any; votes7?: any; votes8?: any; votes9?: any; votes10?: any; votes11?: any; votes12?: any; votes13?: any; votes14?: any; votes15?: any; votes16?: any } | string | Uint8Array, score: ElectionScore, era: EraIndex | AnyNumber | Uint8Array, size: ElectionSize | { validators?: any; nominators?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
|
||||
@@ -63,14 +63,12 @@ function decorateCall<Method extends DecorateFn<ObsInnerType<ReturnType<Method>>
|
||||
// single result tracker - either reject with Error or resolve with Codec result
|
||||
const tracker = promiseTracker(resolve, reject);
|
||||
|
||||
// errors reject immediately, any result unsubscribes and resolves
|
||||
// encoding errors reject immediately, any result unsubscribes and resolves
|
||||
const subscription: Subscription = method(...actualArgs).pipe(
|
||||
catchError((error) => tracker.reject(error))
|
||||
).subscribe((result): void => {
|
||||
tracker.resolve(result);
|
||||
typeof setImmediate === 'undefined'
|
||||
? setTimeout(() => subscription.unsubscribe(), 0)
|
||||
: setImmediate(() => subscription.unsubscribe());
|
||||
setTimeout(() => subscription.unsubscribe(), 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -86,11 +84,8 @@ function decorateSubscribe<Method extends DecorateFn<ObsInnerType<ReturnType<Met
|
||||
catchError((error) => tracker.reject(error)),
|
||||
tap(() => tracker.resolve(() => subscription.unsubscribe()))
|
||||
).subscribe((result): void => {
|
||||
// We use setImmediate here to ensure that the Promise above (tracker) has resolved, before returning
|
||||
// the first result. By putting is back in the queue, the promise above is guarded for first execution
|
||||
typeof setImmediate === 'undefined'
|
||||
? setTimeout(() => resultCb(result) as void, 0)
|
||||
: setImmediate(() => resultCb(result) as void);
|
||||
// queue result (back of queue to clear current)
|
||||
setTimeout(() => resultCb(result) as void, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -27,8 +27,8 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/types-known": "2.0.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/types-known": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"bn.js": "^5.1.3"
|
||||
|
||||
@@ -2903,7 +2903,7 @@
|
||||
" transaction in the block.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" See `crate::weight` module.",
|
||||
" See [`submit_election_solution`].",
|
||||
" # </weight>"
|
||||
]
|
||||
}
|
||||
@@ -3070,7 +3070,7 @@
|
||||
{
|
||||
"name": "MaxNominatorRewardedPerValidator",
|
||||
"type": "u32",
|
||||
"value": "0x40000000",
|
||||
"value": "0x00010000",
|
||||
"documentation": [
|
||||
" The maximum number of nominators rewarded for each validator.",
|
||||
"",
|
||||
@@ -11256,6 +11256,8 @@
|
||||
" Parameters:",
|
||||
" - `proxy`: The account that the `caller` would like to make a proxy.",
|
||||
" - `proxy_type`: The permissions allowed for this proxy account.",
|
||||
" - `delay`: The announcement period required of the initial proxy. Will generally be",
|
||||
" zero.",
|
||||
"",
|
||||
" # <weight>",
|
||||
" Weight is a function of the number of proxies the user has (P).",
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -10,7 +10,7 @@ Installation -
|
||||
yarn add @polkadot/rpc-core
|
||||
```
|
||||
|
||||
Initialisation -
|
||||
Initialization -
|
||||
|
||||
```js
|
||||
import Rpc from '@polkadot/rpc-core';
|
||||
@@ -70,7 +70,3 @@ rpc
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
## Classes
|
||||
|
||||
[Classes](SUMMARY.md)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,9 +27,9 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/metadata": "2.1.1",
|
||||
"@polkadot/rpc-provider": "2.1.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.6.3"
|
||||
|
||||
@@ -16,7 +16,7 @@ Installation -
|
||||
yarn add @polkadot/rpc-provider
|
||||
```
|
||||
|
||||
WebSocket Initialisation -
|
||||
WebSocket Initialization -
|
||||
|
||||
```javascript
|
||||
import WsProvider from '@polkadot/rpc-provider/ws';
|
||||
@@ -28,7 +28,7 @@ const version = await provider.send('client_version', []);
|
||||
console.log('client version', version);
|
||||
```
|
||||
|
||||
HTTP Initialisation -
|
||||
HTTP Initialization -
|
||||
|
||||
```javascript
|
||||
import { HttpProvider } from '@polkadot/rpc-provider';
|
||||
@@ -39,7 +39,3 @@ const version = await provider.send('chain_getBlockHash', []);
|
||||
|
||||
console.log('latest block Hash', hash);
|
||||
```
|
||||
|
||||
## Classes
|
||||
|
||||
[Classes](SUMMARY.md)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,8 +27,8 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/metadata": "2.1.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"@polkadot/x-fetch": "^0.3.2",
|
||||
|
||||
@@ -10,13 +10,15 @@ function formatErrorData (data?: string | number): string {
|
||||
return '';
|
||||
}
|
||||
|
||||
const formatted = isString(data)
|
||||
? data.replace('Error("', '').replace('")', '')
|
||||
: JSON.stringify(data);
|
||||
const formatted = `: ${isString(data)
|
||||
? data.replace(/Error\("/g, '').replace(/\("/g, '(').replace(/"\)/g, ')').replace(/\(/g, ', ').replace(/\)/g, '')
|
||||
: JSON.stringify(data)}`;
|
||||
|
||||
// We need some sort of cut-off here since these can be very large and
|
||||
// very nested, pick a number and trim the result display to it
|
||||
return `: ${formatted.substr(0, 100)}`;
|
||||
return formatted.length <= 256
|
||||
? formatted
|
||||
: `${formatted.substr(0, 255)}…`;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -36,10 +36,10 @@
|
||||
"@babel/core": "^7.11.6",
|
||||
"@babel/register": "^7.11.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "2.0.1",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/rpc-provider": "2.0.1",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/api": "2.1.1",
|
||||
"@polkadot/metadata": "2.1.1",
|
||||
"@polkadot/rpc-provider": "2.1.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"handlebars": "^4.7.6",
|
||||
"websocket": "^1.0.32",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,7 +27,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "2.0.1",
|
||||
"@polkadot/types": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "2.0.1",
|
||||
"version": "2.1.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,7 +27,7 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "2.0.1",
|
||||
"@polkadot/metadata": "2.1.1",
|
||||
"@polkadot/util": "^3.5.1",
|
||||
"@polkadot/util-crypto": "^3.5.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
|
||||
@@ -9,7 +9,7 @@ import Compact from './Compact';
|
||||
import { decodeU8a, typeToConstructor } from './utils';
|
||||
import AbstractArray from './AbstractArray';
|
||||
|
||||
const MAX_LENGTH = 32768;
|
||||
const MAX_LENGTH = 64 * 1024;
|
||||
|
||||
/**
|
||||
* @name Vec
|
||||
|
||||
@@ -32,7 +32,7 @@ const VERSIONS: (keyof InterfaceTypes)[] = [
|
||||
'ExtrinsicV4'
|
||||
];
|
||||
|
||||
export { TRANSACTION_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic';
|
||||
export { EXTRINSIC_VERSION as LATEST_EXTRINSIC_VERSION } from './v4/Extrinsic';
|
||||
|
||||
abstract class ExtrinsicBase extends Base<ExtrinsicVx | ExtrinsicUnknown> {
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,7 @@ import { isU8a } from '@polkadot/util';
|
||||
|
||||
import Struct from '../../codec/Struct';
|
||||
|
||||
export const TRANSACTION_VERSION = 4;
|
||||
export const EXTRINSIC_VERSION = 4;
|
||||
|
||||
export interface ExtrinsicValueV4 {
|
||||
method?: Call;
|
||||
@@ -76,7 +76,7 @@ export default class ExtrinsicV4 extends Struct implements IExtrinsicImpl {
|
||||
* @description The version for the signature
|
||||
*/
|
||||
public get version (): number {
|
||||
return TRANSACTION_VERSION;
|
||||
return EXTRINSIC_VERSION;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,9 @@ import { assert, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import Compact from '../codec/Compact';
|
||||
import Raw from '../codec/Raw';
|
||||
|
||||
// Bytes are used for things like on-chain code, so it has a healthy limit
|
||||
const MAX_LENGTH = 10 * 1024 * 1024;
|
||||
|
||||
/** @internal */
|
||||
function decodeBytesU8a (value: Uint8Array): Uint8Array {
|
||||
if (!value.length) {
|
||||
@@ -18,6 +21,7 @@ function decodeBytesU8a (value: Uint8Array): Uint8Array {
|
||||
const [offset, length] = Compact.decodeU8a(value);
|
||||
const total = offset + length.toNumber();
|
||||
|
||||
assert(length.lten(MAX_LENGTH), `Bytes length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
assert(total <= value.length, `Bytes: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
|
||||
return value.subarray(offset, total);
|
||||
|
||||
@@ -9,6 +9,8 @@ import { assert, hexToU8a, isHex, isString, stringToU8a, u8aToString, u8aToHex }
|
||||
import Compact from '../codec/Compact';
|
||||
import Raw from '../codec/Raw';
|
||||
|
||||
const MAX_LENGTH = 128 * 1024;
|
||||
|
||||
/** @internal */
|
||||
function decodeText (value: Text | string | AnyU8a | { toString: () => string }): string {
|
||||
if (isHex(value)) {
|
||||
@@ -27,6 +29,7 @@ function decodeText (value: Text | string | AnyU8a | { toString: () => string })
|
||||
const [offset, length] = Compact.decodeU8a(value);
|
||||
const total = offset + length.toNumber();
|
||||
|
||||
assert(length.lten(MAX_LENGTH), `Text length ${length.toString()} exceeds ${MAX_LENGTH}`);
|
||||
assert(total <= value.length, `Text: required length less than remainder, expected at least ${total}, found ${value.length}`);
|
||||
|
||||
return u8aToString(value.subarray(offset, total));
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// NOTE When adding any types here, we need to update the documentation links as
|
||||
// well - <root>/docs/SUMMARY.md as well as ../README.md
|
||||
|
||||
/**
|
||||
* @summary Type definitions that are used in the system
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user