Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4195833d6f | ||
|
|
8f4e62c278 | ||
|
|
2c294af116 | ||
|
|
0f1f3b88b2 | ||
|
|
56b7697dda | ||
|
|
86d7471c76 | ||
|
|
cb7400710b | ||
|
|
59796067e2 | ||
|
|
7920565b97 | ||
|
|
4f0069cac8 | ||
|
|
835070c44f | ||
|
|
5368733353 | ||
|
|
efda09f279 | ||
|
|
af48f19dfa | ||
|
|
a0dd50b3ba | ||
|
|
3e159891c0 | ||
|
|
4b36fa68a5 | ||
|
|
70c9cfa0f0 | ||
|
|
3ce67375e3 | ||
|
|
10d611ba17 | ||
|
|
00acff5956 | ||
|
|
9857abd061 | ||
|
|
e87c830990 | ||
|
|
71063c93d1 | ||
|
|
e037df89e3 | ||
|
|
564d63ce28 | ||
|
|
69db63b6f9 | ||
|
|
2bd81e9d05 | ||
|
|
d267895dd5 | ||
|
|
190e0fcdb1 | ||
|
|
5e83837c5b | ||
|
|
7f949874e6 | ||
|
|
b024d7f63c | ||
|
|
4bc76bb3e5 | ||
|
|
212b43dda2 | ||
|
|
0ba1b318a7 | ||
|
|
2e8e5a93ca | ||
|
|
6101f82000 | ||
|
|
662aef2033 | ||
|
|
0859c470be | ||
|
|
29fe22da43 | ||
|
|
7eef825b38 | ||
|
|
24808fb55d | ||
|
|
9c06ed7a1c | ||
|
|
9560259f55 | ||
|
|
6236838fc8 | ||
|
|
e14eddfee3 | ||
|
|
0927f9ba8c | ||
|
|
a8775fd69d | ||
|
|
363c502ae8 | ||
|
|
d6cc0c30b4 | ||
|
|
5e312973f3 | ||
|
|
17c6262a5e | ||
|
|
0932a9aa7b | ||
|
|
88b44befdf | ||
|
|
e4fb971bec | ||
|
|
5c7c406676 | ||
|
|
709e89b801 | ||
|
|
fd96255d05 | ||
|
|
c212db26b6 | ||
|
|
817aaccbb1 | ||
|
|
bfd5642d64 | ||
|
|
126871bd46 | ||
|
|
714234b7af | ||
|
|
a7a0965d73 | ||
|
|
9b1f9c214b | ||
|
|
ca17955d83 | ||
|
|
9b0d260b33 | ||
|
|
fed2913684 | ||
|
|
fc777377ef | ||
|
|
ce7968f870 | ||
|
|
07594a33b5 | ||
|
|
48620ea7a3 | ||
|
|
f86ace2680 | ||
|
|
0e22308954 | ||
|
|
ae21d13b23 | ||
|
|
b594158275 | ||
|
|
76da6a6af5 | ||
|
|
e1f510f5e9 | ||
|
|
db6c44615f | ||
|
|
4ce01fe16f | ||
|
|
c52576149a | ||
|
|
0b5e4fe1cc | ||
|
|
8404170240 | ||
|
|
2b6e66b906 | ||
|
|
b165c0fe8d | ||
|
|
c0751f1a67 | ||
|
|
2a95046fb2 | ||
|
|
e1828af4c4 | ||
|
|
a133fec533 | ||
|
|
c51f3d5d2a | ||
|
|
54bb965537 | ||
|
|
9ab662881f | ||
|
|
697781fb52 | ||
|
|
a60d80953b | ||
|
|
a7edf81279 | ||
|
|
3423fb1717 | ||
|
|
4ae4e4298c | ||
|
|
90a84baa52 | ||
|
|
a80df7d846 | ||
|
|
9961595634 | ||
|
|
e0ecaccb09 | ||
|
|
fd7c80bd8a | ||
|
|
44a81bc00c | ||
|
|
7d71726024 | ||
|
|
f603100b8b | ||
|
|
70ac38cfd2 | ||
|
|
0bf0d27a39 | ||
|
|
b51988193a | ||
|
|
fd31e5a6e5 | ||
|
|
074663cdb7 | ||
|
|
5f5be13c08 | ||
|
|
d60b1818d0 | ||
|
|
9c611e9414 | ||
|
|
da14679b65 | ||
|
|
c88bb99b19 | ||
|
|
fc174738ec | ||
|
|
b43f1a747d | ||
|
|
555b2fb5fe | ||
|
|
1e1ee6eb49 | ||
|
|
7c4c346389 | ||
|
|
beff353b4e | ||
|
|
3172cb55f8 | ||
|
|
ba74ad0be9 | ||
|
|
6ec7687f33 | ||
|
|
bd70b1e6ce | ||
|
|
8744b95c83 | ||
|
|
94e6d8455d | ||
|
|
70d19fcebb | ||
|
|
174ba867d7 | ||
|
|
36b217463a | ||
|
|
412c7525c0 | ||
|
|
172c6f655f | ||
|
|
1e3240c669 | ||
|
|
43e1bf2d4a | ||
|
|
839b2bc342 | ||
|
|
a281e0dc2d | ||
|
|
9a4893130d | ||
|
|
77c45cf4c0 | ||
|
|
ca0969b1eb | ||
|
|
1df8cf9857 | ||
|
|
b7f095bcbd | ||
|
|
6cc7242bdf | ||
|
|
48f91ae0da | ||
|
|
4a63026b14 | ||
|
|
a40ce72298 | ||
|
|
f302d8de69 | ||
|
|
fcaebbdbb2 | ||
|
|
9e7037af04 | ||
|
|
68efac60df | ||
|
|
d763f49e8b | ||
|
|
77ffd7c153 | ||
|
|
d1506154bd | ||
|
|
b1254685da | ||
|
|
81a2a2c688 | ||
|
|
1fed997080 | ||
|
|
6e620e3bb3 | ||
|
|
6e4c62ea99 | ||
|
|
8972d2ffe9 | ||
|
|
091d2d30e0 | ||
|
|
ae7ded1767 | ||
|
|
8aa3550354 | ||
|
|
196d3c5995 | ||
|
|
592407d691 | ||
|
|
1e3a1bb51c | ||
|
|
2ca23a85d0 | ||
|
|
1a04b4a72e | ||
|
|
6dfe7c4f56 | ||
|
|
3f9f7bd649 | ||
|
|
e02e1302b2 | ||
|
|
a64dec3487 | ||
|
|
3415fbd121 | ||
|
|
0be1d46be9 | ||
|
|
9309e9f3a1 | ||
|
|
6dd019343d |
@@ -24,3 +24,7 @@
|
||||
4.9.2
|
||||
4.11.2
|
||||
4.16.2
|
||||
|
||||
5.3.2
|
||||
5.5.2
|
||||
5.8.2
|
||||
Vendored
-591
File diff suppressed because one or more lines are too long
+631
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-3.0.0-rc.2.cjs
|
||||
yarnPath: .yarn/releases/yarn-3.0.1.cjs
|
||||
|
||||
+148
@@ -1,7 +1,155 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 5.8.2 Sep 6, 2021
|
||||
|
||||
Contributed:
|
||||
|
||||
- Correct Xcm V1 `MultiLocation` definitions (Thanks to https://github.com/apopiak)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust Kusama Xcm overrides
|
||||
|
||||
|
||||
## 5.8.1 Sep 6, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `Auction` to Kusama `ProxyType` definition
|
||||
- Adjust Xcm definitions with latest v1 & v2 types
|
||||
- Support for `scale-info` 1.0 `Range` mapping
|
||||
- Bump static metadata for latest Substrate, Polkadot & Kusama
|
||||
|
||||
|
||||
## 5.7.1 Aug 29, 2021
|
||||
|
||||
Upgrade priority: Low.
|
||||
|
||||
Changes:
|
||||
|
||||
- Optimize `Vec` construction (no re-create on new arrays)
|
||||
- Adjust output for enums in `toHuman`
|
||||
- Adjust aliases for new parachain module locations
|
||||
- Support for versioned xcm types (Polkadot master)
|
||||
- Add support for `Range` in `PortableRegistry` (used in Metadata 14)
|
||||
- Adjust balances derive for non-existent instances
|
||||
- Ensure Statemint (current) defaults to xcm v0
|
||||
- Add Kusama 9090 upgrade block
|
||||
|
||||
|
||||
## 5.6.1 Aug 23, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of Xcm, preparing for Kusama/Westend 9100
|
||||
|
||||
Contributed:
|
||||
|
||||
- Support 0...N-1 args on `keys/entries` (Thanks to https://github.com/hamidra)
|
||||
|
||||
Changes:
|
||||
|
||||
- Updated XCM types, `AssetId`, `MultiAssets`, `MultiAssetV1`, `AssetInstanceV1`, `XcmOrderV1`
|
||||
- Rename `Null` entry in `MultiLocation` to `Here` (Xcm V1)
|
||||
- Westend 9090 upgrade block
|
||||
- Bump static Substrate, Kusama & Polkadot metadata
|
||||
|
||||
|
||||
## 5.5.2 Aug 19, 2021
|
||||
|
||||
Upgrade priority: Medium. Contains fixes for parachain types, affecting historic block retrieval on Kusama.
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust `ValidDisputeStatementKind` enum to latest version
|
||||
- Only enable API health keepalive on connections supporting subscriptions
|
||||
|
||||
|
||||
## 5.5.1 Aug 15, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of TS (`createType` and `bigint` adjustments)
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add `Range` & `RangeInclusive` types (Thanks to https://github.com/c410-f3r)
|
||||
- Always use TS `bigint` type (Thanks to https://github.com/ntduan)
|
||||
|
||||
Changes:
|
||||
|
||||
- Loosen pedantic check not to fail on all-empty values
|
||||
- Extend `createType` auto-TS decoration for `BreeMap`, `BTreeSet`, `HashMap`, `Range`
|
||||
- Add Polkadot 9080 upgrade block
|
||||
|
||||
|
||||
## 5.4.1 Aug 9, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for potential users of NMap.
|
||||
|
||||
- **Important** The `ClassOf` alias for `createClass` has been removed, use `createClass` (with new generics) directly
|
||||
|
||||
Contributed:
|
||||
|
||||
- Enable `.keys()/.entries()` on NMap (Thanks to https://github.com/hamidra)
|
||||
|
||||
Changes:
|
||||
|
||||
- `createType<T = Codec>('...': K)` now returns `Codec` when `K` is not known
|
||||
- `createType` does basic TypeScript type matching on the input type
|
||||
- Handle `BitSequence` in `PortableRegistry`
|
||||
- Ensure API `isConnected` is set before connect/disconnect events are fired
|
||||
- Move all static test support files into `@polkadot/types-support`
|
||||
- Align static Metadata with latest Substrate, Polkadot & Kusama
|
||||
- Adjust v14 Metadata definitions to latest version
|
||||
|
||||
|
||||
## 5.3.2 Aug 3, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of bridges.
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add missing bridges types (Thanks to https://github.com/tomusdrw)
|
||||
|
||||
Changes:
|
||||
|
||||
- Align static metadata with latest Substrate
|
||||
|
||||
|
||||
## 5.3.1 Aug 2, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of `api.at(...)` interfaces
|
||||
|
||||
Changes:
|
||||
|
||||
- Check specName & specVersion for historic registries (caters for runtime renames)
|
||||
- Fix circular dependencies in codec utils
|
||||
- Fix `api.at(<blockHash>)` to decorate with the correct storage hash
|
||||
- Adjustments for upcoming metadata v14 in type creation & `PortableRegistry`
|
||||
- Add Kusama 9080 upgrade block
|
||||
- Add v13/v14 static metadata for Polkadot
|
||||
- Align static metadata with latest Substrate
|
||||
|
||||
|
||||
## 5.2.1 Jul 26, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of `BTreeMap` and `BTreeSet`
|
||||
|
||||
Contributed:
|
||||
|
||||
- Perform sorting on `BTree{Map, Set}`, aligning with Substrate (Thanks to https://github.com/Lezek123)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust RPC to use `registry.createType` with optionality (required for metadata v14)
|
||||
- Adjust alphabetical sorting for TS type generation
|
||||
- Adjustments for upcoming metadata v14 in type creation & `PortableRegistry`
|
||||
- Provide the capability to convert v13 Metadata to upcoming v14
|
||||
|
||||
|
||||
## 5.1.1 Jul 19, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of XCM with type fixes.
|
||||
|
||||
- **Breaking changes** With the support for v14 metadata parsing, the `documentation` fields on metadata was renamed to `docs` for consistency, aligning with the SCALE type generators.
|
||||
|
||||
Contributed:
|
||||
|
||||
+2
-14
@@ -12,21 +12,9 @@ module.exports = {
|
||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
|
||||
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
|
||||
'@polkadot/types-(known|support)(.*)$': '<rootDir>/packages/types-$1/src/$2',
|
||||
// eslint-disable-next-line sort-keys
|
||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||
},
|
||||
modulePathIgnorePatterns: [
|
||||
'<rootDir>/packages/api/build',
|
||||
'<rootDir>/packages/api-contract/build',
|
||||
'<rootDir>/packages/api-derive/build',
|
||||
'<rootDir>/packages/metadata/build',
|
||||
'<rootDir>/packages/rpc-core/build',
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/typegen/build',
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
],
|
||||
testTimeout: 30000,
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
||||
testTimeout: 30000
|
||||
};
|
||||
|
||||
+9
-8
@@ -8,7 +8,7 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"typescript": "^4.3.5"
|
||||
"typescript": "^4.4.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
@@ -26,14 +26,15 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.6",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/dev": "^0.62.57",
|
||||
"@polkadot/ts": "^0.4.4",
|
||||
"@babel/core": "^7.15.5",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/dev": "^0.62.66",
|
||||
"@polkadot/ts": "^0.4.7",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/jest": "^27.0.1",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "5.1.1"
|
||||
"version": "5.8.2",
|
||||
"packageManager": "yarn@3.0.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
@@ -19,10 +19,10 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api": "5.1.1",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/api": "5.8.2",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1",
|
||||
"rxjs": "^7.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { AnyJson, Codec } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
||||
|
||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
@@ -154,7 +154,7 @@ export class Abi {
|
||||
index,
|
||||
method: stringCamelCase(identifier),
|
||||
selector: spec.selector,
|
||||
toU8a: (params: CodecArg[]) =>
|
||||
toU8a: (params: unknown[]) =>
|
||||
this.#encodeArgs(spec, args, params)
|
||||
};
|
||||
|
||||
@@ -185,7 +185,7 @@ export class Abi {
|
||||
return message.fromU8a(trimmed.subarray(4));
|
||||
}
|
||||
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): Uint8Array => {
|
||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: unknown[]): Uint8Array => {
|
||||
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
||||
|
||||
return compactAddLength(
|
||||
|
||||
@@ -4,27 +4,35 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import { TypeDefInfo } from '@polkadot/types/types';
|
||||
|
||||
import abis from '../test/contracts';
|
||||
import { Abi } from '.';
|
||||
|
||||
function stringifyInfo (key: string, value: unknown): unknown {
|
||||
return key === 'info'
|
||||
? TypeDefInfo[value as number]
|
||||
: value;
|
||||
}
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
Object.keys(abis).forEach((abiName) => {
|
||||
it(`initializes from a contract ABI (${abiName})`, (): void => {
|
||||
const abi = new Abi(abis[abiName]);
|
||||
const json = JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo, 2);
|
||||
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
|
||||
|
||||
try {
|
||||
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
expect(JSON.parse(json)).toEqual(require(cmpPath));
|
||||
} catch (error) {
|
||||
if (process.env.GITHUB_REPOSITORY) {
|
||||
console.error(JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo));
|
||||
|
||||
if (!fs.existsSync(cmpPath)) {
|
||||
fs.writeFileSync(cmpPath, JSON.stringify(abi.registry.metaTypeDefs, null, 2), { flag: 'w' });
|
||||
throw error;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
expect(abi.registry.metaTypeDefs).toEqual(require(cmpPath));
|
||||
} catch (error) {
|
||||
console.error(JSON.stringify(abi.registry.metaTypeDefs));
|
||||
|
||||
throw error;
|
||||
fs.writeFileSync(cmpPath, json, { flag: 'w' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,6 +24,7 @@ const PRIMITIVE_ALIAS: Record<string, keyof InterfaceTypes> = {
|
||||
|
||||
const PRIMITIVE_ALWAYS = ['AccountId', 'AccountIndex', 'Address', 'Balance'];
|
||||
|
||||
// TODO Replace usages with PortableRegistry
|
||||
export class MetaRegistry extends TypeRegistry {
|
||||
public readonly metaTypeDefs: TypeDef[] = [];
|
||||
|
||||
@@ -119,7 +120,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
|
||||
const displayName = path.pop()?.toString();
|
||||
|
||||
return withTypeString({
|
||||
return withTypeString(this, {
|
||||
...(displayName
|
||||
? { displayName }
|
||||
: {}
|
||||
@@ -243,7 +244,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
name: name.toString(),
|
||||
type: 'Null'
|
||||
}))
|
||||
: variants.map(({ fields, name }) => withTypeString({
|
||||
: variants.map(({ fields, name }) => withTypeString(this, {
|
||||
...this.#extractFields(fields),
|
||||
name: name.toString()
|
||||
}));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { MapConstructorExec } from './types';
|
||||
|
||||
@@ -52,7 +52,7 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.instantiate(
|
||||
value,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { MapConstructorExec } from './types';
|
||||
|
||||
@@ -56,7 +56,7 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
return this.api.tx.contracts
|
||||
.instantiateWithCode(
|
||||
value,
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||
import type { Bytes } from '@polkadot/types';
|
||||
import type { AccountId, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||
|
||||
@@ -26,15 +26,15 @@ const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is
|
||||
|
||||
const l = logger('Contract');
|
||||
|
||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: unknown[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
return (origin: string | AccountId | Uint8Array, options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
isOptions(options)
|
||||
? fn(origin, options, params)
|
||||
: fn(origin, ...extractOptions(options, params));
|
||||
}
|
||||
|
||||
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||
return (options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> =>
|
||||
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: unknown[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||
return (options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
@@ -90,7 +90,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
return this.#tx;
|
||||
}
|
||||
|
||||
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
|
||||
#getGas = (_gasLimit: bigint | BN | string | number, isCall = false): BN => {
|
||||
const gasLimit = bnToBn(_gasLimit);
|
||||
|
||||
return gasLimit.lte(BN_ZERO)
|
||||
@@ -103,7 +103,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
: gasLimit;
|
||||
}
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
|
||||
return this.api.tx.contracts
|
||||
.call(
|
||||
this.address,
|
||||
@@ -129,7 +129,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
);
|
||||
}
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
|
||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
|
||||
@@ -5,28 +5,27 @@ import type { Observable } from 'rxjs';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
||||
|
||||
export interface BlueprintDeploy<ApiType extends ApiTypes> {
|
||||
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: bigint | string | number | BN, gasLimit: bigint | string | number | BN, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractQuery<ApiType extends ApiTypes> {
|
||||
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
(origin: AccountId | string | Uint8Array, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
}
|
||||
|
||||
export interface ContractTx<ApiType extends ApiTypes> {
|
||||
(options: ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
||||
(options: ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractGeneric<O, T> {
|
||||
(messageOrId: AbiMessage | string | number, options: O, ...params: CodecArg[]): T;
|
||||
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): T;
|
||||
(messageOrId: AbiMessage | string | number, options: O, ...params: unknown[]): T;
|
||||
(messageOrId: AbiMessage | string | number, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): T;
|
||||
}
|
||||
|
||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||
@@ -17,15 +16,15 @@ import { extractOptions, isOptions } from '../util';
|
||||
|
||||
export const EMPTY_SALT = new Uint8Array();
|
||||
|
||||
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
||||
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
|
||||
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: unknown[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
||||
return (options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType, R> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions(options, params));
|
||||
}
|
||||
|
||||
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
|
||||
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: unknown[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||
return (constructorOrId: AbiConstructor | string | number, options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): T =>
|
||||
isOptions(options)
|
||||
? fn(constructorOrId, options, params)
|
||||
: fn(constructorOrId, ...extractOptions(options, params));
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '5.8.2' };
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { ApiBase } from '@polkadot/api/base';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
import type { Text, u64 } from '@polkadot/types';
|
||||
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
||||
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
|
||||
import type { Codec, TypeDef } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { Abi } from '.';
|
||||
|
||||
@@ -42,7 +42,7 @@ export interface AbiMessage {
|
||||
method: string;
|
||||
returnType?: TypeDef | null;
|
||||
selector: ContractSelector;
|
||||
toU8a: (params: CodecArg[]) => Uint8Array;
|
||||
toU8a: (params: unknown[]) => Uint8Array;
|
||||
}
|
||||
|
||||
export type AbiConstructor = AbiMessage;
|
||||
@@ -71,12 +71,12 @@ export interface DecodedMessage {
|
||||
}
|
||||
|
||||
export interface BlueprintOptions {
|
||||
gasLimit?: BigInt | string | number | BN;
|
||||
gasLimit?: bigint | string | number | BN;
|
||||
salt?: Uint8Array | string | null;
|
||||
value?: BigInt | string | number | BN;
|
||||
value?: bigint | string | number | BN;
|
||||
}
|
||||
|
||||
export interface ContractOptions {
|
||||
gasLimit?: BigInt | BN | string | number;
|
||||
value?: BigInt | BN | string | number;
|
||||
gasLimit?: bigint | BN | string | number;
|
||||
value?: bigint | BN | string | number;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { CodecArg } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
@@ -25,11 +24,11 @@ export function applyOnEvent <T> (result: SubmittableResult, types: ContractEven
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isOptions <T> (options: BigInt | string | number | BN | T): options is T {
|
||||
export function isOptions <T> (options: bigint | string | number | BN | T): options is T {
|
||||
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
|
||||
}
|
||||
|
||||
export function extractOptions <T extends TOptions> (value: BigInt | string | number | BN, params: CodecArg[]): [T, CodecArg[]] {
|
||||
export function extractOptions <T extends TOptions> (value: bigint | string | number | BN, params: unknown[]): [T, unknown[]] {
|
||||
const gasLimit = params.shift() as BN;
|
||||
|
||||
return [{ gasLimit, value } as T, params];
|
||||
|
||||
@@ -2,30 +2,30 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32"
|
||||
},
|
||||
{
|
||||
"displayName": "Hash",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "Hash"
|
||||
}
|
||||
]
|
||||
@@ -2,20 +2,20 @@
|
||||
{
|
||||
"displayName": "Header",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "last_vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len_entries"
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
@@ -33,15 +33,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -52,45 +52,45 @@
|
||||
{
|
||||
"displayName": "Hash",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "Hash",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "Hash",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "Hash"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -104,23 +104,23 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
@@ -128,7 +128,7 @@
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
@@ -136,13 +136,13 @@
|
||||
"name": "Error",
|
||||
"displayName": "Error",
|
||||
"namespace": "dns::dns",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NameAlreadyExists",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -150,7 +150,7 @@
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CallerIsNotOwner",
|
||||
"type": "Null"
|
||||
}
|
||||
@@ -158,24 +158,24 @@
|
||||
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"info": "Result",
|
||||
"type": "Result<(), Error>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Error",
|
||||
"namespace": "dns::dns",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NameAlreadyExists",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -183,7 +183,7 @@
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CallerIsNotOwner",
|
||||
"type": "Null"
|
||||
}
|
||||
@@ -195,10 +195,10 @@
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"info": "Option",
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
@@ -1,25 +1,25 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128"
|
||||
},
|
||||
{
|
||||
"displayName": "Header",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "last_vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len_entries"
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
@@ -37,15 +37,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -56,45 +56,45 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -106,17 +106,17 @@
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -126,15 +126,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -143,48 +143,48 @@
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(AccountId,AccountId)",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
"type": "(AccountId,AccountId)"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
@@ -192,10 +192,10 @@
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"info": "Option",
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
@@ -2,20 +2,20 @@
|
||||
{
|
||||
"displayName": "Header",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "last_vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len_entries"
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
@@ -33,15 +33,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -50,26 +50,26 @@
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -83,36 +83,36 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
@@ -122,15 +122,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -141,12 +141,12 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
@@ -154,17 +154,17 @@
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -174,15 +174,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -191,66 +191,66 @@
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(AccountId,AccountId)",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
"type": "(AccountId,AccountId)"
|
||||
},
|
||||
{
|
||||
"displayName": "ValueEntry",
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "bool",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
@@ -258,10 +258,10 @@
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"info": "Option",
|
||||
"type": "Option<AccountId>"
|
||||
},
|
||||
{
|
||||
@@ -269,7 +269,7 @@
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
@@ -277,13 +277,13 @@
|
||||
"name": "Error",
|
||||
"displayName": "Error",
|
||||
"namespace": "erc721::erc721",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotOwner",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -291,7 +291,7 @@
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotApproved",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -299,7 +299,7 @@
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "TokenExists",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -307,7 +307,7 @@
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "TokenNotFound",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -315,7 +315,7 @@
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CannotInsert",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -323,7 +323,7 @@
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CannotRemove",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -331,7 +331,7 @@
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CannotFetchValue",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -339,7 +339,7 @@
|
||||
"ext": {
|
||||
"discriminant": 7
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotAllowed",
|
||||
"type": "Null"
|
||||
}
|
||||
@@ -347,24 +347,24 @@
|
||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"info": "Result",
|
||||
"type": "Result<(), Error>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"displayName": "Error",
|
||||
"namespace": "erc721::erc721",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotOwner",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -372,7 +372,7 @@
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotApproved",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -380,7 +380,7 @@
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "TokenExists",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -388,7 +388,7 @@
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "TokenNotFound",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -396,7 +396,7 @@
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CannotInsert",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -404,7 +404,7 @@
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CannotRemove",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -412,7 +412,7 @@
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "CannotFetchValue",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -420,7 +420,7 @@
|
||||
"ext": {
|
||||
"discriminant": 7
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotAllowed",
|
||||
"type": "Null"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32"
|
||||
}
|
||||
]
|
||||
@@ -2,20 +2,20 @@
|
||||
{
|
||||
"displayName": "Header",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "last_vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len_entries"
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
@@ -33,15 +33,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -50,73 +50,73 @@
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(u32, AccountId)",
|
||||
"type": "(u32,AccountId)",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32, AccountId)\"}}"
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(u32, AccountId)"
|
||||
"type": "(u32,AccountId)"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -128,22 +128,22 @@
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
@@ -154,15 +154,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -171,12 +171,12 @@
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||
},
|
||||
{
|
||||
@@ -184,17 +184,17 @@
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -204,15 +204,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -223,41 +223,41 @@
|
||||
{
|
||||
"displayName": "Transaction",
|
||||
"namespace": "multisig_plain::multisig_plain",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "callee"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 4,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;4]",
|
||||
"name": "selector"
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>",
|
||||
"name": "input"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128",
|
||||
"name": "transferred_value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u64",
|
||||
"name": "gas_limit"
|
||||
}
|
||||
@@ -266,47 +266,47 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "Transaction",
|
||||
"namespace": "multisig_plain::multisig_plain",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "callee"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 4,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;4]",
|
||||
"name": "selector"
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>",
|
||||
"name": "input"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128",
|
||||
"name": "transferred_value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u64",
|
||||
"name": "gas_limit"
|
||||
}
|
||||
@@ -314,28 +314,28 @@
|
||||
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 4,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;4]"
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u64"
|
||||
},
|
||||
{
|
||||
@@ -345,15 +345,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -364,44 +364,44 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
"type": "Vec<AccountId>"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"displayName": "ConfirmationStatus",
|
||||
"namespace": "multisig_plain::multisig_plain",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Confirmed",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "ConfirmationsNeeded"
|
||||
}
|
||||
@@ -409,21 +409,21 @@
|
||||
"type": "{\"_enum\":{\"Confirmed\":\"()\",\"ConfirmationsNeeded\":\"u32\"}}"
|
||||
}
|
||||
],
|
||||
"type": "(u32, ConfirmationStatus)"
|
||||
"type": "(u32,ConfirmationStatus)"
|
||||
},
|
||||
{
|
||||
"displayName": "ConfirmationStatus",
|
||||
"namespace": "multisig_plain::multisig_plain",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Confirmed",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "ConfirmationsNeeded"
|
||||
}
|
||||
@@ -435,18 +435,18 @@
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"name": "Error",
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"info": "Result",
|
||||
"type": "Result<(), ()>"
|
||||
},
|
||||
{
|
||||
@@ -454,21 +454,21 @@
|
||||
"sub": [
|
||||
{
|
||||
"name": "Ok",
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
{
|
||||
"name": "Error",
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"info": "Result",
|
||||
"type": "Result<Vec<u8>, ()>"
|
||||
},
|
||||
{
|
||||
@@ -478,37 +478,37 @@
|
||||
"name": "Ok",
|
||||
"displayName": "Option",
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"info": 5,
|
||||
"info": "Option",
|
||||
"type": "Option<Vec<u8>>"
|
||||
},
|
||||
{
|
||||
"name": "Error",
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"type": "()"
|
||||
}
|
||||
],
|
||||
"info": 7,
|
||||
"info": "Result",
|
||||
"type": "Result<Option<Vec<u8>>, ()>"
|
||||
},
|
||||
{
|
||||
"displayName": "Option",
|
||||
"sub": {
|
||||
"info": 11,
|
||||
"info": "Vec",
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "Vec<u8>"
|
||||
},
|
||||
"info": 5,
|
||||
"info": "Option",
|
||||
"type": "Option<Vec<u8>>"
|
||||
}
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u256"
|
||||
}
|
||||
]
|
||||
@@ -1,28 +1,28 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u256"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "Text"
|
||||
}
|
||||
]
|
||||
@@ -1,23 +1,23 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "Variant",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "None",
|
||||
"type": "()"
|
||||
@@ -25,13 +25,13 @@
|
||||
{
|
||||
"displayName": "Weekday",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Monday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -39,7 +39,7 @@
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Tuesday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -47,7 +47,7 @@
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Wednesday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -55,7 +55,7 @@
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Thursday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -63,7 +63,7 @@
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Friday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -71,7 +71,7 @@
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Saturday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -79,7 +79,7 @@
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Sunday",
|
||||
"type": "Null"
|
||||
}
|
||||
@@ -90,15 +90,15 @@
|
||||
{
|
||||
"displayName": "TupleMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32",
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "Unsigned"
|
||||
}
|
||||
@@ -109,13 +109,13 @@
|
||||
{
|
||||
"displayName": "NamedMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32",
|
||||
"name": "value"
|
||||
}
|
||||
@@ -124,10 +124,10 @@
|
||||
"type": "{\"value\":\"i32\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
}
|
||||
@@ -142,47 +142,47 @@
|
||||
{
|
||||
"displayName": "Color",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Red",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Blue",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Green",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Yellow",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
}
|
||||
@@ -191,25 +191,25 @@
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "a"
|
||||
}
|
||||
@@ -227,13 +227,13 @@
|
||||
{
|
||||
"displayName": "Weekday",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"ext": {
|
||||
"discriminant": 0
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Monday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -241,7 +241,7 @@
|
||||
"ext": {
|
||||
"discriminant": 1
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Tuesday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -249,7 +249,7 @@
|
||||
"ext": {
|
||||
"discriminant": 2
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Wednesday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -257,7 +257,7 @@
|
||||
"ext": {
|
||||
"discriminant": 3
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Thursday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -265,7 +265,7 @@
|
||||
"ext": {
|
||||
"discriminant": 4
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Friday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -273,7 +273,7 @@
|
||||
"ext": {
|
||||
"discriminant": 5
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Saturday",
|
||||
"type": "Null"
|
||||
},
|
||||
@@ -281,7 +281,7 @@
|
||||
"ext": {
|
||||
"discriminant": 6
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "Sunday",
|
||||
"type": "Null"
|
||||
}
|
||||
@@ -291,15 +291,15 @@
|
||||
{
|
||||
"displayName": "TupleMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32",
|
||||
"name": "Signed"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "Unsigned"
|
||||
}
|
||||
@@ -309,13 +309,13 @@
|
||||
{
|
||||
"displayName": "NamedMaybeSigned",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "i32",
|
||||
"name": "value"
|
||||
}
|
||||
@@ -324,10 +324,10 @@
|
||||
"type": "{\"value\":\"i32\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "value"
|
||||
}
|
||||
@@ -341,47 +341,47 @@
|
||||
{
|
||||
"displayName": "Color",
|
||||
"namespace": "enum_example::enum_example",
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"sub": [
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Red",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Blue",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Green",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [],
|
||||
"name": "Yellow",
|
||||
"type": "()"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
}
|
||||
@@ -390,25 +390,25 @@
|
||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||
},
|
||||
{
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "r"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "g"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "b"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8",
|
||||
"name": "a"
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
[
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128"
|
||||
},
|
||||
{
|
||||
"displayName": "Header",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "last_vacant"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "len_entries"
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32"
|
||||
},
|
||||
{
|
||||
@@ -37,15 +37,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -56,45 +56,45 @@
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"info": 12,
|
||||
"info": "VecFixed",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
"type": "[u8;32]"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u8"
|
||||
},
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -106,17 +106,17 @@
|
||||
"namespace": "ink_storage::collections::hashmap",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u128",
|
||||
"name": "value"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "key_index"
|
||||
}
|
||||
],
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||
},
|
||||
{
|
||||
@@ -126,15 +126,15 @@
|
||||
{
|
||||
"displayName": "VacantEntry",
|
||||
"namespace": "ink_storage::collections::stash",
|
||||
"info": 9,
|
||||
"info": "Struct",
|
||||
"sub": [
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "next"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "u32",
|
||||
"name": "prev"
|
||||
}
|
||||
@@ -143,52 +143,52 @@
|
||||
"name": "Vacant"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)",
|
||||
"type": "(AccountId,AccountId)",
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId, AccountId)\"}}"
|
||||
"info": "Enum",
|
||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
||||
},
|
||||
{
|
||||
"info": 10,
|
||||
"info": "Tuple",
|
||||
"sub": [
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
{
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
}
|
||||
],
|
||||
"type": "(AccountId, AccountId)"
|
||||
"type": "(AccountId,AccountId)"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "Text"
|
||||
},
|
||||
{
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "bool"
|
||||
},
|
||||
{
|
||||
@@ -196,10 +196,10 @@
|
||||
"sub": {
|
||||
"displayName": "AccountId",
|
||||
"namespace": "ink_env::types",
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"type": "AccountId"
|
||||
},
|
||||
"info": 5,
|
||||
"info": "Option",
|
||||
"type": "Option<AccountId>"
|
||||
}
|
||||
]
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
@@ -19,16 +19,16 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api": "5.1.1",
|
||||
"@polkadot/rpc-core": "5.1.1",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2",
|
||||
"@polkadot/util-crypto": "^7.0.2",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/api": "5.8.2",
|
||||
"@polkadot/rpc-core": "5.8.2",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1",
|
||||
"@polkadot/util-crypto": "^7.3.1",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.0.2",
|
||||
"@polkadot/rpc-provider": "5.1.1"
|
||||
"@polkadot/keyring": "^7.3.1",
|
||||
"@polkadot/rpc-provider": "5.8.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
||||
import type { ApiInterfaceRx, QueryableStorageEntry } from '@polkadot/api/types';
|
||||
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||
import type { ITuple } from '@polkadot/types/types';
|
||||
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { assert, isFunction } from '@polkadot/util';
|
||||
import { isFunction } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -39,15 +39,11 @@ function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenF
|
||||
};
|
||||
}
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
const primary = balances[0];
|
||||
|
||||
assert(primary, 'No balances retrieved for account');
|
||||
|
||||
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, [primary, ...additional]]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
return {
|
||||
accountId,
|
||||
accountNonce,
|
||||
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
|
||||
additional: additional.map((b) => getBalance(api, b)),
|
||||
...getBalance(api, primary)
|
||||
};
|
||||
}
|
||||
@@ -66,34 +62,44 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
||||
);
|
||||
}
|
||||
|
||||
function querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
return api.query.system.accountNonce<Index>(accountId).pipe(
|
||||
map((accountNonce): Result => [
|
||||
accountNonce,
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
])
|
||||
);
|
||||
function queryNonceOnly (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
const fill = (nonce: Index): Result => [
|
||||
nonce,
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
];
|
||||
|
||||
return isFunction(api.query.system.account)
|
||||
? api.query.system.account(accountId).pipe(
|
||||
map(({ nonce }) => fill(nonce))
|
||||
)
|
||||
: isFunction(api.query.system.accountNonce)
|
||||
? api.query.system.accountNonce<Index>(accountId).pipe(
|
||||
map((nonce) => fill(nonce))
|
||||
)
|
||||
: of(fill(api.registry.createType('Index')));
|
||||
}
|
||||
|
||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||
const balances = modules.map(
|
||||
(m): QueryableStorageMultiArg<'rxjs'> => [
|
||||
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
|
||||
accountId
|
||||
]
|
||||
);
|
||||
const balances = modules
|
||||
.map((m): QueryableStorageEntry<'rxjs'> => (api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m]?.account)
|
||||
.filter((q) => isFunction(q))
|
||||
.map((q): [QueryableStorageEntry<'rxjs'>, AccountId] => [q, accountId]);
|
||||
|
||||
const extract = (data: AccountData[]) =>
|
||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
||||
const extract = (nonce: Index, data: AccountData[]): Result => [
|
||||
nonce,
|
||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen])
|
||||
];
|
||||
|
||||
// NOTE this is for the first case where we do have instances specified
|
||||
return isFunction(api.query.system.account)
|
||||
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
|
||||
)
|
||||
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
||||
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
|
||||
);
|
||||
return balances.length
|
||||
? isFunction(api.query.system.account)
|
||||
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||
map(([{ nonce }, ...balances]) => extract(nonce, balances))
|
||||
)
|
||||
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
||||
map(([nonce, ...balances]) => extract(nonce, balances))
|
||||
)
|
||||
: queryNonceOnly(api, accountId);
|
||||
}
|
||||
|
||||
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||
@@ -140,10 +146,6 @@ function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observa
|
||||
*/
|
||||
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||
const empty: Result = [
|
||||
api.registry.createType('Index'),
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
];
|
||||
|
||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
@@ -159,11 +161,12 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
|
||||
? queryBalancesAccount(api, accountId)
|
||||
: isFunction(api.query.balances?.freeBalance)
|
||||
? queryBalancesFree(api, accountId)
|
||||
: isFunction(api.query.system?.accountNonce)
|
||||
? querySystemNonce(api, accountId)
|
||||
: of(empty)
|
||||
: queryNonceOnly(api, accountId)
|
||||
])
|
||||
: of([api.registry.createType('AccountId'), empty])
|
||||
: of([api.registry.createType('AccountId'), [
|
||||
api.registry.createType('Index'),
|
||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||
]])
|
||||
)
|
||||
),
|
||||
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
||||
|
||||
@@ -73,7 +73,8 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
|
||||
// Calculate the vesting balances,
|
||||
// - offset = balance locked at startingBlock
|
||||
// - perBlock is the unlock amount
|
||||
const { locked: vestingTotal, perBlock, startingBlock } = vesting || api.registry.createType('VestingInfo');
|
||||
const emptyVest = api.registry.createType('VestingInfo');
|
||||
const { locked: vestingTotal, perBlock, startingBlock } = vesting || emptyVest;
|
||||
const isStarted = bestNumber.gt(startingBlock);
|
||||
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
||||
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
||||
@@ -117,33 +118,29 @@ const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable
|
||||
|
||||
// current (balances, vesting)
|
||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
||||
const lockCalls = balanceInstances.map(
|
||||
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
|
||||
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
|
||||
const calls = balanceInstances.map((m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
|
||||
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
|
||||
);
|
||||
|
||||
const lockEmpty = lockCalls.map((c) => !c);
|
||||
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||
const lockEmpty = calls.map((c) => !c);
|
||||
const queries = calls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||
|
||||
return (
|
||||
api.query.vesting?.vesting
|
||||
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
|
||||
[api.query.vesting.vesting, accountId],
|
||||
...lockQueries
|
||||
])
|
||||
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([[api.query.vesting.vesting, accountId], ...queries])
|
||||
// TODO We need to check module instances here as well, not only the balances module
|
||||
: lockQueries.length
|
||||
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
|
||||
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
|
||||
[api.registry.createType('Option<VestingInfo>'), ...locks]
|
||||
)
|
||||
: queries.length
|
||||
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(queries).pipe(
|
||||
map((r): [Option<VestingInfo>, ...BalanceLocks] => [api.registry.createType('Option<VestingInfo>'), ...r])
|
||||
)
|
||||
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
|
||||
).pipe(
|
||||
map(([optVesting, ...locks]): ResultBalance => {
|
||||
map(([opt, ...locks]): ResultBalance => {
|
||||
let offset = -1;
|
||||
|
||||
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
|
||||
return [
|
||||
opt.unwrapOr(null),
|
||||
lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
|
||||
const id = scheduled.maybeId.unwrap().toHex();
|
||||
|
||||
if (id.startsWith(DEMOCRACY_ID)) {
|
||||
const [, index] = api.registry.createType('(u64, ReferendumIndex)' as any, id) as ITuple<[u64, ReferendumIndex]>;
|
||||
const [, index] = api.registry.createType<ITuple<[u64, ReferendumIndex]>>('(u64, ReferendumIndex)', id);
|
||||
const imageHash = scheduled.call.args[0] as Hash;
|
||||
|
||||
result.push({ at, imageHash, index });
|
||||
|
||||
@@ -14,10 +14,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
||||
import { ExactDerive } from '.';
|
||||
|
||||
const testFunction = (api: ApiRx): any => {
|
||||
return <
|
||||
Section extends keyof ExactDerive,
|
||||
Method extends keyof (typeof api.derive[Section])
|
||||
>(section: Section, method: Method, inputs: any[]): void => {
|
||||
return <S extends keyof ExactDerive, M extends keyof (typeof api.derive[S])>(section: S, method: M, inputs: any[]): void => {
|
||||
describe(`derive.${section}.${method}`, (): void => {
|
||||
it('should be a function', (): void => {
|
||||
expect(typeof api.derive[section][method]).toBe('function');
|
||||
@@ -96,7 +93,7 @@ describe('derive', (): void => {
|
||||
testFunction(api)('balances', 'fees', ['a', 'b']);
|
||||
|
||||
// new
|
||||
testFunction(api)('custom' as any, 'test', [1, 2, 3]);
|
||||
testFunction(api)('custom', 'test', [1, 2, 3]);
|
||||
|
||||
// existing
|
||||
testFunction(api)('chain', 'bestNumber', []);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '5.8.2' };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Option, u32 } from '@polkadot/types';
|
||||
import type { Option, u32, u64 } from '@polkadot/types';
|
||||
import type { BlockNumber, EraIndex, Moment, SessionIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
export interface DeriveSessionIndexes {
|
||||
@@ -15,7 +15,7 @@ export interface DeriveSessionIndexes {
|
||||
export interface DeriveSessionInfo extends DeriveSessionIndexes {
|
||||
eraLength: BlockNumber;
|
||||
isEpoch: boolean;
|
||||
sessionLength: BlockNumber;
|
||||
sessionLength: u64;
|
||||
sessionsPerEra: SessionIndex;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||
import metaStatic from '@polkadot/types/metadata/static';
|
||||
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
export function createApiWithAugmentations (): ApiPromise {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
@@ -19,16 +19,16 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api-derive": "5.1.1",
|
||||
"@polkadot/keyring": "^7.0.2",
|
||||
"@polkadot/rpc-core": "5.1.1",
|
||||
"@polkadot/rpc-provider": "5.1.1",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/types-known": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2",
|
||||
"@polkadot/util-crypto": "^7.0.2",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/api-derive": "5.8.2",
|
||||
"@polkadot/keyring": "^7.3.1",
|
||||
"@polkadot/rpc-core": "5.8.2",
|
||||
"@polkadot/rpc-provider": "5.8.2",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/types-known": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1",
|
||||
"@polkadot/util-crypto": "^7.3.1",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^7.2.0"
|
||||
"rxjs": "^7.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,59 @@
|
||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||
/* eslint-disable */
|
||||
|
||||
import type { Vec, u16, u32, u64 } from '@polkadot/types';
|
||||
import type { Vec, bool, u16, u32, u64 } from '@polkadot/types';
|
||||
import type { Codec } from '@polkadot/types/types';
|
||||
import type { Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, TransactionPriority, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { EraIndex } from '@polkadot/types/interfaces/staking';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import type { BlockLength, BlockWeights } from '@polkadot/types/interfaces/system';
|
||||
import type { DepositBalanceOf } from '@polkadot/types/interfaces/uniques';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
|
||||
declare module '@polkadot/api/types/consts' {
|
||||
export interface AugmentedConsts<ApiType> {
|
||||
assets: {
|
||||
/**
|
||||
* The amount of funds that must be reserved when creating a new approval.
|
||||
**/
|
||||
approvalDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The basic amount of funds that must be reserved for an asset.
|
||||
**/
|
||||
assetDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The basic amount of funds that must be reserved when adding metadata to your asset.
|
||||
**/
|
||||
metadataDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The additional funds that must be reserved for the number of bytes you store in your
|
||||
* metadata.
|
||||
**/
|
||||
metadataDepositPerByte: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of a name or symbol stored on-chain.
|
||||
**/
|
||||
stringLimit: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
authorship: {
|
||||
/**
|
||||
* The number of blocks back we should accept uncles.
|
||||
* This means that we will deal with uncle-parents that are
|
||||
* `UncleGenerations + 1` before `now`.
|
||||
**/
|
||||
uncleGenerations: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
babe: {
|
||||
/**
|
||||
* The amount of time, in slots, that each epoch should last.
|
||||
@@ -39,6 +79,15 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The minimum amount required to keep an account open.
|
||||
**/
|
||||
existentialDeposit: Balance & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of locks that should exist on an account.
|
||||
* Not strictly enforced, but used for weight estimation.
|
||||
**/
|
||||
maxLocks: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of named reserves that can exist on an account.
|
||||
**/
|
||||
maxReserves: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
@@ -94,17 +143,18 @@ declare module '@polkadot/api/types/consts' {
|
||||
* deposited while the contract is alive. Costs for additional storage are added to
|
||||
* this base cost.
|
||||
*
|
||||
* This is a simple way to ensure that contracts with empty storage eventually get deleted by
|
||||
* making them pay rent. This creates an incentive to remove them early in order to save rent.
|
||||
* This is a simple way to ensure that contracts with empty storage eventually get deleted
|
||||
* by making them pay rent. This creates an incentive to remove them early in order to save
|
||||
* rent.
|
||||
**/
|
||||
depositPerContract: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The balance a contract needs to deposit per storage byte to stay alive indefinitely.
|
||||
*
|
||||
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
|
||||
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
|
||||
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
|
||||
* then it would pay 500 BU/day.
|
||||
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1
|
||||
* BU/byte/day, then a contract with 1,000,000 BU that uses 1,000 bytes of storage would
|
||||
* pay no rent. But if the balance reduced to 500,000 BU and the storage stayed the same at
|
||||
* 1,000, then it would pay 500 BU/day.
|
||||
**/
|
||||
depositPerStorageByte: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -152,21 +202,31 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
cooloffPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum period of locking and the period between a proposal being approved and enacted.
|
||||
* The period between a proposal being approved and enacted.
|
||||
*
|
||||
* It should generally be a little more than the unstake period to ensure that
|
||||
* voting stakers have an opportunity to remove themselves from the system in the case where
|
||||
* they are on the losing side of a vote.
|
||||
* voting stakers have an opportunity to remove themselves from the system in the case
|
||||
* where they are on the losing side of a vote.
|
||||
**/
|
||||
enactmentPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Minimum voting period allowed for a fast-track referendum.
|
||||
**/
|
||||
fastTrackVotingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Indicator for whether an emergency origin is even allowed to happen. Some chains may
|
||||
* want to set this permanently to `false`, others may want to condition it on things such
|
||||
* as an upgrade having happened recently.
|
||||
**/
|
||||
instantAllowed: bool & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* How often (in blocks) new public referenda are launched.
|
||||
**/
|
||||
launchPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of public proposals that can exist at any time.
|
||||
**/
|
||||
maxProposals: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of votes for an account.
|
||||
*
|
||||
@@ -182,6 +242,13 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The amount of balance that must be deposited per byte of preimage stored.
|
||||
**/
|
||||
preimageByteDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum period of vote locking.
|
||||
*
|
||||
* It should be no shorter than enactment period to ensure that in the case of an approval,
|
||||
* those successful voters are locked into the consequences that their votes entail.
|
||||
**/
|
||||
voteLockingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* How often (in blocks) to check for new votes.
|
||||
**/
|
||||
@@ -192,6 +259,29 @@ declare module '@polkadot/api/types/consts' {
|
||||
[key: string]: Codec;
|
||||
};
|
||||
electionProviderMultiPhase: {
|
||||
/**
|
||||
* Maximum number of iteration of balancing that will be executed in the embedded miner of
|
||||
* the pallet.
|
||||
**/
|
||||
minerMaxIterations: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum length (bytes) that the mined solution should consume.
|
||||
*
|
||||
* The miner will ensure that the total length of the unsigned solution will not exceed
|
||||
* this value.
|
||||
**/
|
||||
minerMaxLength: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Maximum weight that the miner should consume.
|
||||
*
|
||||
* The miner will ensure that the total weight of the unsigned solution will not exceed
|
||||
* this value, based on [`WeightInfo::submit_unsigned`].
|
||||
**/
|
||||
minerMaxWeight: Weight & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The priority of the unsigned transaction submitted in the unsigned-phase
|
||||
**/
|
||||
minerTxPriority: TransactionPriority & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The repeat threshold of the offchain worker.
|
||||
*
|
||||
@@ -295,6 +385,11 @@ declare module '@polkadot/api/types/consts' {
|
||||
* Must be no greater than `MaxQueueLen`.
|
||||
**/
|
||||
fifoQueueLen: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The issuance to ignore. This is subtracted from the `Currency`'s `total_issuance` to get
|
||||
* the issuance by which we inflate or deflate the gilt.
|
||||
**/
|
||||
ignoredIssuance: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The number of blocks between consecutive attempts to issue more gilts in an effort to
|
||||
* get to the target amount to be frozen.
|
||||
@@ -362,8 +457,8 @@ declare module '@polkadot/api/types/consts' {
|
||||
maxSubAccounts: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount held on deposit for a registered subaccount. This should account for the fact
|
||||
* that one storage item's value will increase by the size of an account ID, and there will be
|
||||
* another trie item whose value is the size of an account ID plus 32 bytes.
|
||||
* that one storage item's value will increase by the size of an account ID, and there will
|
||||
* be another trie item whose value is the size of an account ID plus 32 bytes.
|
||||
**/
|
||||
subAccountDeposit: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -371,6 +466,19 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
imOnline: {
|
||||
/**
|
||||
* A configuration for base priority of unsigned transactions.
|
||||
*
|
||||
* This is exposed so that it can be tuned for particular runtime, when
|
||||
* multiple pallets send unsigned transactions.
|
||||
**/
|
||||
unsignedPriority: TransactionPriority & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
indices: {
|
||||
/**
|
||||
* The deposit needed for reserving an index.
|
||||
@@ -386,6 +494,12 @@ declare module '@polkadot/api/types/consts' {
|
||||
* The max number of calls available in a single lottery.
|
||||
**/
|
||||
maxCalls: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Number of time we should try to generate a random number that has no modulo bias.
|
||||
* The larger this number, the more potential computation is used for picking the winner,
|
||||
* but also the more likely that the chosen winner is done fairly.
|
||||
**/
|
||||
maxGenerateRandom: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The Lottery's pallet id
|
||||
**/
|
||||
@@ -397,8 +511,8 @@ declare module '@polkadot/api/types/consts' {
|
||||
};
|
||||
multisig: {
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating a multisig execution or to store
|
||||
* a dispatch call for later.
|
||||
* 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
|
||||
@@ -424,7 +538,8 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The base amount of currency needed to reserve for creating an announcement.
|
||||
*
|
||||
* This is held when a new storage item holding a `Balance` is created (typically 16 bytes).
|
||||
* This is held when a new storage item holding a `Balance` is created (typically 16
|
||||
* bytes).
|
||||
**/
|
||||
announcementDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -452,9 +567,9 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The amount of currency needed per proxy added.
|
||||
*
|
||||
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a pre-existing
|
||||
* storage value. Thus, when configuring `ProxyDepositFactor` one should take into account
|
||||
* `32 + proxy_type.encode().len()` bytes of data.
|
||||
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a
|
||||
* pre-existing storage value. Thus, when configuring `ProxyDepositFactor` one should take
|
||||
* into account `32 + proxy_type.encode().len()` bytes of data.
|
||||
**/
|
||||
proxyDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -471,9 +586,11 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
configDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The amount of currency needed per additional user when creating a recovery configuration.
|
||||
* The amount of currency needed per additional user when creating a recovery
|
||||
* configuration.
|
||||
*
|
||||
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value.
|
||||
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage
|
||||
* value.
|
||||
**/
|
||||
friendDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -495,6 +612,22 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
scheduler: {
|
||||
/**
|
||||
* The maximum weight that may be scheduled per block for any dispatchables of less
|
||||
* priority than `schedule::HARD_DEADLINE`.
|
||||
**/
|
||||
maximumWeight: Weight & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum number of scheduled calls in the queue for a single block.
|
||||
* Not strictly enforced, but used for weight estimation.
|
||||
**/
|
||||
maxScheduledPerBlock: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
society: {
|
||||
/**
|
||||
* The minimum amount of a deposit required for a bid to be made.
|
||||
@@ -544,8 +677,8 @@ declare module '@polkadot/api/types/consts' {
|
||||
/**
|
||||
* The maximum number of nominators rewarded for each validator.
|
||||
*
|
||||
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim
|
||||
* their reward. This used to limit the i/o cost for the nominator payout.
|
||||
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can
|
||||
* claim their reward. This used to limit the i/o cost for the nominator payout.
|
||||
**/
|
||||
maxNominatorRewardedPerValidator: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -600,10 +733,10 @@ declare module '@polkadot/api/types/consts' {
|
||||
};
|
||||
timestamp: {
|
||||
/**
|
||||
* The minimum period between blocks. Beware that this is different to the *expected* period
|
||||
* that the block production apparatus provides. Your chosen consensus system will generally
|
||||
* work with this to determine a sensible block time. e.g. For Aura, it will be double this
|
||||
* period on default settings.
|
||||
* The minimum period between blocks. Beware that this is different to the *expected*
|
||||
* period that the block production apparatus provides. Your chosen consensus system will
|
||||
* generally work with this to determine a sensible block time. e.g. For Aura, it will be
|
||||
* double this period on default settings.
|
||||
**/
|
||||
minimumPeriod: Moment & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -657,7 +790,11 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
burn: Permill & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The treasury's module id, used for deriving its sovereign account ID.
|
||||
* The maximum number of approvals that can wait in the spending queue.
|
||||
**/
|
||||
maxApprovals: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The treasury's pallet id, used for deriving its sovereign account ID.
|
||||
**/
|
||||
palletId: PalletId & AugmentedConst<ApiType>;
|
||||
/**
|
||||
@@ -678,7 +815,57 @@ declare module '@polkadot/api/types/consts' {
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
uniques: {
|
||||
/**
|
||||
* The basic amount of funds that must be reserved when adding an attribute to an asset.
|
||||
**/
|
||||
attributeDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The basic amount of funds that must be reserved for an asset class.
|
||||
**/
|
||||
classDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The additional funds that must be reserved for the number of bytes store in metadata,
|
||||
* either "normal" metadata or attribute metadata.
|
||||
**/
|
||||
depositPerByte: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The basic amount of funds that must be reserved for an asset instance.
|
||||
**/
|
||||
instanceDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of an attribute key.
|
||||
**/
|
||||
keyLimit: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The basic amount of funds that must be reserved when adding metadata to your asset.
|
||||
**/
|
||||
metadataDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of data stored on-chain.
|
||||
**/
|
||||
stringLimit: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The maximum length of an attribute value.
|
||||
**/
|
||||
valueLimit: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
utility: {
|
||||
/**
|
||||
* The limit on the number of batched calls.
|
||||
**/
|
||||
batchedCallsLimit: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* Generic const
|
||||
**/
|
||||
[key: string]: Codec;
|
||||
};
|
||||
vesting: {
|
||||
maxVestingSchedules: u32 & AugmentedConst<ApiType>;
|
||||
/**
|
||||
* The minimum amount transferred to call `vested_transfer`.
|
||||
**/
|
||||
|
||||
@@ -39,7 +39,8 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
NoPermission: AugmentedError<ApiType>;
|
||||
/**
|
||||
* No provider reference exists to allow a non-zero balance of a non-self-sufficient asset.
|
||||
* No provider reference exists to allow a non-zero balance of a non-self-sufficient
|
||||
* asset.
|
||||
**/
|
||||
NoProvider: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -424,10 +425,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Identity may not veto a proposal twice
|
||||
**/
|
||||
AlreadyVetoed: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Unknown index
|
||||
**/
|
||||
BadIndex: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Preimage already noted
|
||||
**/
|
||||
@@ -452,10 +449,6 @@ declare module '@polkadot/api/types/errors' {
|
||||
* Invalid hash
|
||||
**/
|
||||
InvalidHash: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The provided witness data is wrong.
|
||||
**/
|
||||
InvalidWitness: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Maximum number of votes reached.
|
||||
**/
|
||||
@@ -476,26 +469,14 @@ declare module '@polkadot/api/types/errors' {
|
||||
* No external proposal
|
||||
**/
|
||||
NoProposal: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Not delegated
|
||||
**/
|
||||
NotDelegated: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The account is not currently delegating.
|
||||
**/
|
||||
NotDelegating: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The lock on the account to be unlocked has not yet expired.
|
||||
**/
|
||||
NotExpired: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Not imminent
|
||||
**/
|
||||
NotImminent: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The target account does not have a lock.
|
||||
**/
|
||||
NotLocked: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Next external proposal not simple majority
|
||||
**/
|
||||
@@ -680,8 +661,8 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
AmountTooSmall: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The queue for the bid's duration is full and the amount bid is too low to get in through
|
||||
* replacing an existing bid.
|
||||
* The queue for the bid's duration is full and the amount bid is too low to get in
|
||||
* through replacing an existing bid.
|
||||
**/
|
||||
BidTooLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -1271,8 +1252,8 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
NoUnlockChunk: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are too many nominators in the system. Governance needs to adjust the staking settings
|
||||
* to keep things safe for the runtime.
|
||||
* There are too many nominators in the system. Governance needs to adjust the staking
|
||||
* settings to keep things safe for the runtime.
|
||||
**/
|
||||
TooManyNominators: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -1280,8 +1261,8 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
TooManyTargets: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There are too many validators in the system. Governance needs to adjust the staking settings
|
||||
* to keep things safe for the runtime.
|
||||
* There are too many validators in the system. Governance needs to adjust the staking
|
||||
* settings to keep things safe for the runtime.
|
||||
**/
|
||||
TooManyValidators: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -1541,19 +1522,38 @@ declare module '@polkadot/api/types/errors' {
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
utility: {
|
||||
/**
|
||||
* Too many calls batched.
|
||||
**/
|
||||
TooManyCalls: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
[key: string]: AugmentedError<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
/**
|
||||
* Amount being transferred is too low to create a vesting schedule.
|
||||
**/
|
||||
AmountLow: AugmentedError<ApiType>;
|
||||
/**
|
||||
* An existing vesting schedule already exists for this account that cannot be clobbered.
|
||||
* The account already has `MaxVestingSchedules` count of schedules and thus
|
||||
* cannot add another one. Consider merging existing schedules in order to add another.
|
||||
**/
|
||||
ExistingVestingSchedule: AugmentedError<ApiType>;
|
||||
AtMaxVestingSchedules: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Failed to create a new schedule because some parameter was invalid.
|
||||
**/
|
||||
InvalidScheduleParams: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The account given is not vesting.
|
||||
**/
|
||||
NotVesting: AugmentedError<ApiType>;
|
||||
/**
|
||||
* An index was out of bounds of the vesting schedules.
|
||||
**/
|
||||
ScheduleIndexOutOfBounds: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
|
||||
@@ -204,8 +204,8 @@ declare module '@polkadot/api/types/events' {
|
||||
* # Params
|
||||
*
|
||||
* - `contract`: The contract that emitted the event.
|
||||
* - `data`: Data supplied by the contract. Metadata generated during contract
|
||||
* compilation is needed to decode it.
|
||||
* - `data`: Data supplied by the contract. Metadata generated during contract compilation
|
||||
* is needed to decode it.
|
||||
**/
|
||||
ContractEmitted: AugmentedEvent<ApiType, [AccountId, Bytes]>;
|
||||
/**
|
||||
@@ -314,9 +314,9 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Delegated: AugmentedEvent<ApiType, [AccountId, AccountId]>;
|
||||
/**
|
||||
* A proposal has been enacted. \[ref_index, is_ok\]
|
||||
* A proposal has been enacted. \[ref_index, result\]
|
||||
**/
|
||||
Executed: AugmentedEvent<ApiType, [ReferendumIndex, bool]>;
|
||||
Executed: AugmentedEvent<ApiType, [ReferendumIndex, DispatchResult]>;
|
||||
/**
|
||||
* An external proposal has been tabled.
|
||||
**/
|
||||
@@ -362,17 +362,14 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Started: AugmentedEvent<ApiType, [ReferendumIndex, VoteThreshold]>;
|
||||
/**
|
||||
* A public proposal has been tabled for referendum vote. \[proposal_index, deposit, depositors\]
|
||||
* A public proposal has been tabled for referendum vote. \[proposal_index, deposit,
|
||||
* depositors\]
|
||||
**/
|
||||
Tabled: AugmentedEvent<ApiType, [PropIndex, Balance, Vec<AccountId>]>;
|
||||
/**
|
||||
* An \[account\] has cancelled a previous delegation operation.
|
||||
**/
|
||||
Undelegated: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* An \[account\] has been unlocked successfully.
|
||||
**/
|
||||
Unlocked: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* An external proposal has been vetoed. \[who, proposal_hash, until\]
|
||||
**/
|
||||
@@ -653,9 +650,14 @@ declare module '@polkadot/api/types/events' {
|
||||
Announced: AugmentedEvent<ApiType, [AccountId, AccountId, Hash]>;
|
||||
/**
|
||||
* Anonymous account has been created by new proxy with given
|
||||
* disambiguation index and proxy type. \[anonymous, who, proxy_type, disambiguation_index\]
|
||||
* disambiguation index and proxy type. \[anonymous, who, proxy_type,
|
||||
* disambiguation_index\]
|
||||
**/
|
||||
AnonymousCreated: AugmentedEvent<ApiType, [AccountId, AccountId, ProxyType, u16]>;
|
||||
/**
|
||||
* A proxy was added. \[delegator, delegatee, proxy_type, delay\]
|
||||
**/
|
||||
ProxyAdded: AugmentedEvent<ApiType, [AccountId, AccountId, ProxyType, BlockNumber]>;
|
||||
/**
|
||||
* A proxy was executed correctly, with the given \[result\].
|
||||
**/
|
||||
@@ -719,8 +721,8 @@ declare module '@polkadot/api/types/events' {
|
||||
};
|
||||
session: {
|
||||
/**
|
||||
* New session has happened. Note that the argument is the \[session_index\], not the block
|
||||
* number as the type might suggest.
|
||||
* New session has happened. Note that the argument is the \[session_index\], not the
|
||||
* block number as the type might suggest.
|
||||
**/
|
||||
NewSession: AugmentedEvent<ApiType, [SessionIndex]>;
|
||||
/**
|
||||
@@ -819,7 +821,7 @@ declare module '@polkadot/api/types/events' {
|
||||
* the remainder from the maximum amount of reward.
|
||||
* \[era_index, validator_payout, remainder\]
|
||||
**/
|
||||
EraPayout: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>;
|
||||
EraPaid: AugmentedEvent<ApiType, [EraIndex, Balance, Balance]>;
|
||||
/**
|
||||
* A nominator has been kicked from a validator. \[nominator, stash\]
|
||||
**/
|
||||
@@ -830,18 +832,22 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
OldSlashingReportDiscarded: AugmentedEvent<ApiType, [SessionIndex]>;
|
||||
/**
|
||||
* The staker has been rewarded by this amount. \[stash, amount\]
|
||||
* The stakers' rewards are getting paid. \[era_index, validator_stash\]
|
||||
**/
|
||||
Reward: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
PayoutStarted: AugmentedEvent<ApiType, [EraIndex, AccountId]>;
|
||||
/**
|
||||
* The nominator has been rewarded by this amount. \[stash, amount\]
|
||||
**/
|
||||
Rewarded: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* One validator (and its nominators) has been slashed by the given amount.
|
||||
* \[validator, amount\]
|
||||
**/
|
||||
Slash: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
Slashed: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
/**
|
||||
* A new set of stakers was elected.
|
||||
**/
|
||||
StakingElection: AugmentedEvent<ApiType, []>;
|
||||
StakersElected: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* The election failed. No new era is planned.
|
||||
**/
|
||||
@@ -1125,7 +1131,7 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Frozen: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* An asset `instace` was issued. \[ class, instance, owner \]
|
||||
* An asset `instance` was issued. \[ class, instance, owner \]
|
||||
**/
|
||||
Issued: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId]>;
|
||||
/**
|
||||
@@ -1154,7 +1160,7 @@ declare module '@polkadot/api/types/events' {
|
||||
**/
|
||||
Thawed: AugmentedEvent<ApiType, [ClassId, InstanceId]>;
|
||||
/**
|
||||
* An asset `instace` was transferred. \[ class, instance, from, to \]
|
||||
* An asset `instance` was transferred. \[ class, instance, from, to \]
|
||||
**/
|
||||
Transferred: AugmentedEvent<ApiType, [ClassId, InstanceId, AccountId, AccountId]>;
|
||||
/**
|
||||
@@ -1172,6 +1178,10 @@ declare module '@polkadot/api/types/events' {
|
||||
* well as the error. \[index, error\]
|
||||
**/
|
||||
BatchInterrupted: AugmentedEvent<ApiType, [u32, DispatchError]>;
|
||||
/**
|
||||
* A single item within a Batch of dispatches has completed with no error.
|
||||
**/
|
||||
ItemCompleted: AugmentedEvent<ApiType, []>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
@@ -1179,12 +1189,12 @@ declare module '@polkadot/api/types/events' {
|
||||
};
|
||||
vesting: {
|
||||
/**
|
||||
* An \[account\] has become fully vested. No further vesting can happen.
|
||||
* An \[account\] has become fully vested.
|
||||
**/
|
||||
VestingCompleted: AugmentedEvent<ApiType, [AccountId]>;
|
||||
/**
|
||||
* The amount vested has been updated. This could indicate more funds are available. The
|
||||
* balance given is the amount which is left unvested (and thus locked).
|
||||
* The amount vested has been updated. This could indicate a change in funds available.
|
||||
* The balance given is the amount which is left unvested (and thus locked).
|
||||
* \[account, unvested\]
|
||||
**/
|
||||
VestingUpdated: AugmentedEvent<ApiType, [AccountId, Balance]>;
|
||||
|
||||
@@ -94,7 +94,8 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
currentSlot: AugmentedQuery<ApiType, () => Observable<Slot>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The configuration for the current epoch. Should never be `None` as it is initialized in genesis.
|
||||
* The configuration for the current epoch. Should never be `None` as it is initialized in
|
||||
* genesis.
|
||||
**/
|
||||
epochConfig: AugmentedQuery<ApiType, () => Observable<Option<BabeEpochConfiguration>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -916,9 +917,9 @@ declare module '@polkadot/api/types/storage' {
|
||||
**/
|
||||
canceledSlashPayout: AugmentedQuery<ApiType, () => Observable<BalanceOf>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The threshold for when users can start calling `chill_other` for other validators / nominators.
|
||||
* The threshold is compared to the actual number of validators / nominators (`CountFor*`) in
|
||||
* the system compared to the configured max (`Max*Count`).
|
||||
* The threshold for when users can start calling `chill_other` for other validators /
|
||||
* nominators. The threshold is compared to the actual number of validators / nominators
|
||||
* (`CountFor*`) in the system compared to the configured max (`Max*Count`).
|
||||
**/
|
||||
chillThreshold: AugmentedQuery<ApiType, () => Observable<Option<Percent>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -939,7 +940,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
/**
|
||||
* The last planned session scheduled by the session pallet.
|
||||
*
|
||||
* This is basically in sync with the call to [`SessionManager::new_session`].
|
||||
* This is basically in sync with the call to [`pallet_session::SessionManager::new_session`].
|
||||
**/
|
||||
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<SessionIndex>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -1145,6 +1146,9 @@ declare module '@polkadot/api/types/storage' {
|
||||
eventCount: AugmentedQuery<ApiType, () => Observable<EventIndex>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Events deposited for the current block.
|
||||
*
|
||||
* NOTE: This storage item is explicitly unbounded since it is never intended to be read
|
||||
* from within the runtime.
|
||||
**/
|
||||
events: AugmentedQuery<ApiType, () => Observable<Vec<EventRecord>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
@@ -1371,10 +1375,16 @@ declare module '@polkadot/api/types/storage' {
|
||||
[key: string]: QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
vesting: {
|
||||
/**
|
||||
* Storage version of the pallet.
|
||||
*
|
||||
* New networks start with latest version, as determined by the genesis build.
|
||||
**/
|
||||
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Information regarding the vesting of a given account.
|
||||
**/
|
||||
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<VestingInfo>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
vesting: AugmentedQuery<ApiType, (arg: AccountId | string | Uint8Array) => Observable<Option<Vec<VestingInfo>>>, [AccountId]> & QueryableStorageEntry<ApiType, [AccountId]>;
|
||||
/**
|
||||
* Generic query
|
||||
**/
|
||||
|
||||
+126
-93
@@ -211,8 +211,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `id`: The identifier of the new asset. This must not be currently in use to identify
|
||||
* an existing asset.
|
||||
* - `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`.
|
||||
* over this asset, but may later change and configure the permissions using
|
||||
* `transfer_ownership` and `set_team`.
|
||||
* - `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.
|
||||
*
|
||||
@@ -486,8 +486,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Exactly as `transfer`, except the origin must be root and the source account may be
|
||||
* specified.
|
||||
* # <weight>
|
||||
* - Same as transfer, but additional read and write because the source account is
|
||||
* not assumed to be in the overlay.
|
||||
* - Same as transfer, but additional read and write because the source account is not
|
||||
* assumed to be in the overlay.
|
||||
* # </weight>
|
||||
**/
|
||||
forceTransfer: AugmentedSubmittable<(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, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, Compact<Balance>]>;
|
||||
@@ -523,9 +523,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be `Signed` by the transactor.
|
||||
*
|
||||
* # <weight>
|
||||
* - Dependent on arguments but not critical, given proper implementations for
|
||||
* input config types. See related functions below.
|
||||
* - It contains a limited number of reads and writes internally and no complex computation.
|
||||
* - Dependent on arguments but not critical, given proper implementations for input config
|
||||
* types. See related functions below.
|
||||
* - It contains a limited number of reads and writes internally and no complex
|
||||
* computation.
|
||||
*
|
||||
* Related functions:
|
||||
*
|
||||
@@ -533,8 +534,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Transferring balances to accounts that did not exist before will cause
|
||||
* `T::OnNewAccount::on_new_account` to be called.
|
||||
* - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced`.
|
||||
* - `transfer_keep_alive` works the same way as `transfer`, but has an additional
|
||||
* check that the transfer will not kill the origin account.
|
||||
* - `transfer_keep_alive` works the same way as `transfer`, but has an additional check
|
||||
* that the transfer will not kill the origin account.
|
||||
* ---------------------------------
|
||||
* - Base Weight: 73.64 µs, worst case scenario (account created, account removed)
|
||||
* - DB Weight: 1 Read and 1 Write to destination account
|
||||
@@ -557,8 +558,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all
|
||||
* of the funds the account has, causing the sender account to be killed (false), or
|
||||
* transfer everything except at least the existential deposit, which will guarantee to
|
||||
* keep the sender account alive (true).
|
||||
* # <weight>
|
||||
* keep the sender account alive (true). # <weight>
|
||||
* - O(1). Just like transfer, but reading the user's transferable balance first.
|
||||
* #</weight>
|
||||
**/
|
||||
@@ -754,7 +754,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Instantiation is executed as follows:
|
||||
*
|
||||
* - The supplied `code` is instrumented, deployed, and a `code_hash` is created for that code.
|
||||
* - The supplied `code` is instrumented, deployed, and a `code_hash` is created for that
|
||||
* code.
|
||||
* - If the `code_hash` already exists on the chain the underlying `code` will be shared.
|
||||
* - The destination address is computed based on the sender, code_hash and the salt.
|
||||
* - The smart-contract account is created at the computed address.
|
||||
@@ -980,8 +981,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `to`: The account whose voting the `target` account's voting power will follow.
|
||||
* - `conviction`: The conviction that will be attached to the delegated votes. When the
|
||||
* account is undelegated, the funds will be locked for the corresponding period.
|
||||
* - `balance`: The amount of the account's balance to be used in delegating. This must
|
||||
* not be more than the account's current balance.
|
||||
* - `balance`: The amount of the account's balance to be used in delegating. This must not
|
||||
* be more than the account's current balance.
|
||||
*
|
||||
* Emits `Delegated`.
|
||||
*
|
||||
@@ -1118,8 +1119,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin of this call must be _Signed_.
|
||||
*
|
||||
* - `proposal_hash`: The preimage hash of a proposal.
|
||||
* - `proposal_length_upper_bound`: an upper bound on length of the proposal.
|
||||
* Extrinsic is weighted according to this value with no refund.
|
||||
* - `proposal_length_upper_bound`: an upper bound on length of the proposal. Extrinsic is
|
||||
* weighted according to this value with no refund.
|
||||
*
|
||||
* This will only work after `VotingPeriod` blocks from the time that the preimage was
|
||||
* noted, if it's the same account doing it. If it's a different account, then it'll only
|
||||
@@ -1280,7 +1281,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Queue size must be provided as witness data.
|
||||
* # </weight>
|
||||
**/
|
||||
submit: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, numSignedSubmissions: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, u32]>;
|
||||
submit: AugmentedSubmittable<(rawSolution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, numSignedSubmissions: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, u32]>;
|
||||
/**
|
||||
* Submit a solution for the unsigned phase.
|
||||
*
|
||||
@@ -1297,7 +1298,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* No deposit or reward is associated with this submission.
|
||||
**/
|
||||
submitUnsigned: AugmentedSubmittable<(solution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, witness: SolutionOrSnapshotSize | { voters?: any; targets?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, SolutionOrSnapshotSize]>;
|
||||
submitUnsigned: AugmentedSubmittable<(rawSolution: RawSolution | { compact?: any; score?: any; round?: any } | string | Uint8Array, witness: SolutionOrSnapshotSize | { voters?: any; targets?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [RawSolution, SolutionOrSnapshotSize]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -1352,8 +1353,9 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* origin is removed as a runner-up.
|
||||
* - `origin` is a current member. In this case, the deposit is unreserved and origin is
|
||||
* removed as a member, consequently not being a candidate for the next round anymore.
|
||||
* Similar to [`remove_members`], if replacement runners exists, they are immediately
|
||||
* used. If the prime is renouncing, then no prime will exist until the next round.
|
||||
* Similar to [`remove_member`](Self::remove_member), if replacement runners exists, they
|
||||
* are immediately used. If the prime is renouncing, then no prime will exist until the
|
||||
* next round.
|
||||
*
|
||||
* The dispatch origin of this call must be signed, and have one of the above roles.
|
||||
*
|
||||
@@ -1767,8 +1769,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
imOnline: {
|
||||
/**
|
||||
* # <weight>
|
||||
* - Complexity: `O(K + E)` where K is length of `Keys` (heartbeat.validators_len)
|
||||
* and E is length of `heartbeat.network_state.external_address`
|
||||
* - Complexity: `O(K + E)` where K is length of `Keys` (heartbeat.validators_len) and E is
|
||||
* length of `heartbeat.network_state.external_address`
|
||||
* - `O(K)`: decoding of length `K`
|
||||
* - `O(E)`: decoding/encoding of length `E`
|
||||
* - DbReads: pallet_session `Validators`, pallet_session `CurrentIndex`, `Keys`,
|
||||
@@ -1850,7 +1852,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
free: AugmentedSubmittable<(index: AccountIndex | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountIndex]>;
|
||||
/**
|
||||
* Freeze an index so it will always point to the sender account. This consumes the deposit.
|
||||
* Freeze an index so it will always point to the sender account. This consumes the
|
||||
* deposit.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the signing account must have a
|
||||
* non-frozen account `index`.
|
||||
@@ -1976,9 +1979,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Up to one binary search and insert (`O(logS + S)`).
|
||||
* - I/O: 1 read `O(S)`, up to 1 mutate `O(S)`. Up to one remove.
|
||||
* - One event.
|
||||
* - Storage: inserts one item, value size bounded by `MaxSignatories`, with a
|
||||
* deposit taken for its lifetime of
|
||||
* `DepositBase + threshold * DepositFactor`.
|
||||
* - Storage: inserts one item, value size bounded by `MaxSignatories`, with a deposit
|
||||
* taken for its lifetime of `DepositBase + threshold * DepositFactor`.
|
||||
* ----------------------------------
|
||||
* - DB Weight:
|
||||
* - Read: Multisig Storage, [Caller Account]
|
||||
@@ -2024,9 +2026,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - I/O: 1 read `O(S)`, up to 1 mutate `O(S)`. Up to one remove.
|
||||
* - One event.
|
||||
* - The weight of the `call`.
|
||||
* - Storage: inserts one item, value size bounded by `MaxSignatories`, with a
|
||||
* deposit taken for its lifetime of
|
||||
* `DepositBase + threshold * DepositFactor`.
|
||||
* - Storage: inserts one item, value size bounded by `MaxSignatories`, with a deposit
|
||||
* taken for its lifetime of `DepositBase + threshold * DepositFactor`.
|
||||
* -------------------------------
|
||||
* - DB Weight:
|
||||
* - Reads: Multisig Storage, [Caller Account], Calls (if `store_call`)
|
||||
@@ -2325,8 +2326,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* `threshold` or more vouches, waited `delay_period` blocks since initiation.
|
||||
*
|
||||
* Parameters:
|
||||
* - `account`: The lost account that you want to claim has been successfully
|
||||
* recovered by you.
|
||||
* - `account`: The lost account that you want to claim has been successfully recovered by
|
||||
* you.
|
||||
*
|
||||
* # <weight>
|
||||
* Key: F (len of friends in config), V (len of vouching friends)
|
||||
@@ -2373,13 +2374,13 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* Parameters:
|
||||
* - `friends`: A list of friends you trust to vouch for recovery attempts.
|
||||
* Should be ordered and contain no duplicate values.
|
||||
* - `threshold`: The number of friends that must vouch for a recovery attempt
|
||||
* before the account can be recovered. Should be less than or equal to
|
||||
* the length of the list of friends.
|
||||
* - `delay_period`: The number of blocks after a recovery attempt is initialized
|
||||
* that needs to pass before the account can be recovered.
|
||||
* - `friends`: A list of friends you trust to vouch for recovery attempts. Should be
|
||||
* ordered and contain no duplicate values.
|
||||
* - `threshold`: The number of friends that must vouch for a recovery attempt before the
|
||||
* account can be recovered. Should be less than or equal to the length of the list of
|
||||
* friends.
|
||||
* - `delay_period`: The number of blocks after a recovery attempt is initialized that
|
||||
* needs to pass before the account can be recovered.
|
||||
*
|
||||
* # <weight>
|
||||
* - Key: F (len of friends)
|
||||
@@ -2403,8 +2404,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* Parameters:
|
||||
* - `account`: The lost account that you want to recover. This account
|
||||
* needs to be recoverable (i.e. have a recovery configuration).
|
||||
* - `account`: The lost account that you want to recover. This account needs to be
|
||||
* recoverable (i.e. have a recovery configuration).
|
||||
*
|
||||
* # <weight>
|
||||
* - One storage read to check that account is recoverable. O(F)
|
||||
@@ -2467,8 +2468,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Parameters:
|
||||
* - `lost`: The lost account that you want to recover.
|
||||
* - `rescuer`: The account trying to rescue the lost account that you
|
||||
* want to vouch for.
|
||||
* - `rescuer`: The account trying to rescue the lost account that you want to vouch for.
|
||||
*
|
||||
* The combination of these two parameters must point to an active recovery
|
||||
* process.
|
||||
@@ -2556,7 +2556,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Schedule a named task after a delay.
|
||||
*
|
||||
* # <weight>
|
||||
* Same as [`schedule_named`].
|
||||
* Same as [`schedule_named`](Self::schedule_named).
|
||||
* # </weight>
|
||||
**/
|
||||
scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes, BlockNumber, Option<Period>, Priority, Call]>;
|
||||
@@ -2954,8 +2954,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin for this call must be _Signed_ by the stash, not the controller.
|
||||
*
|
||||
* Use this if there are additional funds in your stash account that you wish to bond.
|
||||
* Unlike [`bond`] or [`unbond`] this function does not impose any limitation on the amount
|
||||
* that can be added.
|
||||
* Unlike [`bond`](Self::bond) or [`unbond`](Self::unbond) this function does not impose
|
||||
* any limitation on the amount that can be added.
|
||||
*
|
||||
* Emits `Bonded`.
|
||||
*
|
||||
@@ -3017,7 +3017,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* This can be helpful if bond requirements are updated, and we need to remove old users
|
||||
* who do not satisfy these requirements.
|
||||
*
|
||||
**/
|
||||
chillOther: AugmentedSubmittable<(controller: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId]>;
|
||||
/**
|
||||
@@ -3082,8 +3081,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # <weight>
|
||||
* O(S) where S is the number of slashing spans to be removed
|
||||
* Reads: Bonded, Slashing Spans, Account, Locks
|
||||
* Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators, Account, Locks
|
||||
* Writes Each: SpanSlash * S
|
||||
* Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators,
|
||||
* Account, Locks Writes Each: SpanSlash * S
|
||||
* # </weight>
|
||||
**/
|
||||
forceUnstake: AugmentedSubmittable<(stash: AccountId | string | Uint8Array, numSlashingSpans: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId, u32]>;
|
||||
@@ -3093,7 +3092,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # <weight>
|
||||
* Same as [`set_validator_count`].
|
||||
* Same as [`Self::set_validator_count`].
|
||||
* # </weight>
|
||||
**/
|
||||
increaseValidatorCount: AugmentedSubmittable<(additional: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
|
||||
@@ -3162,7 +3161,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Complexity: O(S) where S is the number of slashing spans on the account.
|
||||
* DB Weight:
|
||||
* - Reads: Stash Account, Bonded, Slashing Spans, Locks
|
||||
* - Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators, Stash Account, Locks
|
||||
* - Writes: Bonded, Slashing Spans (if S > 0), Ledger, Payee, Validators, Nominators,
|
||||
* Stash Account, Locks
|
||||
* - Writes Each: SpanSlash * S
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -3185,7 +3185,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* The dispatch origin must be Root.
|
||||
*
|
||||
* # <weight>
|
||||
* Same as [`set_validator_count`].
|
||||
* Same as [`Self::set_validator_count`].
|
||||
* # </weight>
|
||||
**/
|
||||
scaleValidatorCount: AugmentedSubmittable<(factor: Percent | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Percent]>;
|
||||
@@ -3214,10 +3214,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* Parameters:
|
||||
* - `new_history_depth`: The new history depth you would like to set.
|
||||
* - `era_items_deleted`: The number of items that will be deleted by this dispatch.
|
||||
* This should report all the storage items that will be deleted by clearing old
|
||||
* era history. Needed to report an accurate weight for the dispatch. Trusted by
|
||||
* `Root` to report an accurate number.
|
||||
* - `era_items_deleted`: The number of items that will be deleted by this dispatch. This
|
||||
* should report all the storage items that will be deleted by clearing old era history.
|
||||
* Needed to report an accurate weight for the dispatch. Trusted by `Root` to report an
|
||||
* accurate number.
|
||||
*
|
||||
* Origin must be root.
|
||||
*
|
||||
@@ -3228,7 +3228,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Reads: Current Era, History Depth
|
||||
* - Writes: History Depth
|
||||
* - Clear Prefix Each: Era Stakers, EraStakersClipped, ErasValidatorPrefs
|
||||
* - Writes Each: ErasValidatorReward, ErasRewardPoints, ErasTotalStake, ErasStartSessionIndex
|
||||
* - Writes Each: ErasValidatorReward, ErasRewardPoints, ErasTotalStake,
|
||||
* ErasStartSessionIndex
|
||||
* # </weight>
|
||||
**/
|
||||
setHistoryDepth: AugmentedSubmittable<(newHistoryDepth: Compact<EraIndex> | AnyNumber | Uint8Array, eraItemsDeleted: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<EraIndex>, Compact<u32>]>;
|
||||
@@ -3267,10 +3268,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* * `min_nominator_bond`: The minimum active bond needed to be a nominator.
|
||||
* * `min_validator_bond`: The minimum active bond needed to be a validator.
|
||||
* * `max_nominator_count`: The max number of users who can be a nominator at once.
|
||||
* When set to `None`, no limit is enforced.
|
||||
* * `max_validator_count`: The max number of users who can be a validator at once.
|
||||
* When set to `None`, no limit is enforced.
|
||||
* * `max_nominator_count`: The max number of users who can be a nominator at once. When
|
||||
* set to `None`, no limit is enforced.
|
||||
* * `max_validator_count`: The max number of users who can be a validator at once. When
|
||||
* set to `None`, no limit is enforced.
|
||||
*
|
||||
* Origin must be Root to call this function.
|
||||
*
|
||||
@@ -3344,7 +3345,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
};
|
||||
sudo: {
|
||||
/**
|
||||
* Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo key.
|
||||
* Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo
|
||||
* key.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
@@ -3466,10 +3468,11 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # <weight>
|
||||
* - `O(C + S)` where `C` length of `code` and `S` complexity of `can_set_code`
|
||||
* - 1 storage write (codec `O(C)`).
|
||||
* - 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is expensive).
|
||||
* - 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is
|
||||
* expensive).
|
||||
* - 1 event.
|
||||
* The weight of this function is dependent on the runtime, but generally this is very expensive.
|
||||
* We will treat this as a full block.
|
||||
* The weight of this function is dependent on the runtime, but generally this is very
|
||||
* expensive. We will treat this as a full block.
|
||||
* # </weight>
|
||||
**/
|
||||
setCode: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
|
||||
@@ -3480,8 +3483,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - `O(C)` where `C` length of `code`
|
||||
* - 1 storage write (codec `O(C)`).
|
||||
* - 1 event.
|
||||
* The weight of this function is dependent on the runtime. We will treat this as a full block.
|
||||
* # </weight>
|
||||
* The weight of this function is dependent on the runtime. We will treat this as a full
|
||||
* block. # </weight>
|
||||
**/
|
||||
setCodeWithoutChecks: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
|
||||
/**
|
||||
@@ -3720,7 +3723,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`)
|
||||
* - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in `on_finalize`)
|
||||
* - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in
|
||||
* `on_finalize`)
|
||||
* - 1 event handler `on_timestamp_set`. Must be `O(1)`.
|
||||
* # </weight>
|
||||
**/
|
||||
@@ -3873,7 +3877,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* 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.
|
||||
* - 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>
|
||||
@@ -3890,9 +3895,9 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
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>
|
||||
* 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>
|
||||
@@ -4339,7 +4344,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* May be called from any origin.
|
||||
*
|
||||
* - `calls`: The calls to be dispatched from the same origin.
|
||||
* - `calls`: The calls to be dispatched from the same origin. The number of call must not
|
||||
* exceed the constant: `batched_calls_limit` (available in constant metadata).
|
||||
*
|
||||
* If origin is root then call are dispatch without checking origin filter. (This includes
|
||||
* bypassing `frame_system::Config::BaseCallFilter`).
|
||||
@@ -4361,7 +4367,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* May be called from any origin.
|
||||
*
|
||||
* - `calls`: The calls to be dispatched from the same origin.
|
||||
* - `calls`: The calls to be dispatched from the same origin. The number of call must not
|
||||
* exceed the constant: `batched_calls_limit` (available in constant metadata).
|
||||
*
|
||||
* If origin is root then call are dispatch without checking origin filter. (This includes
|
||||
* bypassing `frame_system::Config::BaseCallFilter`).
|
||||
@@ -4384,11 +4391,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* - `source`: The account whose funds should be transferred.
|
||||
* - `target`: The account that should be transferred the vested funds.
|
||||
* - `amount`: The amount of funds to transfer and will be vested.
|
||||
* - `schedule`: The vesting schedule attached to the transfer.
|
||||
*
|
||||
* Emits `VestingCreated`.
|
||||
*
|
||||
* NOTE: This will unlock all schedules through the current block.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)`.
|
||||
* - DbWeight: 4 Reads, 4 Writes
|
||||
@@ -4397,6 +4405,30 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, LookupSource, VestingInfo]>;
|
||||
/**
|
||||
* Merge two vesting schedules together, creating a new vesting schedule that unlocks over
|
||||
* the highest possible start and end blocks. If both schedules have already started the
|
||||
* current block will be used as the schedule start; with the caveat that if one schedule
|
||||
* is finished by the current block, the other will be treated as the new merged schedule,
|
||||
* unmodified.
|
||||
*
|
||||
* NOTE: If `schedule1_index == schedule2_index` this is a no-op.
|
||||
* NOTE: This will unlock all schedules through the current block prior to merging.
|
||||
* NOTE: If both schedules have ended by the current block, no new schedule will be created
|
||||
* and both will be removed.
|
||||
*
|
||||
* Merged schedule attributes:
|
||||
* - `starting_block`: `MAX(schedule1.starting_block, scheduled2.starting_block,
|
||||
* current_block)`.
|
||||
* - `ending_block`: `MAX(schedule1.ending_block, schedule2.ending_block)`.
|
||||
* - `locked`: `schedule1.locked_at(current_block) + schedule2.locked_at(current_block)`.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* - `schedule1_index`: index of the first schedule to merge.
|
||||
* - `schedule2_index`: index of the second schedule to merge.
|
||||
**/
|
||||
mergeSchedules: AugmentedSubmittable<(schedule1Index: u32 | AnyNumber | Uint8Array, schedule2Index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
|
||||
/**
|
||||
* Unlock any vested funds of the sender account.
|
||||
*
|
||||
@@ -4413,6 +4445,26 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vest: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Create a vested transfer.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* - `target`: The account receiving the vested funds.
|
||||
* - `schedule`: The vesting schedule attached to the transfer.
|
||||
*
|
||||
* Emits `VestingCreated`.
|
||||
*
|
||||
* NOTE: This will unlock all schedules through the current block.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)`.
|
||||
* - DbWeight: 3 Reads, 3 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||
* # </weight>
|
||||
**/
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>;
|
||||
/**
|
||||
* Unlock any vested funds of a `target` account.
|
||||
*
|
||||
@@ -4431,25 +4483,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||
/**
|
||||
* Create a vested transfer.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* - `target`: The account that should be transferred the vested funds.
|
||||
* - `amount`: The amount of funds to transfer and will be vested.
|
||||
* - `schedule`: The vesting schedule attached to the transfer.
|
||||
*
|
||||
* Emits `VestingCreated`.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)`.
|
||||
* - DbWeight: 3 Reads, 3 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
|
||||
* # </weight>
|
||||
**/
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource, VestingInfo]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, IMethod, InterfaceTypes, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { AnyFunction, AnyTuple, CallFunction, Codec, DefinitionRpc, DefinitionRpcSub, DetectCodec, IMethod, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||
import type { SubmittableExtrinsic } from '../submittable/types';
|
||||
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorage, QueryableStorageAt, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||
import type { VersionedRegistry } from './types';
|
||||
@@ -164,7 +164,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
/**
|
||||
* @description Creates an instance of a type as registered
|
||||
*/
|
||||
public createType <K extends keyof InterfaceTypes> (type: K, ...params: unknown[]): InterfaceTypes[K] {
|
||||
public createType <T extends Codec = Codec, K extends string = string> (type: K, ...params: unknown[]): DetectCodec<T, K> {
|
||||
return this.#registry.createType(type, ...params);
|
||||
}
|
||||
|
||||
@@ -189,12 +189,9 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
return this._rpcCore.provider.hasSubscriptions || !!this._rpcCore.state.queryStorageAt;
|
||||
}
|
||||
|
||||
protected _injectDecorated (registry: VersionedRegistry<ApiType>, fromEmpty?: boolean, blockHash?: Uint8Array): FullDecoration<ApiType> {
|
||||
const decoratedMeta = expandMetadata(registry.registry, registry.metadata);
|
||||
|
||||
// clear the decoration, we are redoing it here
|
||||
if (fromEmpty || !registry.decoration) {
|
||||
registry.decoration = {
|
||||
protected _createDecorated (registry: VersionedRegistry<ApiType>, fromEmpty?: boolean, blockHash?: Uint8Array | null, decoratedApi?: ApiDecoration<ApiType>): FullDecoration<ApiType> {
|
||||
if (!decoratedApi) {
|
||||
decoratedApi = {
|
||||
consts: {},
|
||||
errors: {},
|
||||
events: {},
|
||||
@@ -202,25 +199,39 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
} as ApiDecoration<ApiType>;
|
||||
}
|
||||
|
||||
if (!registry.decoratedMeta) {
|
||||
registry.decoratedMeta = expandMetadata(registry.registry, registry.metadata);
|
||||
}
|
||||
|
||||
// adjust the versioned registry
|
||||
augmentObject('consts', decoratedMeta.consts, registry.decoration.consts, fromEmpty);
|
||||
augmentObject('errors', decoratedMeta.errors, registry.decoration.errors, fromEmpty);
|
||||
augmentObject('events', decoratedMeta.events, registry.decoration.events, fromEmpty);
|
||||
augmentObject('consts', registry.decoratedMeta.consts, decoratedApi.consts, fromEmpty);
|
||||
augmentObject('errors', registry.decoratedMeta.errors, decoratedApi.errors, fromEmpty);
|
||||
augmentObject('events', registry.decoratedMeta.events, decoratedApi.events, fromEmpty);
|
||||
|
||||
const storage = blockHash
|
||||
? this._decorateStorageAt(decoratedMeta, this._decorateMethod, blockHash)
|
||||
: this._decorateStorage(decoratedMeta, this._decorateMethod);
|
||||
? this._decorateStorageAt(registry.decoratedMeta, this._decorateMethod, blockHash)
|
||||
: this._decorateStorage(registry.decoratedMeta, this._decorateMethod);
|
||||
|
||||
augmentObject('query', storage, registry.decoration.query, fromEmpty);
|
||||
augmentObject('query', storage, decoratedApi.query, fromEmpty);
|
||||
|
||||
return {
|
||||
decoratedApi: registry.decoration,
|
||||
decoratedMeta
|
||||
decoratedApi,
|
||||
decoratedMeta: registry.decoratedMeta
|
||||
};
|
||||
}
|
||||
|
||||
protected _injectMetadata (registry: VersionedRegistry<ApiType>, fromEmpty?: boolean): void {
|
||||
const { decoratedApi, decoratedMeta } = this._injectDecorated(registry, fromEmpty);
|
||||
// clear the decoration, we are redoing it here
|
||||
if (fromEmpty || !registry.decoratedApi) {
|
||||
registry.decoratedApi = {
|
||||
consts: {},
|
||||
errors: {},
|
||||
events: {},
|
||||
query: {}
|
||||
} as ApiDecoration<ApiType>;
|
||||
}
|
||||
|
||||
const { decoratedApi, decoratedMeta } = this._createDecorated(registry, fromEmpty, null, registry.decoratedApi);
|
||||
|
||||
this._consts = decoratedApi.consts;
|
||||
this._errors = decoratedApi.errors;
|
||||
@@ -245,7 +256,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
* backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
|
||||
*/
|
||||
public injectMetadata (metadata: Metadata, fromEmpty?: boolean, registry?: Registry): void {
|
||||
this._injectMetadata({ metadata, registry: registry || this.#registry, specVersion: BN_ZERO }, fromEmpty);
|
||||
this._injectMetadata({ metadata, registry: registry || this.#registry, specName: this.#registry.createType('Text'), specVersion: BN_ZERO }, fromEmpty);
|
||||
}
|
||||
|
||||
private _decorateFunctionMeta (input: MetaDecoration, output: MetaDecoration): MetaDecoration {
|
||||
@@ -368,7 +379,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
private _decorateExtrinsicEntry<ApiType extends ApiTypes> (method: CallFunction, creator: (value: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>): SubmittableExtrinsicFunction<ApiType> {
|
||||
const decorated = (...params: Arg[]): SubmittableExtrinsic<ApiType> =>
|
||||
const decorated = (...params: unknown[]): SubmittableExtrinsic<ApiType> =>
|
||||
creator(method(...params));
|
||||
|
||||
// pass through the `.is`
|
||||
@@ -405,7 +416,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
||||
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
|
||||
|
||||
// Disable this where it occurs for each field we are decorating
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||
@@ -414,17 +425,17 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
decorated.creator = creator;
|
||||
|
||||
decorated.at = decorateMethod((hash: Hash, ...args: Arg[]): Observable<Codec> =>
|
||||
decorated.at = decorateMethod((hash: Hash, ...args: unknown[]): Observable<Codec> =>
|
||||
this._rpcCore.state.getStorage(getArgs(args), hash));
|
||||
|
||||
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
|
||||
decorated.hash = decorateMethod((...args: unknown[]): Observable<Hash> =>
|
||||
this._rpcCore.state.getStorageHash(getArgs(args)));
|
||||
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section &&
|
||||
key.method === creator.method;
|
||||
|
||||
decorated.key = (...args: Arg[]): string =>
|
||||
decorated.key = (...args: unknown[]): string =>
|
||||
u8aToHex(compactStripLength(creator(
|
||||
creator.meta.type.isPlain
|
||||
? undefined
|
||||
@@ -435,27 +446,27 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
: args
|
||||
))[1]);
|
||||
|
||||
decorated.keyPrefix = (...keys: Arg[]): string =>
|
||||
decorated.keyPrefix = (...keys: unknown[]): string =>
|
||||
u8aToHex(creator.keyPrefix(...keys));
|
||||
|
||||
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: Arg[]): Observable<[Hash, Codec][]> =>
|
||||
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: unknown[]): Observable<[Hash, Codec][]> =>
|
||||
this._decorateStorageRange(decorated, args, range));
|
||||
|
||||
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
|
||||
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args)));
|
||||
|
||||
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<u64> =>
|
||||
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args), hash));
|
||||
|
||||
// FIXME NMap support
|
||||
// .keys() & .entries() only available on map types
|
||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
|
||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap || creator.meta.type.isNMap)) {
|
||||
decorated.entries = decorateMethod(
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
||||
memo(this.#instanceId, (...args: unknown[]): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, null, args)));
|
||||
|
||||
decorated.entriesAt = decorateMethod(
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, hash, args)));
|
||||
|
||||
decorated.entriesPaged = decorateMethod(
|
||||
@@ -463,11 +474,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
this._retrieveMapEntriesPaged(creator, opts)));
|
||||
|
||||
decorated.keys = decorateMethod(
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
|
||||
memo(this.#instanceId, (...args: unknown[]): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, null, args)));
|
||||
|
||||
decorated.keysAt = decorateMethod(
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<StorageKey[]> =>
|
||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, hash, args)));
|
||||
|
||||
decorated.keysPaged = decorateMethod(
|
||||
@@ -477,7 +488,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
if (this.supportMulti) {
|
||||
// When using double map storage function, user need to pass double map key as an array
|
||||
decorated.multi = decorateMethod((args: (Arg | Arg[])[]): Observable<Codec[]> =>
|
||||
decorated.multi = decorateMethod((args: (unknown | unknown[])[]): Observable<Codec[]> =>
|
||||
this._retrieveMulti(args.map((arg) => [creator, arg])));
|
||||
}
|
||||
|
||||
@@ -488,24 +499,24 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
private _decorateStorageEntryAt<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>, blockHash: Uint8Array): QueryableStorageEntryAt<ApiType> {
|
||||
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(creator, args);
|
||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
|
||||
|
||||
// Disable this where it occurs for each field we are decorating
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||
|
||||
const decorated = decorateMethod((...args: Arg[]): Observable<Codec> =>
|
||||
const decorated = decorateMethod((...args: unknown[]): Observable<Codec> =>
|
||||
this._rpcCore.state.getStorage(getArgs(args), blockHash));
|
||||
|
||||
decorated.creator = creator;
|
||||
|
||||
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
|
||||
decorated.hash = decorateMethod((...args: unknown[]): Observable<Hash> =>
|
||||
this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
|
||||
|
||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||
key.section === creator.section &&
|
||||
key.method === creator.method;
|
||||
|
||||
decorated.key = (...args: Arg[]): string =>
|
||||
decorated.key = (...args: unknown[]): string =>
|
||||
u8aToHex(compactStripLength(creator(
|
||||
creator.meta.type.isPlain
|
||||
? undefined
|
||||
@@ -516,21 +527,21 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
: args
|
||||
))[1]);
|
||||
|
||||
decorated.keyPrefix = (...keys: Arg[]): string =>
|
||||
decorated.keyPrefix = (...keys: unknown[]): string =>
|
||||
u8aToHex(creator.keyPrefix(...keys));
|
||||
|
||||
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
|
||||
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
|
||||
|
||||
// FIXME NMap support
|
||||
// .keys() & .entries() only available on map types
|
||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
|
||||
decorated.entries = decorateMethod(
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
||||
memo(this.#instanceId, (...args: unknown[]): Observable<[StorageKey, Codec][]> =>
|
||||
this._retrieveMapEntries(creator, blockHash, args)));
|
||||
|
||||
decorated.keys = decorateMethod(
|
||||
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
|
||||
memo(this.#instanceId, (...args: unknown[]): Observable<StorageKey[]> =>
|
||||
this._retrieveMapKeys(creator, blockHash, args)));
|
||||
}
|
||||
|
||||
@@ -542,21 +553,20 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
// Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
|
||||
// we make a subscription, alternatively we push this through a single-shot query
|
||||
private _decorateStorageCall<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return decorateMethod((...args: unknown[]): Observable<Codec> => {
|
||||
return this.hasSubscriptions
|
||||
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(creator, args)]).pipe(
|
||||
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(this.#registry, creator, args)]).pipe(
|
||||
map(([data]) => data) // extract first/only result from list
|
||||
)
|
||||
: this._rpcCore.state.getStorage(extractStorageArgs(creator, args));
|
||||
: this._rpcCore.state.getStorage(extractStorageArgs(this.#registry, creator, args));
|
||||
}, {
|
||||
methodName: creator.method,
|
||||
overrideNoSub: (...args: unknown[]) => this._rpcCore.state.getStorage(extractStorageArgs(creator, args))
|
||||
overrideNoSub: (...args: unknown[]) => this._rpcCore.state.getStorage(extractStorageArgs(this.#registry, creator, args))
|
||||
});
|
||||
}
|
||||
|
||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: Arg[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||
const outputType = unwrapStorageType(decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: unknown[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
||||
|
||||
return this._rpcCore.state
|
||||
.queryStorage<[Option<Raw>]>([decorated.key(...args)], ...range)
|
||||
@@ -569,7 +579,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
||||
private _retrieveMulti (keys: [StorageEntry, Arg | Arg[]][]): Observable<Codec[]> {
|
||||
private _retrieveMulti (keys: [StorageEntry, unknown | unknown[]][]): Observable<Codec[]> {
|
||||
if (!keys.length) {
|
||||
return of([]);
|
||||
}
|
||||
@@ -585,7 +595,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
);
|
||||
}
|
||||
|
||||
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<StorageKey[]> {
|
||||
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: unknown[]): Observable<StorageKey[]> {
|
||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
||||
|
||||
const headKey = iterKey(...args).toHex();
|
||||
@@ -619,7 +629,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
);
|
||||
}
|
||||
|
||||
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<[StorageKey, Codec][]> {
|
||||
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: unknown[]): Observable<[StorageKey, Codec][]> {
|
||||
const query = at
|
||||
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
|
||||
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
|
||||
|
||||
@@ -114,9 +114,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
const u8aHash = u8aToU8a(blockHash);
|
||||
const registry = await this.getBlockRegistry(u8aHash);
|
||||
|
||||
return registry.decoration
|
||||
? registry.decoration
|
||||
: this._injectDecorated(registry, true, u8aHash).decoratedApi;
|
||||
// always create a new decoration for this specific hash
|
||||
return this._createDecorated(registry, true, u8aHash).decoratedApi;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,8 +151,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
: await firstValueFrom((this._rpcCore.state.getRuntimeVersion as RpcInterfaceMethod).json(header.parentHash))
|
||||
);
|
||||
|
||||
// check for pre-existing registries
|
||||
const existingViaVersion = this.#registries.find(({ specVersion }) => specVersion.eq(version.specVersion));
|
||||
// check for pre-existing registries. We also check specName, e.g. it
|
||||
// could be changed like in Westmint with upgrade from shell -> westmint
|
||||
const existingViaVersion = this.#registries.find(({ specName, specVersion }) =>
|
||||
specName.eq(version.specName) &&
|
||||
specVersion.eq(version.specVersion)
|
||||
);
|
||||
|
||||
if (existingViaVersion) {
|
||||
existingViaVersion.lastBlockHash = blockHash;
|
||||
@@ -170,7 +173,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
this._initRegistry(registry, this._runtimeChain as Text, version, metadata);
|
||||
|
||||
// add our new registry
|
||||
const result = { lastBlockHash: blockHash, metadata, registry, specVersion: version.specVersion };
|
||||
const result = { lastBlockHash: blockHash, metadata, registry, specName: version.specName, specVersion: version.specVersion };
|
||||
|
||||
this.#registries.push(result);
|
||||
|
||||
@@ -301,7 +304,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// setup the initial registry, when we have none
|
||||
if (!this.#registries.length) {
|
||||
this.#registries.push({ isDefault: true, metadata, registry: this.registry, specVersion: runtimeVersion.specVersion });
|
||||
this.#registries.push({ isDefault: true, metadata, registry: this.registry, specName: runtimeVersion.specName, specVersion: runtimeVersion.specVersion });
|
||||
}
|
||||
|
||||
// get unique types & validate
|
||||
@@ -329,6 +332,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
return true;
|
||||
}
|
||||
|
||||
private _subscribeHealth (): void {
|
||||
// Only enable the health keepalive on WS, not needed on HTTP
|
||||
this.#healthTimer = this.hasSubscriptions
|
||||
? setInterval((): void => {
|
||||
firstValueFrom(this._rpcCore.system.health()).catch(() => undefined);
|
||||
}, KEEPALIVE_INTERVAL)
|
||||
: null;
|
||||
}
|
||||
|
||||
private _unsubscribeHealth (): void {
|
||||
if (this.#healthTimer) {
|
||||
clearInterval(this.#healthTimer);
|
||||
@@ -349,8 +361,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
}
|
||||
|
||||
#onProviderConnect = async (): Promise<void> => {
|
||||
this.emit('connected');
|
||||
this._isConnected.next(true);
|
||||
this.emit('connected');
|
||||
|
||||
try {
|
||||
const [hasMeta, cryptoReady] = await Promise.all([
|
||||
@@ -360,15 +372,13 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
: cryptoWaitReady()
|
||||
]);
|
||||
|
||||
this._subscribeHealth();
|
||||
|
||||
if (hasMeta && !this._isReady && cryptoReady) {
|
||||
this._isReady = true;
|
||||
|
||||
this.emit('ready', this);
|
||||
}
|
||||
|
||||
this.#healthTimer = setInterval((): void => {
|
||||
firstValueFrom(this._rpcCore.system.health()).catch(() => undefined);
|
||||
}, KEEPALIVE_INTERVAL);
|
||||
} catch (_error) {
|
||||
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
|
||||
|
||||
@@ -379,10 +389,9 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
}
|
||||
|
||||
#onProviderDisconnect = (): void => {
|
||||
this.emit('disconnected');
|
||||
this._isConnected.next(false);
|
||||
|
||||
this._unsubscribeHealth();
|
||||
this.emit('disconnected');
|
||||
};
|
||||
|
||||
#onProviderError = (error: Error): void => {
|
||||
|
||||
@@ -2,15 +2,19 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Metadata } from '@polkadot/types/metadata';
|
||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||
import type { Text } from '@polkadot/types/primitive';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { ApiDecoration, ApiTypes } from '../types';
|
||||
|
||||
export interface VersionedRegistry<ApiType extends ApiTypes> {
|
||||
decoration?: ApiDecoration<ApiType> | null;
|
||||
decoratedApi?: ApiDecoration<ApiType>;
|
||||
decoratedMeta?: DecoratedMeta;
|
||||
isDefault?: boolean;
|
||||
lastBlockHash?: Uint8Array | null;
|
||||
metadata: Metadata;
|
||||
registry: Registry;
|
||||
specName: Text;
|
||||
specVersion: BN;
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ function types (api: ApiPromise): void {
|
||||
}
|
||||
|
||||
async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
// transfer, also allows for BigInt inputs here
|
||||
// transfer, also allows for bigint inputs here
|
||||
const transfer = api.tx.balances.transfer(pairs.bob.address, 123456789n);
|
||||
|
||||
console.log('transfer casted', transfer as IMethod<AnyTuple>, transfer as IExtrinsic<AnyTuple>);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '5.8.2' };
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
|
||||
import type { AnyFunction, Callback, Codec } from '@polkadot/types/types';
|
||||
|
||||
export type Push<T extends readonly unknown[], V> = [...T, V]
|
||||
|
||||
@@ -57,9 +57,8 @@ export interface DecorateMethodOptions {
|
||||
|
||||
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
|
||||
|
||||
// FIXME We need a solution for NMap
|
||||
export interface PaginationOptions<ArgType = CodecArg> {
|
||||
args: ArgType[];
|
||||
export interface PaginationOptions<A = unknown> {
|
||||
args: A[];
|
||||
pageSize: number;
|
||||
startKey?: string;
|
||||
}
|
||||
|
||||
@@ -5,34 +5,34 @@ import type { Observable } from 'rxjs';
|
||||
import type { StorageKey, u64 } from '@polkadot/types';
|
||||
import type { Hash } from '@polkadot/types/interfaces';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { AnyFunction, AnyTuple, Callback, Codec, CodecArg, IStorageKey } from '@polkadot/types/types';
|
||||
import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from '@polkadot/types/types';
|
||||
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
|
||||
|
||||
interface StorageEntryObservableMulti {
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
|
||||
<T extends Codec>(args: (unknown[] | unknown)[]): Observable<T[]>;
|
||||
}
|
||||
|
||||
interface StorageEntryPromiseMulti {
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Promise<T[]>;
|
||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[], callback: Callback<T[]>): UnsubscribePromise;
|
||||
<T extends Codec>(args: (unknown[] | unknown)[]): Promise<T[]>;
|
||||
<T extends Codec>(args: (unknown[] | unknown)[], callback: Callback<T[]>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloads {
|
||||
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
|
||||
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
|
||||
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, arg3: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: unknown, arg2: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||
<T extends Codec>(arg1: unknown, arg2: unknown, arg3: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||
}
|
||||
|
||||
export interface StorageEntryPromiseOverloadsAt {
|
||||
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
|
||||
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
|
||||
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
|
||||
}
|
||||
|
||||
// This is the most generic typings we can have for a storage entry function
|
||||
type GenericStorageEntryFunction = (...args: CodecArg[]) => Observable<Codec>
|
||||
type GenericStorageEntryFunction = (...args: unknown[]) => Observable<Codec>
|
||||
|
||||
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||
ApiType extends 'rxjs'
|
||||
@@ -92,7 +92,7 @@ export interface QueryableModuleStorageAt<ApiType extends ApiTypes> {
|
||||
|
||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||
QueryableStorageEntry<ApiType> |
|
||||
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
|
||||
[QueryableStorageEntry<ApiType>, ...unknown[]];
|
||||
|
||||
export interface QueryableStorageMultiBase<ApiType extends ApiTypes> {
|
||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { Storage } from '@polkadot/types/metadata/decorate/types';
|
||||
|
||||
import { decorateStorage, Metadata, TypeRegistry } from '@polkadot/types';
|
||||
import metaStatic from '@polkadot/types/metadata/static';
|
||||
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
import { extractStorageArgs } from './validate';
|
||||
|
||||
@@ -20,79 +20,79 @@ describe('extractStorageArgs', (): void => {
|
||||
|
||||
it('validates no-arg plain', (): void => {
|
||||
expect(
|
||||
extractStorageArgs(storage.timestamp.now, [])
|
||||
extractStorageArgs(registry, storage.timestamp.now, [])
|
||||
).toEqual([storage.timestamp.now]);
|
||||
});
|
||||
|
||||
it('validates no-arg plain (with undefined, undefined)', (): void => {
|
||||
expect(
|
||||
extractStorageArgs(storage.timestamp.now, [undefined, undefined])
|
||||
extractStorageArgs(registry, storage.timestamp.now, [undefined, undefined])
|
||||
).toEqual([storage.timestamp.now]);
|
||||
});
|
||||
|
||||
it('validates no-arg plain (failing when there are args)', (): void => {
|
||||
expect(
|
||||
(): unknown => extractStorageArgs(storage.timestamp.now, [123, 456])
|
||||
(): unknown => extractStorageArgs(registry, storage.timestamp.now, [123, 456])
|
||||
).toThrow('timestamp.now() does not take any arguments, 2 found');
|
||||
});
|
||||
|
||||
it('validates map, 1 arg', (): void => {
|
||||
expect(
|
||||
extractStorageArgs(storage.staking.payee, ['abc'])
|
||||
extractStorageArgs(registry, storage.staking.payee, ['abc'])
|
||||
).toEqual([storage.staking.payee, 'abc']);
|
||||
});
|
||||
|
||||
it('validates map, 1 arg (failing with no args)', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.payee, [])
|
||||
extractStorageArgs(registry, storage.staking.payee, [])
|
||||
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 0 found');
|
||||
});
|
||||
|
||||
it('validates map, 1 arg (failing with no args)', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.payee, ['abc', 'def'])
|
||||
extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
|
||||
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 2 found');
|
||||
});
|
||||
|
||||
it('validates doublemap, 2 args', (): void => {
|
||||
expect(
|
||||
extractStorageArgs(storage.staking.erasStakers, [1, '0x1234'])
|
||||
extractStorageArgs(registry, storage.staking.erasStakers, [1, '0x1234'])
|
||||
).toEqual([storage.staking.erasStakers, [1, '0x1234']]);
|
||||
});
|
||||
|
||||
it('validates doublemap, 2 args (failing with no args)', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.erasStakers, [])
|
||||
extractStorageArgs(registry, storage.staking.erasStakers, [])
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
|
||||
});
|
||||
|
||||
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
|
||||
expect(
|
||||
(): any =>
|
||||
extractStorageArgs(storage.staking.erasStakers, [123])
|
||||
extractStorageArgs(registry, storage.staking.erasStakers, [123])
|
||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
|
||||
});
|
||||
|
||||
// Linked maps have been removed
|
||||
it.skip('validates linked map, no args', (): void => {
|
||||
expect(
|
||||
extractStorageArgs(storage.staking.validators, [])
|
||||
extractStorageArgs(registry, storage.staking.validators, [])
|
||||
).toEqual([storage.staking.validators]);
|
||||
});
|
||||
|
||||
it.skip('validates linked map, single arg', (): void => {
|
||||
expect(
|
||||
extractStorageArgs(storage.staking.validators, [123])
|
||||
extractStorageArgs(registry, storage.staking.validators, [123])
|
||||
).toEqual([storage.staking.validators, 123]);
|
||||
});
|
||||
|
||||
it.skip('validates linked map (failing with extra args)', (): void => {
|
||||
expect(
|
||||
(): any[] =>
|
||||
extractStorageArgs(storage.staking.validators, [123, 456])
|
||||
extractStorageArgs(registry, storage.staking.validators, [123, 456])
|
||||
).toThrow('staking.validators(AccountId) is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, 2 found');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,26 +3,27 @@
|
||||
|
||||
import type { Type } from '@polkadot/types';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
function sig ({ method, section }: StorageEntry, args: Type[]): string {
|
||||
function sig (_: Registry, { method, section }: StorageEntry, args: Type[]): string {
|
||||
return `${section}.${method}(${args.join(', ')})`;
|
||||
}
|
||||
|
||||
function doDoubleMap (creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
|
||||
function doDoubleMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
|
||||
const { key1, key2 } = creator.meta.type.asDoubleMap;
|
||||
|
||||
assert(args.length === 2, () => `${sig(creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
|
||||
assert(args.length === 2, () => `${sig(registry, creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
|
||||
|
||||
// pass as tuple
|
||||
return [creator, args as [any, any]];
|
||||
}
|
||||
|
||||
function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
|
||||
function doMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
|
||||
const { key } = creator.meta.type.asMap;
|
||||
|
||||
assert(args.length === 1, () => `${sig(creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
|
||||
assert(args.length === 1, () => `${sig(registry, creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
|
||||
|
||||
// expand
|
||||
return args.length
|
||||
@@ -30,10 +31,10 @@ function doMap (creator: StorageEntry, args: unknown[]): [StorageEntry] | [Stora
|
||||
: [creator];
|
||||
}
|
||||
|
||||
function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
|
||||
function doNMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
|
||||
const { keyVec } = creator.meta.type.asNMap;
|
||||
|
||||
assert(args.length === keyVec.length, () => `${sig(creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
|
||||
assert(args.length === keyVec.length, () => `${sig(registry, creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
|
||||
|
||||
// pass as tuple
|
||||
return [creator, args];
|
||||
@@ -41,18 +42,18 @@ function doNMap (creator: StorageEntry, args: unknown[]): [StorageEntry, any[]]
|
||||
|
||||
// sets up the arguments in the form of [creator, args] ready to be used in a storage
|
||||
// call. Additionally, it verifies that the correct number of arguments have been passed
|
||||
export function extractStorageArgs (creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
|
||||
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
|
||||
const args = _args.filter((arg) => !isUndefined(arg));
|
||||
|
||||
if (creator.meta.type.isDoubleMap) {
|
||||
return doDoubleMap(creator, args);
|
||||
return doDoubleMap(registry, creator, args);
|
||||
} else if (creator.meta.type.isMap) {
|
||||
return doMap(creator, args);
|
||||
return doMap(registry, creator, args);
|
||||
} else if (creator.meta.type.isNMap) {
|
||||
return doNMap(creator, args);
|
||||
return doNMap(registry, creator, args);
|
||||
}
|
||||
|
||||
assert(args.length === 0, () => `${sig(creator, [])} does not take any arguments, ${args.length} found`);
|
||||
assert(args.length === 0, () => `${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
|
||||
|
||||
// no args
|
||||
return [creator];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
@@ -19,13 +19,13 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/rpc-provider": "5.1.1",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/rpc-provider": "5.8.2",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.0.2"
|
||||
"@polkadot/keyring": "^7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { RpcInterface, RpcInterfaceMethod } from './types';
|
||||
|
||||
import { Observable, publishReplay, refCount } from 'rxjs';
|
||||
|
||||
import { createClass, createTypeUnsafe, Option, rpcDefinitions } from '@polkadot/types';
|
||||
import { rpcDefinitions } from '@polkadot/types';
|
||||
import { assert, hexToU8a, isFunction, isNull, isUndefined, logger, memoize, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { drr, refCountDelay } from './util';
|
||||
@@ -305,7 +305,7 @@ export class RpcCore {
|
||||
|
||||
subscriptionPromise = this._createSubscriber({ paramsJson, subName, subType, update }, errorHandler);
|
||||
} catch (error) {
|
||||
errorHandler(error);
|
||||
errorHandler(error as Error);
|
||||
}
|
||||
|
||||
// Teardown logic
|
||||
@@ -339,7 +339,7 @@ export class RpcCore {
|
||||
assert(inputs.length >= reqArgCount && inputs.length <= def.params.length, () => `Expected ${def.params.length} parameters${optText}, ${inputs.length} found instead`);
|
||||
|
||||
return inputs.map((input, index): Codec =>
|
||||
createTypeUnsafe(registry, def.params[index].type, [input], { blockHash })
|
||||
registry.createTypeUnsafe(def.params[index].type, [input], { blockHash })
|
||||
);
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ export class RpcCore {
|
||||
: mapped as unknown as Codec[];
|
||||
}
|
||||
|
||||
return createTypeUnsafe(registry, rpc.type, [result], { blockHash });
|
||||
return registry.createTypeUnsafe(rpc.type, [result], { blockHash });
|
||||
}
|
||||
|
||||
private _formatStorageData (registry: Registry, blockHash: Uint8Array | string | null | undefined, key: StorageKey, value: string | null): Codec {
|
||||
@@ -432,29 +432,15 @@ export class RpcCore {
|
||||
: ` entry ${entryIndex}:`;
|
||||
|
||||
try {
|
||||
if (meta.modifier.isOptional) {
|
||||
let inner = null;
|
||||
|
||||
if (!isEmpty) {
|
||||
inner = createTypeUnsafe(registry, type, [input], { blockHash, isPedantic: true });
|
||||
}
|
||||
|
||||
const option = new Option(registry, createClass(registry, type), inner);
|
||||
|
||||
if (blockHash) {
|
||||
option.createdAtHash = registry.createType('Hash', blockHash);
|
||||
}
|
||||
|
||||
return option;
|
||||
}
|
||||
|
||||
return createTypeUnsafe(registry, type, [
|
||||
return registry.createTypeUnsafe(type, [
|
||||
isEmpty
|
||||
? meta.fallback
|
||||
? hexToU8a(meta.fallback.toHex())
|
||||
: undefined
|
||||
: input
|
||||
], { blockHash, isPedantic: true });
|
||||
: meta.modifier.isOptional
|
||||
? registry.createTypeUnsafe(type, [input], { blockHash, isPedantic: true })
|
||||
: input
|
||||
], { blockHash, isOptional: meta.modifier.isOptional, isPedantic: !meta.modifier.isOptional });
|
||||
} catch (error) {
|
||||
throw new Error(`Unable to decode storage ${key.section || 'unknown'}.${key.method || 'unknown'}:${entryNum}: ${(error as Error).message}`);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.8.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
@@ -19,19 +19,19 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2",
|
||||
"@polkadot/util-crypto": "^7.0.2",
|
||||
"@polkadot/x-fetch": "^7.0.2",
|
||||
"@polkadot/x-global": "^7.0.2",
|
||||
"@polkadot/x-ws": "^7.0.2",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1",
|
||||
"@polkadot/util-crypto": "^7.3.1",
|
||||
"@polkadot/x-fetch": "^7.3.1",
|
||||
"@polkadot/x-global": "^7.3.1",
|
||||
"@polkadot/x-ws": "^7.3.1",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.0.2",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/keyring": "^7.3.1",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.1.1"
|
||||
"nock": "^13.1.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ import EventEmitter from 'eventemitter3';
|
||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||
import { decorateStorage, Metadata } from '@polkadot/types';
|
||||
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
||||
import rpcHeader from '@polkadot/types/json/Header.004.json';
|
||||
import rpcSignedBlock from '@polkadot/types/json/SignedBlock.004.immortal.json';
|
||||
import rpcMetadata from '@polkadot/types/metadata/static';
|
||||
import rpcHeader from '@polkadot/types-support/json/Header.004.json';
|
||||
import rpcSignedBlock from '@polkadot/types-support/json/SignedBlock.004.immortal.json';
|
||||
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||
import { assert, BN, bnToU8a, logger, u8aToHex } 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/rpc-provider', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.8.2' };
|
||||
|
||||
@@ -418,7 +418,7 @@ export class WsProvider implements ProviderInterface {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
handler.callback(error, undefined);
|
||||
handler.callback(error as Error, undefined);
|
||||
}
|
||||
|
||||
delete this.#handlers[response.id];
|
||||
@@ -446,7 +446,7 @@ export class WsProvider implements ProviderInterface {
|
||||
|
||||
handler.callback(null, result);
|
||||
} catch (error) {
|
||||
handler.callback(error, undefined);
|
||||
handler.callback(error as Error, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ interface ReplyDef {
|
||||
};
|
||||
}
|
||||
|
||||
global.WebSocket = WebSocket;
|
||||
global.WebSocket = WebSocket as typeof global.WebSocket;
|
||||
|
||||
export const TEST_WS_URL = 'ws://localhost:9955';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
@@ -26,19 +26,20 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.14.6",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/api": "5.1.1",
|
||||
"@polkadot/rpc-provider": "5.1.1",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2",
|
||||
"@babel/core": "^7.15.5",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/api": "5.8.2",
|
||||
"@polkadot/rpc-provider": "5.8.2",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/types-support": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.0.1"
|
||||
"yargs": "^17.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.3",
|
||||
"@types/websocket": "^1.0.4",
|
||||
"@types/yargs": "^17.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ try {
|
||||
'^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1',
|
||||
'^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1',
|
||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -17,6 +17,7 @@ try {
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -18,6 +18,7 @@ try {
|
||||
alias: {
|
||||
'^@polkadot/typegen(.*)': './packages/typegen/src\\1',
|
||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -17,6 +17,7 @@ try {
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -17,6 +17,7 @@ try {
|
||||
['module-resolver', {
|
||||
alias: {
|
||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||
}
|
||||
}]
|
||||
|
||||
@@ -24,7 +24,6 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
}, {});
|
||||
|
||||
const modules = meta.asLatest.modules
|
||||
.sort(compareName)
|
||||
.filter((mod) => mod.constants.length > 0)
|
||||
.map(({ constants, name }) => {
|
||||
if (!isStrict) {
|
||||
@@ -32,9 +31,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
}
|
||||
|
||||
const items = constants
|
||||
.sort(compareName)
|
||||
.map(({ docs, name, type }) => {
|
||||
const returnType = formatType(allDefs, type.toString(), imports);
|
||||
const returnType = formatType(meta.registry, allDefs, type.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [returnType]);
|
||||
|
||||
@@ -43,31 +41,31 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
name: stringCamelCase(name),
|
||||
type: returnType
|
||||
};
|
||||
});
|
||||
})
|
||||
.sort(compareName);
|
||||
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
});
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
];
|
||||
})
|
||||
.sort(compareName);
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,31 +19,29 @@ function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void
|
||||
const imports = createImports({});
|
||||
|
||||
const modules = meta.asLatest.modules
|
||||
.sort(compareName)
|
||||
.filter((mod) => mod.errors.length > 0)
|
||||
.map(({ errors, name }) => ({
|
||||
items: errors
|
||||
.sort(compareName)
|
||||
.map(({ docs, name }) => ({
|
||||
docs,
|
||||
name: name.toString()
|
||||
})),
|
||||
}))
|
||||
.sort(compareName),
|
||||
name: stringCamelCase(name)
|
||||
}));
|
||||
|
||||
const types = [
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
];
|
||||
}))
|
||||
.sort(compareName);
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
types: [
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,14 +24,13 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
}, {});
|
||||
|
||||
const modules = meta.asLatest.modules
|
||||
.sort(compareName)
|
||||
.filter((mod) => mod.events.isSome)
|
||||
.map(({ events, name }) => ({
|
||||
items: events
|
||||
.unwrap()
|
||||
.sort(compareName)
|
||||
.map(({ args, docs, name }) => {
|
||||
const types = args.map((type) => formatType(allDefs, type.toString(), imports));
|
||||
const types = args.map((type) => formatType(meta.registry, allDefs, type.toString(), imports));
|
||||
|
||||
setImports(allDefs, imports, types);
|
||||
|
||||
@@ -40,27 +39,26 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
name: name.toString(),
|
||||
type: types.join(', ')
|
||||
};
|
||||
}),
|
||||
}).sort(compareName),
|
||||
name: stringCamelCase(name)
|
||||
}));
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
];
|
||||
}))
|
||||
.sort(compareName);
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||
import * as defaultPrimitives from '@polkadot/types/primitive';
|
||||
|
||||
import { createImports, getDerivedTypes, readTemplate, setImports, writeFile } from '../util';
|
||||
import { createImports, readTemplate, setImports, writeFile } from '../util';
|
||||
import { ModuleTypes } from '../util/imports';
|
||||
|
||||
const primitiveClasses = {
|
||||
@@ -35,10 +35,10 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
||||
Object
|
||||
.keys(primitiveClasses)
|
||||
.filter((name) => !name.includes('Generic'))
|
||||
.forEach((primitiveName) => {
|
||||
.forEach((primitiveName): void => {
|
||||
setImports(definitions, imports, [primitiveName]);
|
||||
|
||||
items.push(...getDerivedTypes(registry, definitions, primitiveName, primitiveName, imports));
|
||||
items.push(primitiveName);
|
||||
});
|
||||
|
||||
const existingTypes: Record<string, boolean> = {};
|
||||
@@ -55,25 +55,23 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
||||
|
||||
const uniqueTypes = Object.keys(types).filter((type) => !existingTypes[type]);
|
||||
|
||||
uniqueTypes.forEach((type) => {
|
||||
uniqueTypes.forEach((type): void => {
|
||||
existingTypes[type] = true;
|
||||
|
||||
items.push(...getDerivedTypes(registry, definitions, type, types[type] as string, imports));
|
||||
items.push(type);
|
||||
});
|
||||
});
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
];
|
||||
|
||||
return generateInterfaceTypesTemplate({
|
||||
headerType: 'defs',
|
||||
imports,
|
||||
items: items.sort((a, b) => a.localeCompare(b)),
|
||||
types
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,12 +18,12 @@ import { ModuleTypes } from '../util/imports';
|
||||
// From a storage entry metadata, we return [args, returnType]
|
||||
/** @internal */
|
||||
function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [string, string, string] {
|
||||
const outputType = unwrapStorageType(storageEntry.type, storageEntry.modifier.isOptional);
|
||||
const outputType = unwrapStorageType(registry, storageEntry.type, storageEntry.modifier.isOptional);
|
||||
|
||||
if (storageEntry.type.isPlain) {
|
||||
setImports(allDefs, imports, [storageEntry.type.asPlain.toString()]);
|
||||
|
||||
return ['', '', formatType(allDefs, outputType, imports)];
|
||||
return ['', '', formatType(registry, allDefs, outputType, imports)];
|
||||
} else if (storageEntry.type.isMap) {
|
||||
const map = storageEntry.type.asMap;
|
||||
|
||||
@@ -36,9 +36,9 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
]);
|
||||
|
||||
return [
|
||||
formatType(allDefs, map.key.toString(), imports),
|
||||
formatType(registry, allDefs, map.key.toString(), imports),
|
||||
`arg: ${similarTypes.join(' | ')}`,
|
||||
formatType(allDefs, outputType, imports)
|
||||
formatType(registry, allDefs, outputType, imports)
|
||||
];
|
||||
} else if (storageEntry.type.isDoubleMap) {
|
||||
const dm = storageEntry.type.asDoubleMap;
|
||||
@@ -57,9 +57,12 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
const key2Types = similarTypes2.join(' | ');
|
||||
|
||||
return [
|
||||
[formatType(allDefs, dm.key1.toString(), imports), formatType(allDefs, dm.key2.toString(), imports)].join(', '),
|
||||
[
|
||||
formatType(registry, allDefs, dm.key1.toString(), imports),
|
||||
formatType(registry, allDefs, dm.key2.toString(), imports)
|
||||
].join(', '),
|
||||
`arg1: ${key1Types}, arg2: ${key2Types}`,
|
||||
formatType(allDefs, outputType, imports)
|
||||
formatType(registry, allDefs, outputType, imports)
|
||||
];
|
||||
} else if (storageEntry.type.isNMap) {
|
||||
const nmap = storageEntry.type.asNMap;
|
||||
@@ -75,9 +78,9 @@ function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registr
|
||||
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
||||
|
||||
return [
|
||||
nmap.keyVec.map((k) => formatType(allDefs, k.toString(), imports)).join(', '),
|
||||
nmap.keyVec.map((k) => formatType(registry, allDefs, k.toString(), imports)).join(', '),
|
||||
keyTypes.map((t, i) => `arg${i + 1}: ${t}`).join(', '),
|
||||
formatType(allDefs, outputType, imports)
|
||||
formatType(registry, allDefs, outputType, imports)
|
||||
];
|
||||
}
|
||||
|
||||
@@ -101,7 +104,6 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
.filter((mod) => !mod.storage.isNone)
|
||||
.map(({ name, storage }) => {
|
||||
const items = storage.unwrap().items
|
||||
.sort(compareName)
|
||||
.map((storageEntry) => {
|
||||
const [args, params, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
|
||||
|
||||
@@ -113,33 +115,33 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
params,
|
||||
returnType
|
||||
};
|
||||
});
|
||||
})
|
||||
.sort(compareName);
|
||||
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
});
|
||||
})
|
||||
.sort(compareName);
|
||||
|
||||
imports.typesTypes.Observable = true;
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
];
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
|
||||
return `${param.name}${param.isOptional ? '?' : ''}: ${similarTypes.join(' | ')}`;
|
||||
});
|
||||
|
||||
type = formatType(allDefs, def.type, imports);
|
||||
type = formatType(registry, allDefs, def.type, imports);
|
||||
generic = '';
|
||||
}
|
||||
|
||||
@@ -126,18 +126,16 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
|
||||
|
||||
imports.typesTypes.Observable = true;
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
];
|
||||
|
||||
return generateRpcTypesTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
modules,
|
||||
types
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
}))
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { TypeDef } from '@polkadot/types/create/types';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
import type { ModuleTypes } from '../util/imports';
|
||||
|
||||
import Handlebars from 'handlebars';
|
||||
import path from 'path';
|
||||
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import { getTypeDef, TypeRegistry } from '@polkadot/types/create';
|
||||
import { TypeDefInfo } from '@polkadot/types/create/types';
|
||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||
import { assert, isString, stringCamelCase, stringify, stringUpperFirst } from '@polkadot/util';
|
||||
@@ -28,13 +29,13 @@ export function createGetter (definitions: Record<string, ModuleTypes>, name = '
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function errorUnhandled (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
function errorUnhandled (_: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
throw new Error(`Generate: ${def.name || ''}: Unhandled type ${TypeDefInfo[def.info]}`);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsExport (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
return exportInterface(def.name, formatType(definitions, def, imports));
|
||||
function tsExport (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
return exportInterface(def.name, formatType(registry, definitions, def, imports));
|
||||
}
|
||||
|
||||
const tsBTreeMap = tsExport;
|
||||
@@ -47,16 +48,16 @@ const tsPlain = tsExport;
|
||||
const tsTuple = tsExport;
|
||||
|
||||
/** @internal */
|
||||
function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub }: TypeDef, imports: TypeImports): string {
|
||||
function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, { name: enumName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Enum']);
|
||||
|
||||
const keys = (sub as TypeDef[]).map((def, index): string => {
|
||||
const { info, name = `unknown${index}`, type } = def;
|
||||
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
|
||||
const isComplex = [TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||
const isComplex = [TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `as${getter}`, isComplex ? formatType(definitions, info === TypeDefInfo.Struct ? def : type, imports) : type, imports);
|
||||
: createGetter(definitions, `as${getter}`, isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports) : type, imports);
|
||||
const isGetter = info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
@@ -64,6 +65,7 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
|
||||
switch (info) {
|
||||
case TypeDefInfo.Compact:
|
||||
case TypeDefInfo.Plain:
|
||||
case TypeDefInfo.Result:
|
||||
case TypeDefInfo.Struct:
|
||||
case TypeDefInfo.Tuple:
|
||||
case TypeDefInfo.Vec:
|
||||
@@ -75,25 +77,25 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
|
||||
return '';
|
||||
|
||||
default:
|
||||
throw new Error(`Enum: ${enumName || 'undefined'}: Unhandled type ${TypeDefInfo[info]}`);
|
||||
throw new Error(`Enum: ${enumName || 'undefined'}: Unhandled nested "${TypeDefInfo[info]}" type`);
|
||||
}
|
||||
});
|
||||
|
||||
return exportInterface(enumName, 'Enum', keys.join(''));
|
||||
}
|
||||
|
||||
function tsInt (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports, type: 'Int' | 'UInt' = 'Int'): string {
|
||||
function tsInt (_: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports, type: 'Int' | 'UInt' = 'Int'): string {
|
||||
setImports(definitions, imports, [type]);
|
||||
|
||||
return exportInterface(def.name, type);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||
const { info, type } = def;
|
||||
const asGetter = type === 'Null'
|
||||
? ''
|
||||
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(definitions, def, imports) : type, imports);
|
||||
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports) : type, imports);
|
||||
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
|
||||
switch (info) {
|
||||
@@ -109,28 +111,28 @@ function tsResultGetter (definitions: Record<string, ModuleTypes>, resultName =
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsResult (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
function tsResult (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
||||
const inner = [
|
||||
tsResultGetter(definitions, def.name, 'Err', errorDef, imports),
|
||||
tsResultGetter(registry, definitions, def.name, 'Err', errorDef, imports),
|
||||
// @deprecated, use Err
|
||||
tsResultGetter(definitions, def.name, 'Error', errorDef, imports),
|
||||
tsResultGetter(definitions, def.name, 'Ok', okDef, imports)
|
||||
tsResultGetter(registry, definitions, def.name, 'Error', errorDef, imports),
|
||||
tsResultGetter(registry, definitions, def.name, 'Ok', okDef, imports)
|
||||
].join('');
|
||||
|
||||
setImports(definitions, imports, [def.type]);
|
||||
|
||||
return exportInterface(def.name, formatType(definitions, def, imports), inner);
|
||||
return exportInterface(def.name, formatType(registry, definitions, def, imports), inner);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function tsSi (definitions: Record<string, ModuleTypes>, { type }: TypeDef, imports: TypeImports): string {
|
||||
function tsSi (registry: Registry, definitions: Record<string, ModuleTypes>, { type }: TypeDef, imports: TypeImports): string {
|
||||
throw new Error('Unable to generate string definition from TypeDefInfo.Si');
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsSet (definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||
function tsSet (_: Registry, definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Set']);
|
||||
|
||||
const types = (sub as TypeDef[]).map(({ name }): string => {
|
||||
@@ -143,11 +145,11 @@ function tsSet (definitions: Record<string, ModuleTypes>, { name: setName, sub }
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsStruct (definitions: Record<string, ModuleTypes>, { name: structName, sub }: TypeDef, imports: TypeImports): string {
|
||||
function tsStruct (registry: Registry, definitions: Record<string, ModuleTypes>, { name: structName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Struct']);
|
||||
|
||||
const keys = (sub as TypeDef[]).map((typedef): string => {
|
||||
const returnType = formatType(definitions, typedef, imports);
|
||||
const returnType = formatType(registry, definitions, typedef, imports);
|
||||
|
||||
return createGetter(definitions, typedef.name, returnType, imports);
|
||||
});
|
||||
@@ -156,12 +158,12 @@ function tsStruct (definitions: Record<string, ModuleTypes>, { name: structName,
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsUInt (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
return tsInt(definitions, def, imports, 'UInt');
|
||||
function tsUInt (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
return tsInt(registry, definitions, def, imports, 'UInt');
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsVec (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
function tsVec (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||
const type = (def.sub as TypeDef).type;
|
||||
|
||||
if (def.info === TypeDefInfo.VecFixed && type === 'u8') {
|
||||
@@ -170,13 +172,13 @@ function tsVec (definitions: Record<string, ModuleTypes>, def: TypeDef, imports:
|
||||
return exportType(def.name, 'U8aFixed');
|
||||
}
|
||||
|
||||
return exportInterface(def.name, formatType(definitions, def, imports));
|
||||
return exportInterface(def.name, formatType(registry, definitions, def, imports));
|
||||
}
|
||||
|
||||
// handlers are defined externally to use - this means that when we do a
|
||||
// `generators[typedef.info](...)` TS will show any unhandled types. Rather
|
||||
// we are being explicit in having no handlers where we do not support (yet)
|
||||
const encoders: Record<TypeDefInfo, (definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string> = {
|
||||
const encoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string> = {
|
||||
[TypeDefInfo.BTreeMap]: tsBTreeMap,
|
||||
[TypeDefInfo.BTreeSet]: tsBTreeSet,
|
||||
[TypeDefInfo.Compact]: tsCompact,
|
||||
@@ -188,6 +190,7 @@ const encoders: Record<TypeDefInfo, (definitions: Record<string, ModuleTypes>, d
|
||||
[TypeDefInfo.Null]: errorUnhandled,
|
||||
[TypeDefInfo.Option]: tsOption,
|
||||
[TypeDefInfo.Plain]: tsPlain,
|
||||
[TypeDefInfo.Range]: errorUnhandled,
|
||||
[TypeDefInfo.Result]: tsResult,
|
||||
[TypeDefInfo.Set]: tsSet,
|
||||
[TypeDefInfo.Si]: tsSi,
|
||||
@@ -199,11 +202,11 @@ const encoders: Record<TypeDefInfo, (definitions: Record<string, ModuleTypes>, d
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
function generateInterfaces (definitions: Record<string, ModuleTypes>, { types }: { types: Record<string, any> }, imports: Imports): [string, string][] {
|
||||
function generateInterfaces (registry: Registry, definitions: Record<string, ModuleTypes>, { types }: { types: Record<string, any> }, imports: Imports): [string, string][] {
|
||||
return Object.entries(types).map(([name, type]): [string, string] => {
|
||||
const def = getTypeDef(isString(type) ? type : stringify(type), { name });
|
||||
|
||||
return [name, encoders[def.info](definitions, def, imports)];
|
||||
return [name, encoders[def.info](registry, definitions, def, imports)];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -217,10 +220,10 @@ const templateTypes = readTemplate('tsDef/types');
|
||||
const generateTsDefTypesTemplate = Handlebars.compile(templateTypes);
|
||||
|
||||
/** @internal */
|
||||
function generateTsDefFor (importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
|
||||
function generateTsDefFor (registry: Registry, importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
|
||||
const imports = { ...createImports(importDefinitions, { types }), interfaces: [] } as Imports;
|
||||
const definitions = imports.definitions;
|
||||
const interfaces = generateInterfaces(definitions, { types }, imports);
|
||||
const interfaces = generateInterfaces(registry, definitions, { types }, imports);
|
||||
const items = interfaces.sort((a, b): number => a[0].localeCompare(b[0])).map(([, definition]): string => definition);
|
||||
|
||||
const importTypes = [
|
||||
@@ -242,13 +245,15 @@ function generateTsDefFor (importDefinitions: { [importPath: string]: Record<str
|
||||
|
||||
/** @internal */
|
||||
export function generateTsDef (importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, outputDir: string, generatingPackage: string): void {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
writeFile(path.join(outputDir, 'types.ts'), (): string => {
|
||||
const definitions = importDefinitions[generatingPackage];
|
||||
|
||||
Object.entries(definitions).forEach(([defName, obj]): void => {
|
||||
console.log(`\tExtracting interfaces for ${defName}`);
|
||||
|
||||
generateTsDefFor(importDefinitions, defName, obj, outputDir);
|
||||
generateTsDefFor(registry, importDefinitions, defName, obj, outputDir);
|
||||
});
|
||||
|
||||
return generateTsDefTypesTemplate({
|
||||
|
||||
@@ -37,13 +37,11 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
}, {});
|
||||
|
||||
const modules = meta.asLatest.modules
|
||||
.sort(compareName)
|
||||
.filter(({ calls }) => calls.unwrapOr([]).length !== 0)
|
||||
.map(({ calls, name }) => {
|
||||
setImports(allDefs, imports, ['Call', 'Extrinsic', 'SubmittableExtrinsic']);
|
||||
|
||||
const items = calls.unwrap()
|
||||
.sort(compareName)
|
||||
.map(({ args, docs, name }) => {
|
||||
const params = args
|
||||
.map(({ name, type }) => {
|
||||
@@ -57,36 +55,36 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
||||
.join(', ');
|
||||
|
||||
return {
|
||||
args: args.map(({ type }) => formatType(allDefs, type.toString(), imports)).join(', '),
|
||||
args: args.map(({ type }) => formatType(registry, allDefs, type.toString(), imports)).join(', '),
|
||||
docs,
|
||||
name: stringCamelCase(name),
|
||||
params
|
||||
};
|
||||
});
|
||||
})
|
||||
.sort(compareName);
|
||||
|
||||
return {
|
||||
items,
|
||||
name: stringCamelCase(name)
|
||||
};
|
||||
});
|
||||
|
||||
const types = [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes', 'SubmittableExtrinsic']
|
||||
}
|
||||
];
|
||||
})
|
||||
.sort(compareName);
|
||||
|
||||
return generateForMetaTemplate({
|
||||
headerType: 'chain',
|
||||
imports,
|
||||
isStrict,
|
||||
modules,
|
||||
types
|
||||
types: [
|
||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||
file: packagePath,
|
||||
types: Object.keys(imports.localTypes[packagePath])
|
||||
})),
|
||||
{
|
||||
file: '@polkadot/api/types',
|
||||
types: ['ApiTypes', 'SubmittableExtrinsic']
|
||||
}
|
||||
]
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ import fs from 'fs';
|
||||
import { GenericCall as Call, Metadata, TypeRegistry, Vec } from '@polkadot/types';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
import { getStorage as getSubstrateStorage } from '@polkadot/types/metadata/decorate/storage/getStorage';
|
||||
import rpcdata from '@polkadot/types/metadata/static';
|
||||
import { Text } from '@polkadot/types/primitive';
|
||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||
import rpcdata from '@polkadot/types-support/metadata/static-substrate';
|
||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||
|
||||
interface SectionItem {
|
||||
@@ -211,7 +211,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
? ('`' + func.type.asNMap.keyVec.map((k) => k.toString()).join(', ') + '`')
|
||||
: '';
|
||||
const methodName = stringLowerFirst(func.name);
|
||||
const outputType = unwrapStorageType(func.type, func.modifier.isOptional);
|
||||
const outputType = unwrapStorageType(metadata.registry, func.type, func.modifier.isOptional);
|
||||
|
||||
return {
|
||||
interface: '`' + `api.query.${sectionName}.${methodName}` + '`',
|
||||
@@ -234,7 +234,7 @@ function addStorage (metadata: MetadataLatest): string {
|
||||
? ('`' + meta.type.asDoubleMap.key1.toString() + ', ' + meta.type.asDoubleMap.key2.toString() + '`')
|
||||
: '';
|
||||
const methodName = stringLowerFirst(name);
|
||||
const outputType = unwrapStorageType(meta.type, meta.modifier.isOptional);
|
||||
const outputType = unwrapStorageType(metadata.registry, meta.type, meta.modifier.isOptional);
|
||||
|
||||
return {
|
||||
interface: '`' + `api.query.substrate.${methodName}` + '`',
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.8.2' };
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
declare module '@polkadot/types/types/registry' {
|
||||
export interface InterfaceTypes {
|
||||
{{#each items}}
|
||||
{{{this}}}
|
||||
{{{this}}}: {{{this}}};
|
||||
{{/each}}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
|
||||
import { UInt } from '@polkadot/types/codec';
|
||||
import { isChildClass } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
export function isCompactEncodable (Child: Constructor<any>): boolean {
|
||||
return isChildClass(UInt, Child);
|
||||
}
|
||||
@@ -6,15 +6,13 @@ import type { Constructor, Registry } from '@polkadot/types/types';
|
||||
|
||||
import { Compact, Enum, Option, Struct, Tuple, UInt, Vec } from '@polkadot/types/codec';
|
||||
import { AbstractInt } from '@polkadot/types/codec/AbstractInt';
|
||||
import { ClassOfUnsafe, getTypeDef } from '@polkadot/types/create';
|
||||
import { getTypeDef } from '@polkadot/types/create';
|
||||
import { TypeDefInfo } from '@polkadot/types/create/types';
|
||||
import { GenericAccountId, GenericLookupSource, GenericVote } from '@polkadot/types/generic';
|
||||
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
|
||||
import { Null } from '@polkadot/types/primitive';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
import { bool, Null } from '@polkadot/types/primitive';
|
||||
import { isChildClass, stringify } from '@polkadot/util';
|
||||
|
||||
import { isCompactEncodable } from './class';
|
||||
import { formatType } from './formatting';
|
||||
import { ModuleTypes, setImports, TypeImports } from './imports';
|
||||
|
||||
@@ -24,43 +22,6 @@ function arrayToStrType (arr: string[]): string {
|
||||
|
||||
const voteConvictions = arrayToStrType(AllConvictions);
|
||||
|
||||
// From `T`, generate `Compact<T>, Option<T>, Vec<T>`
|
||||
/** @internal */
|
||||
export function getDerivedTypes (registry: Registry, definitions: Record<string, ModuleTypes>, type: string, primitiveName: string, imports: TypeImports): string[] {
|
||||
// `primitiveName` represents the actual primitive type our type is mapped to
|
||||
const isCompact = isCompactEncodable((primitiveClasses as Record<string, any>)[primitiveName] || ClassOfUnsafe(registry, type));
|
||||
const def = getTypeDef(type);
|
||||
|
||||
setImports(definitions, imports, ['Option', 'Vec', isCompact ? 'Compact' : '']);
|
||||
|
||||
const types = [
|
||||
{
|
||||
info: TypeDefInfo.Option,
|
||||
sub: def,
|
||||
type
|
||||
},
|
||||
{
|
||||
info: TypeDefInfo.Vec,
|
||||
sub: def,
|
||||
type
|
||||
}
|
||||
];
|
||||
|
||||
if (isCompact) {
|
||||
types.unshift({
|
||||
info: TypeDefInfo.Compact,
|
||||
sub: def,
|
||||
type
|
||||
});
|
||||
}
|
||||
|
||||
const result = types.map((t) => formatType(definitions, t, imports)).map((t) => `'${t}': ${t};`);
|
||||
|
||||
result.unshift(`${type}: ${type};`);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Make types a little bit more flexible
|
||||
// - if param instanceof AbstractInt, then param: u64 | Uint8array | AnyNumber
|
||||
// etc
|
||||
@@ -68,7 +29,7 @@ export function getDerivedTypes (registry: Registry, definitions: Record<string,
|
||||
export function getSimilarTypes (registry: Registry, definitions: Record<string, ModuleTypes>, _type: string, imports: TypeImports): string[] {
|
||||
const typeParts = _type.split('::');
|
||||
const type = typeParts[typeParts.length - 1];
|
||||
const possibleTypes = [formatType(definitions, type, imports)];
|
||||
const possibleTypes = [formatType(registry, definitions, type, imports)];
|
||||
|
||||
if (type === 'Extrinsic') {
|
||||
setImports(definitions, imports, ['IExtrinsic']);
|
||||
@@ -84,7 +45,7 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
|
||||
return ['null'];
|
||||
}
|
||||
|
||||
const Clazz = ClassOfUnsafe(registry, type);
|
||||
const Clazz = registry.createClass(type);
|
||||
|
||||
if (isChildClass(Vec, Clazz)) {
|
||||
const vecDef = getTypeDef(type);
|
||||
@@ -121,7 +82,7 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
|
||||
possibleTypes.push('Address', 'AccountId', 'AccountIndex', 'LookupSource', 'string', 'Uint8Array');
|
||||
} else if (isChildClass(GenericAccountId, Clazz)) {
|
||||
possibleTypes.push('string', 'Uint8Array');
|
||||
} else if (isChildClass(registry.createClass('bool'), Clazz)) {
|
||||
} else if (isChildClass(bool, Clazz)) {
|
||||
possibleTypes.push('boolean', 'Uint8Array');
|
||||
} else if (isChildClass(Null, Clazz)) {
|
||||
possibleTypes.push('null');
|
||||
|
||||
@@ -1,12 +1,16 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
import { formatType } from './formatting';
|
||||
|
||||
describe('formatType', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
it('handles nested Tuples', (): void => {
|
||||
expect(
|
||||
formatType({}, '(AccountId, (Balance, u32), u64)', {
|
||||
formatType(registry, {}, '(AccountId, (Balance, u32), u64)', {
|
||||
codecTypes: {},
|
||||
definitions: {},
|
||||
extrinsicTypes: {},
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
|
||||
import type { TypeDef } from '@polkadot/types/create/types';
|
||||
import type { Registry } from '@polkadot/types/types';
|
||||
|
||||
import Handlebars from 'handlebars';
|
||||
|
||||
@@ -83,100 +86,141 @@ export function exportType (name = '', base: string): string {
|
||||
return exportInterface(name, base);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the inner `K` & `V`, return a `BTreeMap<K, V>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatBTreeMap (key: string, val: string): string {
|
||||
return `BTreeMap<${key}, ${val}>`;
|
||||
}
|
||||
const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => string> = {
|
||||
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Compact']);
|
||||
|
||||
/**
|
||||
* Given the inner `V`, return a `BTreeSet<V>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatBTreeSet (val: string): string {
|
||||
return `BTreeSet<${val}>`;
|
||||
}
|
||||
const sub = typeDef.sub as TypeDef;
|
||||
|
||||
/**
|
||||
* Given the inner `T`, return a `Compact<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatCompact (inner: string): string {
|
||||
return paramsNotation('Compact', inner);
|
||||
}
|
||||
return paramsNotation('Compact', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
||||
},
|
||||
[TypeDefInfo.DoNotConstruct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['DoNotConstruct']);
|
||||
|
||||
/**
|
||||
* Simple return
|
||||
*/
|
||||
/** @internal */
|
||||
function formatDoNoConstruct (): string {
|
||||
return 'DoNotConstruct';
|
||||
}
|
||||
return 'DoNotConstruct';
|
||||
},
|
||||
[TypeDefInfo.Enum]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
if (typeDef.lookupName) {
|
||||
return typeDef.lookupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the inner `K` & `V`, return a `BTreeMap<K, V>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatHashMap (key: string, val: string): string {
|
||||
return `HashMap<${key}, ${val}>`;
|
||||
}
|
||||
throw new Error(`TypeDefInfo.Enum: Not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
[TypeDefInfo.Int]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.Int: Not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
[TypeDefInfo.UInt]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.UInt: Not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
[TypeDefInfo.Null]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Null']);
|
||||
|
||||
/**
|
||||
* Given the inner `T`, return a `Vec<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatLinkage (inner: string): string {
|
||||
return paramsNotation('Linkage', inner);
|
||||
}
|
||||
return 'Null';
|
||||
},
|
||||
[TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Option']);
|
||||
|
||||
/**
|
||||
* Given the inner `T`, return a `Option<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatOption (inner: string): string {
|
||||
return paramsNotation('Option', inner);
|
||||
}
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
|
||||
/**
|
||||
* Given the inner `O` & `E`, return a `Result<O, E>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatResult (innerOk: string, innerError: string): string {
|
||||
return `Result<${innerOk}, ${innerError}>`;
|
||||
}
|
||||
return paramsNotation('Option', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
||||
},
|
||||
[TypeDefInfo.Plain]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, [typeDef.type]);
|
||||
|
||||
/**
|
||||
* Given the entries `[string, T][]`, return a `{ name: T; ... }` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatStruct (inners: [string, string][]): string {
|
||||
return `{ ${inners.map(([k, t]) => `${k}: ${t};`).join(' ')} } & Struct`;
|
||||
}
|
||||
return typeDef.type;
|
||||
},
|
||||
[TypeDefInfo.Range]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.Range: Not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
[TypeDefInfo.Set]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
throw new Error(`TypeDefInfo.Set: Not implemented on ${stringify(typeDef)}`);
|
||||
},
|
||||
[TypeDefInfo.Si]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
return formatType(registry, definitions, registry.lookup.getTypeDef(typeDef.type), imports, withShortcut);
|
||||
},
|
||||
[TypeDefInfo.Struct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Struct']);
|
||||
|
||||
/**
|
||||
* Given the inners `T[]`, return a `ITuple<...T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatTuple (inners: string[]): string {
|
||||
return paramsNotation('ITuple', `[${inners.join(', ')}]`);
|
||||
}
|
||||
return `{${withShortcut ? ' ' : '\n'}${
|
||||
((typeDef.sub as TypeDef[]).map(({ lookupName, name, type }, index) => [
|
||||
name || `unknown${index}`,
|
||||
formatType(registry, definitions, lookupName || type, imports, withShortcut)
|
||||
])).map(([k, t]) => `${withShortcut ? '' : ' readonly '}${k}: ${t};`).join(withShortcut ? ' ' : '\n')
|
||||
}${withShortcut ? ' ' : '\n '}} & Struct`;
|
||||
},
|
||||
[TypeDefInfo.Tuple]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['ITuple']);
|
||||
|
||||
/**
|
||||
* Given the inner `T`, return a `Vec<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatVec (inner: string): string {
|
||||
return paramsNotation('Vec', inner);
|
||||
}
|
||||
// `(a,b)` gets transformed into `ITuple<[a, b]>`
|
||||
return paramsNotation('ITuple', `[${
|
||||
((typeDef.sub as TypeDef[]).map(({ lookupName, type }) =>
|
||||
formatType(registry, definitions, lookupName || type, imports, withShortcut)
|
||||
)).join(', ')
|
||||
}]`);
|
||||
},
|
||||
[TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Vec']);
|
||||
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
|
||||
return paramsNotation('Vec', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
||||
},
|
||||
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
|
||||
if (sub.type === 'u8') {
|
||||
setImports(definitions, imports, ['U8aFixed']);
|
||||
|
||||
return 'U8aFixed';
|
||||
}
|
||||
|
||||
setImports(definitions, imports, ['Vec']);
|
||||
|
||||
return paramsNotation('Vec', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
||||
},
|
||||
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['BTreeMap']);
|
||||
|
||||
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
||||
|
||||
return `BTreeMap<${formatType(registry, definitions, keyDef.lookupName || keyDef.type, imports, withShortcut)}, ${formatType(registry, definitions, valDef.lookupName || valDef.type, imports, withShortcut)}>`;
|
||||
},
|
||||
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['BTreeSet']);
|
||||
|
||||
const valDef = typeDef.sub as TypeDef;
|
||||
|
||||
return `BTreeSet<${formatType(registry, definitions, valDef.lookupName || valDef.type, imports, withShortcut)}>`;
|
||||
},
|
||||
[TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['HashMap']);
|
||||
|
||||
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
||||
|
||||
return `HashMap<${formatType(registry, definitions, keyDef.lookupName || keyDef.type, imports, withShortcut)}, ${formatType(registry, definitions, valDef.lookupName || valDef.type, imports, withShortcut)}>`;
|
||||
},
|
||||
[TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Linkage']);
|
||||
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
|
||||
return paramsNotation('Linkage', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
||||
},
|
||||
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||
setImports(definitions, imports, ['Result']);
|
||||
|
||||
const [okDef, errDef] = (typeDef.sub as TypeDef[]);
|
||||
|
||||
return `Result<${formatType(registry, definitions, okDef.lookupName || okDef.type, imports, withShortcut)}, ${formatType(registry, definitions, errDef.lookupName || errDef.type, imports, withShortcut)}>`;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Correctly format a given type
|
||||
*/
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function formatType (definitions: Record<string, ModuleTypes>, type: string | String | TypeDef, imports: TypeImports): string {
|
||||
export function formatType (registry: Registry, definitions: Record<string, ModuleTypes>, type: string | String | TypeDef, imports: TypeImports, withShortcut = false): string {
|
||||
let typeDef: TypeDef;
|
||||
|
||||
if (isString(type)) {
|
||||
@@ -184,7 +228,7 @@ export function formatType (definitions: Record<string, ModuleTypes>, type: stri
|
||||
|
||||
// If type is "unorthodox" (i.e. `{ something: any }` for an Enum input or `[a | b | c, d | e | f]` for a Tuple's similar types),
|
||||
// we return it as-is
|
||||
if (/(^{.+:.+})|^\([^,]+\)|^\(.+\)\[\]|^\[.+\]/.exec(_type) && !/\[\w+;\w+\]/.exec(_type)) {
|
||||
if (withShortcut && /(^{.+:.+})|^\([^,]+\)|^\(.+\)\[\]|^\[.+\]/.exec(_type) && !/\[\w+;\w+\]/.exec(_type)) {
|
||||
return _type;
|
||||
}
|
||||
|
||||
@@ -195,112 +239,5 @@ export function formatType (definitions: Record<string, ModuleTypes>, type: stri
|
||||
|
||||
setImports(definitions, imports, [typeDef.type]);
|
||||
|
||||
// FIXME Swap to Record<TypeDefInfo, fn> to check all types
|
||||
switch (typeDef.info) {
|
||||
case TypeDefInfo.Compact: {
|
||||
setImports(definitions, imports, ['Compact']);
|
||||
|
||||
return formatCompact(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.DoNotConstruct: {
|
||||
setImports(definitions, imports, ['DoNotConstruct']);
|
||||
|
||||
return formatDoNoConstruct();
|
||||
}
|
||||
|
||||
case TypeDefInfo.Option: {
|
||||
setImports(definitions, imports, ['Option']);
|
||||
|
||||
return formatOption(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.Plain: {
|
||||
return typeDef.type;
|
||||
}
|
||||
|
||||
case TypeDefInfo.Struct: {
|
||||
setImports(definitions, imports, ['Struct']);
|
||||
|
||||
return formatStruct(
|
||||
((typeDef.sub as TypeDef[]).map(({ name, type }, index) => [
|
||||
name || `unknown${index}`,
|
||||
formatType(definitions, type, imports)
|
||||
]))
|
||||
);
|
||||
}
|
||||
|
||||
case TypeDefInfo.Tuple: {
|
||||
setImports(definitions, imports, ['ITuple']);
|
||||
|
||||
// `(a,b)` gets transformed into `ITuple<[a, b]>`
|
||||
return formatTuple(
|
||||
((typeDef.sub as TypeDef[]).map(({ type }) => formatType(definitions, type, imports)))
|
||||
);
|
||||
}
|
||||
|
||||
case TypeDefInfo.Vec: {
|
||||
setImports(definitions, imports, ['Vec']);
|
||||
|
||||
return formatVec(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.VecFixed: {
|
||||
const type = (typeDef.sub as TypeDef).type;
|
||||
|
||||
if (type === 'u8') {
|
||||
setImports(definitions, imports, ['U8aFixed']);
|
||||
|
||||
return 'U8aFixed';
|
||||
}
|
||||
|
||||
setImports(definitions, imports, ['Vec']);
|
||||
|
||||
return formatVec(formatType(definitions, type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.BTreeMap: {
|
||||
setImports(definitions, imports, ['BTreeMap']);
|
||||
|
||||
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
||||
|
||||
return formatBTreeMap(formatType(definitions, keyDef.type, imports), formatType(definitions, valDef.type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.BTreeSet: {
|
||||
setImports(definitions, imports, ['BTreeSet']);
|
||||
|
||||
const valDef = typeDef.sub as TypeDef;
|
||||
|
||||
return formatBTreeSet(formatType(definitions, valDef.type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.HashMap: {
|
||||
setImports(definitions, imports, ['HashMap']);
|
||||
|
||||
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
||||
|
||||
return formatHashMap(formatType(definitions, keyDef.type, imports), formatType(definitions, valDef.type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.Linkage: {
|
||||
const type = (typeDef.sub as TypeDef).type;
|
||||
|
||||
setImports(definitions, imports, ['Linkage']);
|
||||
|
||||
return formatLinkage(formatType(definitions, type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.Result: {
|
||||
setImports(definitions, imports, ['Result']);
|
||||
|
||||
const [okDef, errorDef] = (typeDef.sub as TypeDef[]);
|
||||
|
||||
return formatResult(formatType(definitions, okDef.type, imports), formatType(definitions, errorDef.type, imports));
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new Error(`Cannot format ${stringify(type)}`);
|
||||
}
|
||||
}
|
||||
return formatters[typeDef.info](registry, typeDef, definitions, imports, withShortcut);
|
||||
}
|
||||
|
||||
@@ -64,10 +64,10 @@ export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeI
|
||||
|
||||
// TypeDef.sub is a `TypeDef | TypeDef[]`
|
||||
if (Array.isArray(typeDef.sub)) {
|
||||
typeDef.sub.forEach((subType) => setImports(allDefs, imports, [subType.type]));
|
||||
typeDef.sub.forEach((subType) => setImports(allDefs, imports, [subType.lookupName || subType.type]));
|
||||
} else if (typeDef.sub && (typeDef.info !== TypeDefInfo.VecFixed || typeDef.sub.type !== 'u8')) {
|
||||
// typeDef.sub is a TypeDef in this case
|
||||
setImports(allDefs, imports, [typeDef.sub.type]);
|
||||
setImports(allDefs, imports, [typeDef.sub.lookupName || typeDef.sub.type]);
|
||||
}
|
||||
} else if (type.includes('[') && type.includes('|')) {
|
||||
// We split the types (we already dod the check above, so safe-path should not be caught)
|
||||
|
||||
@@ -9,5 +9,8 @@ export * from './imports';
|
||||
export * from './initMeta';
|
||||
export * from './register';
|
||||
|
||||
export const compareName = (a: { name: { toString(): string } }, b: { name: { toString(): string } }): number =>
|
||||
a.name.toString().localeCompare(b.name.toString());
|
||||
type Cmp = { name: { toString(): string } };
|
||||
|
||||
export function compareName (a: Cmp, b: Cmp): number {
|
||||
return a.name.toString().localeCompare(b.name.toString());
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { ExtraTypes } from '../generate/types';
|
||||
|
||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||
import staticData from '@polkadot/types/metadata/static';
|
||||
import staticData from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
import { registerDefinitions } from './register';
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "5.1.1",
|
||||
"version": "5.8.2",
|
||||
"type": "module",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"description": "Known type definitions",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
@@ -19,9 +19,9 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.6",
|
||||
"@polkadot/networks": "^7.0.2",
|
||||
"@polkadot/types": "5.1.1",
|
||||
"@polkadot/util": "^7.0.2"
|
||||
"@babel/runtime": "^7.15.4",
|
||||
"@polkadot/networks": "^7.3.1",
|
||||
"@polkadot/types": "5.8.2",
|
||||
"@polkadot/util": "^7.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import typesModules from './modules';
|
||||
import typesSpec from './spec';
|
||||
import upgrades from './upgrades';
|
||||
|
||||
export { knownOrigins } from './knownOrigins';
|
||||
export { packageInfo } from './packageInfo';
|
||||
|
||||
// flatten a VersionedType[] into a Record<string, string>
|
||||
@@ -56,7 +57,7 @@ export function getSpecExtensions ({ knownTypes }: Registry, chainName: Text | s
|
||||
/**
|
||||
* @description Based on the chain and runtimeVersion, get the applicable types (ready for registration)
|
||||
*/
|
||||
export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: BigInt | BN | number): RegistryTypes {
|
||||
export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string, specVersion: bigint | BN | number): RegistryTypes {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
const _specVersion = bnToBn(specVersion).toNumber();
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// We want predictive ordering (manually managed)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
// FIXME: Need some sort of solution for specifying these
|
||||
// Since we don't have insight into the origin specification, we can only define what we know about
|
||||
// in a pure Substrate/Polkadot implementation, any other custom origins won't be handled at all
|
||||
export const knownOrigins: Record<string, string> = {
|
||||
//
|
||||
// (1) Defaults from Substrate
|
||||
//
|
||||
Council: 'CollectiveOrigin',
|
||||
System: 'SystemOrigin',
|
||||
TechnicalCommittee: 'CollectiveOrigin',
|
||||
//
|
||||
// (2) Defaults from Polkadot
|
||||
//
|
||||
Xcm: 'XcmOrigin',
|
||||
XcmPallet: 'XcmOrigin',
|
||||
//
|
||||
// (3) Defaults from Acala
|
||||
//
|
||||
Authority: 'AuthorityOrigin',
|
||||
GeneralCouncil: 'CollectiveOrigin'
|
||||
};
|
||||
@@ -48,6 +48,15 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
inclusion: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
paraInclusion: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
paraScheduler: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
paraShared: {
|
||||
ValidatorIndex: 'ParaValidatorIndex'
|
||||
},
|
||||
parachains: {
|
||||
Id: 'ParaId'
|
||||
},
|
||||
@@ -81,6 +90,12 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
},
|
||||
treasury: {
|
||||
Proposal: 'TreasuryProposal'
|
||||
},
|
||||
xcm: {
|
||||
AssetId: 'XcmAssetId'
|
||||
},
|
||||
xcmPallet: {
|
||||
AssetId: 'XcmAssetId'
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '5.1.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '5.8.2' };
|
||||
|
||||
@@ -10,7 +10,7 @@ const sharedTypes = {
|
||||
RawSolution: 'RawSolutionWith24',
|
||||
Keys: 'SessionKeys6',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement', 'CancelProxy']
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement', 'CancelProxy', 'Auction']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -192,7 +192,13 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [9010, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
AssetInstance: 'AssetInstanceV0',
|
||||
MultiAsset: 'MultiAssetV0',
|
||||
MultiLocation: 'MultiLocationV0',
|
||||
Response: 'ResponseV0',
|
||||
Xcm: 'XcmV0',
|
||||
XcmOrder: 'XcmOrderV0'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -40,7 +40,12 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [229, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
AssetInstance: 'AssetInstanceV0',
|
||||
MultiAsset: 'MultiAssetV0',
|
||||
Response: 'ResponseV0',
|
||||
Xcm: 'XcmV0',
|
||||
XcmOrder: 'XcmOrderV0'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
// these are override types for Polkadot
|
||||
// these are override types for Statemine, Statemint, Westmint
|
||||
const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [0, undefined],
|
||||
@@ -21,7 +21,12 @@ const versioned: OverrideVersionedType[] = [
|
||||
'AssetManager',
|
||||
'Staking'
|
||||
]
|
||||
}
|
||||
},
|
||||
AssetInstance: 'AssetInstanceV0',
|
||||
MultiAsset: 'MultiAssetV0',
|
||||
Response: 'ResponseV0',
|
||||
Xcm: 'XcmV0',
|
||||
XcmOrder: 'XcmOrderV0'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -91,7 +91,12 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [50, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
AssetInstance: 'AssetInstanceV0',
|
||||
MultiAsset: 'MultiAssetV0',
|
||||
Response: 'ResponseV0',
|
||||
Xcm: 'XcmV0',
|
||||
XcmOrder: 'XcmOrderV0'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -13,7 +13,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[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], [7668600, 9030],
|
||||
[7812476, 9040], [8010981, 9050], [8073833, 9070]
|
||||
[7812476, 9040], [8010981, 9050], [8073833, 9070], [8555825, 9080], [8945245, 9090]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -8,7 +8,8 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[244358, 8], [303079, 9], [314201, 10], [342400, 11], [443963, 12],
|
||||
[528470, 13], [687751, 14], [746085, 15], [787923, 16], [799302, 17],
|
||||
[1205128, 18], [1603423, 23], [1733218, 24], [2005673, 25], [2436698, 26],
|
||||
[3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30], [5661442, 9050]
|
||||
[3613564, 27], [3899547, 28], [4345767, 29], [4876134, 30], [5661442, 9050],
|
||||
[6321619, 9080]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -11,7 +11,7 @@ const upgrades: ChainUpgradesRaw = [
|
||||
[2549864, 45], [3925782, 46], [3925843, 47], [4207800, 48], [4627944, 49],
|
||||
[5124076, 50], [5478664, 900], [5482450, 9000], [5584305, 9010], [5784566, 9030],
|
||||
[5879822, 9031], [5896856, 9032], [5897316, 9033], [6117927, 9050], [6210274, 9070],
|
||||
[6379314, 9080]
|
||||
[6379314, 9080], [6979141, 9090]
|
||||
];
|
||||
|
||||
export default upgrades;
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@@ -0,0 +1,3 @@
|
||||
# @polkadot/types-known
|
||||
|
||||
Specific known base type overrides (e.g. `Address`, etc) for chains & specs. This does not contain user-specfic types.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user