Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
20f18c72e5 | ||
|
|
6a31cbe1a2 | ||
|
|
acba636d16 | ||
|
|
6356fe0571 | ||
|
|
3e17824539 | ||
|
|
db9e580f82 | ||
|
|
5ffcba6dd5 | ||
|
|
731846088c | ||
|
|
8b87689489 | ||
|
|
5a299adddc | ||
|
|
99bb6cfe71 | ||
|
|
ad9a8605d7 | ||
|
|
d62bfc55ac | ||
|
|
311740a1a2 | ||
|
|
3285f1f122 | ||
|
|
2a9711a3cb | ||
|
|
3ea7cb47ce | ||
|
|
82fc46881a | ||
|
|
e7758ad54c | ||
|
|
7d3ab4c5c1 | ||
|
|
6c87a6f0af | ||
|
|
fc5e4afe44 | ||
|
|
48ef04b8ca | ||
|
|
1b526fe618 | ||
|
|
8d6bd931f3 | ||
|
|
b317a8eb9b | ||
|
|
8e65545a3c | ||
|
|
4ded189697 | ||
|
|
b503441341 |
@@ -24,3 +24,6 @@
|
||||
4.9.2
|
||||
4.11.2
|
||||
4.16.2
|
||||
|
||||
5.3.2
|
||||
5.5.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
|
||||
|
||||
+111
@@ -1,5 +1,116 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 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:
|
||||
|
||||
- Don't clear rpc decoration on Api clone (Thanks to https://github.com/ianhe8x)
|
||||
- Align Xcm Junction type with Substrate (Thanks to https://github.com/dt665m)
|
||||
|
||||
Changes:
|
||||
|
||||
- Update `ParaPastCodeMeta` with `ReplacementTimes`
|
||||
- Add mappings for `AccountId20` & `AccountId32` types
|
||||
- Adjust scale-info types with Substrate (mapping for api-contracts to old)
|
||||
- Allow nested structs in enum definitions & generation
|
||||
- Allow for parsing of v14 metadata (not enabled by default, not merged into Substrate as of yet)
|
||||
|
||||
|
||||
## 5.0.1 Jul 11, 2021
|
||||
|
||||
Upgrade priority: Low. Recommended for users of current-generation Substrate chains.
|
||||
|
||||
+3
-2
@@ -12,7 +12,7 @@ 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'
|
||||
},
|
||||
@@ -25,7 +25,8 @@ module.exports = {
|
||||
'<rootDir>/packages/rpc-provider/build',
|
||||
'<rootDir>/packages/typegen/build',
|
||||
'<rootDir>/packages/types/build',
|
||||
'<rootDir>/packages/types-known/build'
|
||||
'<rootDir>/packages/types-known/build',
|
||||
'<rootDir>/packages/types-support/build'
|
||||
],
|
||||
testTimeout: 30000,
|
||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
||||
|
||||
+7
-6
@@ -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",
|
||||
"@babel/core": "^7.15.0",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/dev": "^0.62.60",
|
||||
"@polkadot/ts": "^0.4.4",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.23",
|
||||
"@types/jest": "^26.0.24",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "5.0.1"
|
||||
"version": "5.5.2",
|
||||
"packageManager": "yarn@3.0.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "5.0.1",
|
||||
"version": "5.5.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.0.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/util": "^7.0.1",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api": "5.5.2",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/util": "^7.2.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';
|
||||
@@ -49,7 +49,7 @@ export class Abi {
|
||||
this.registry.setMetaTypes(this.project.types);
|
||||
|
||||
this.project.types.forEach((_, index) =>
|
||||
this.registry.getMetaTypeDef({ type: this.registry.createType('SiLookupTypeId', index + this.registry.typeOffset) })
|
||||
this.registry.getMetaTypeDef({ type: this.registry.createType('Si0LookupTypeId', index + this.registry.typeOffset) })
|
||||
);
|
||||
this.constructors = this.project.spec.constructors.map((spec: ContractConstructorSpec, index) =>
|
||||
this.#createMessage(spec, index, {
|
||||
@@ -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' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// Copyright 2017-2021 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { ChainProperties, ContractDisplayName, SiField, SiLookupTypeId, SiType, SiTypeDefArray, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiVariant } from '@polkadot/types/interfaces';
|
||||
import type { ChainProperties, ContractDisplayName, Si0Field, Si0LookupTypeId, Si0Type, Si0TypeDefArray, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0Variant } from '@polkadot/types/interfaces';
|
||||
import type { InterfaceTypes, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import { TypeDefInfo, TypeRegistry, withTypeString } from '@polkadot/types';
|
||||
import { assert, isUndefined } from '@polkadot/util';
|
||||
|
||||
interface PartialTypeSpec {
|
||||
readonly type: SiLookupTypeId;
|
||||
readonly type: Si0LookupTypeId;
|
||||
readonly displayName?: ContractDisplayName;
|
||||
}
|
||||
|
||||
// convert the offset into project-specific, index-1
|
||||
export function getRegistryOffset (id: SiLookupTypeId, typeOffset: number): number {
|
||||
export function getRegistryOffset (id: Si0LookupTypeId, typeOffset: number): number {
|
||||
return id.toNumber() - typeOffset;
|
||||
}
|
||||
|
||||
@@ -24,12 +24,13 @@ 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[] = [];
|
||||
|
||||
public readonly typeOffset;
|
||||
|
||||
#siTypes: SiType[] = [];
|
||||
#siTypes: Si0Type[] = [];
|
||||
|
||||
constructor (metadataVersion: string, chainProperties?: ChainProperties) {
|
||||
super();
|
||||
@@ -44,7 +45,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
}
|
||||
}
|
||||
|
||||
public setMetaTypes (metaTypes: SiType[]): void {
|
||||
public setMetaTypes (metaTypes: Si0Type[]): void {
|
||||
this.#siTypes = metaTypes;
|
||||
}
|
||||
|
||||
@@ -83,15 +84,15 @@ export class MetaRegistry extends TypeRegistry {
|
||||
return typeDef;
|
||||
}
|
||||
|
||||
#getMetaType = (id: SiLookupTypeId): SiType => {
|
||||
#getMetaType = (id: Si0LookupTypeId): Si0Type => {
|
||||
const type = this.#siTypes[getRegistryOffset(id, this.typeOffset)];
|
||||
|
||||
assert(!isUndefined(type), () => `getMetaType:: Unable to find ${id.toNumber()} in type values`);
|
||||
|
||||
return this.createType('SiType', type);
|
||||
return this.createType('Si0Type', type);
|
||||
}
|
||||
|
||||
#extract = (type: SiType, id: SiLookupTypeId): TypeDef => {
|
||||
#extract = (type: Si0Type, id: Si0LookupTypeId): TypeDef => {
|
||||
const path = [...type.path];
|
||||
const isPrimitivePath = !!path.length && (
|
||||
(path.length > 2 && path[0].eq('ink_env') && path[1].eq('types')) ||
|
||||
@@ -119,7 +120,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
|
||||
const displayName = path.pop()?.toString();
|
||||
|
||||
return withTypeString({
|
||||
return withTypeString(this, {
|
||||
...(displayName
|
||||
? { displayName }
|
||||
: {}
|
||||
@@ -136,7 +137,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
});
|
||||
}
|
||||
|
||||
#extractArray = ({ len: length, type }: SiTypeDefArray): Omit<TypeDef, 'type'> => {
|
||||
#extractArray = ({ len: length, type }: Si0TypeDefArray): Omit<TypeDef, 'type'> => {
|
||||
assert(!length || length.toNumber() <= 256, 'MetaRegistry: Only support for [Type; <length>], where length <= 256');
|
||||
|
||||
return {
|
||||
@@ -146,7 +147,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
#extractFields = (fields: SiField[]): Omit<TypeDef, 'type'> => {
|
||||
#extractFields = (fields: Si0Field[]): Omit<TypeDef, 'type'> => {
|
||||
const [isStruct, isTuple] = fields.reduce(([isAllNamed, isAllUnnamed], { name }) => ([
|
||||
isAllNamed && name.isSome,
|
||||
isAllUnnamed && name.isNone
|
||||
@@ -174,7 +175,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
#extractPrimitive = (type: SiType): TypeDef => {
|
||||
#extractPrimitive = (type: Si0Type): TypeDef => {
|
||||
const typeStr = type.def.asPrimitive.type.toString();
|
||||
|
||||
return {
|
||||
@@ -183,14 +184,14 @@ export class MetaRegistry extends TypeRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
#extractPrimitivePath = (type: SiType): TypeDef => {
|
||||
#extractPrimitivePath = (type: Si0Type): TypeDef => {
|
||||
return {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: type.path[type.path.length - 1].toString()
|
||||
};
|
||||
}
|
||||
|
||||
#extractSequence = ({ type }: SiTypeDefSequence, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
#extractSequence = ({ type }: Si0TypeDefSequence, id: Si0LookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
assert(!!type, () => `ContractRegistry: Invalid sequence type found at id ${id.toString()}`);
|
||||
|
||||
return {
|
||||
@@ -199,7 +200,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
#extractTuple = (ids: SiTypeDefTuple): Omit<TypeDef, 'type'> => {
|
||||
#extractTuple = (ids: Si0TypeDefTuple): Omit<TypeDef, 'type'> => {
|
||||
return ids.length === 1
|
||||
? this.getMetaTypeDef({ type: ids[0] })
|
||||
: {
|
||||
@@ -208,7 +209,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
#extractVariant = ({ variants }: SiTypeDefVariant, id: SiLookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
#extractVariant = ({ variants }: Si0TypeDefVariant, id: Si0LookupTypeId): Omit<TypeDef, 'type'> => {
|
||||
const { params, path } = this.#getMetaType(id);
|
||||
const specialVariant = path[0].toString();
|
||||
|
||||
@@ -231,7 +232,7 @@ export class MetaRegistry extends TypeRegistry {
|
||||
};
|
||||
}
|
||||
|
||||
#extractVariantSub = (variants: SiVariant[]): TypeDef[] => {
|
||||
#extractVariantSub = (variants: Si0Variant[]): TypeDef[] => {
|
||||
return variants.every(({ fields }) => fields.length === 0)
|
||||
? variants.map(({ discriminant, name }) => ({
|
||||
...(
|
||||
@@ -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.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '5.5.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.0.1",
|
||||
"version": "5.5.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.0.1",
|
||||
"@polkadot/rpc-core": "5.0.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/util": "^7.0.1",
|
||||
"@polkadot/util-crypto": "^7.0.1",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api": "5.5.2",
|
||||
"@polkadot/rpc-core": "5.5.2",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/util": "^7.2.1",
|
||||
"@polkadot/util-crypto": "^7.2.1",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.0.1",
|
||||
"@polkadot/rpc-provider": "5.0.1"
|
||||
"@polkadot/keyring": "^7.2.1",
|
||||
"@polkadot/rpc-provider": "5.5.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '5.5.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.0.1",
|
||||
"version": "5.5.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.0.1",
|
||||
"@polkadot/keyring": "^7.0.1",
|
||||
"@polkadot/rpc-core": "5.0.1",
|
||||
"@polkadot/rpc-provider": "5.0.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/types-known": "5.0.1",
|
||||
"@polkadot/util": "^7.0.1",
|
||||
"@polkadot/util-crypto": "^7.0.1",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api-derive": "5.5.2",
|
||||
"@polkadot/keyring": "^7.2.1",
|
||||
"@polkadot/rpc-core": "5.5.2",
|
||||
"@polkadot/rpc-provider": "5.5.2",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/types-known": "5.5.2",
|
||||
"@polkadot/util": "^7.2.1",
|
||||
"@polkadot/util-crypto": "^7.2.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
|
||||
**/
|
||||
@@ -163,10 +212,20 @@ declare module '@polkadot/api/types/consts' {
|
||||
* 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.
|
||||
*
|
||||
@@ -192,6 +251,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 +377,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.
|
||||
@@ -371,6 +458,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 +486,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
|
||||
**/
|
||||
@@ -495,6 +601,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.
|
||||
@@ -657,7 +779,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,6 +804,45 @@ 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;
|
||||
};
|
||||
vesting: {
|
||||
/**
|
||||
* The minimum amount transferred to call `vested_transfer`.
|
||||
|
||||
@@ -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.
|
||||
**/
|
||||
@@ -819,7 +819,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 +830,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.
|
||||
**/
|
||||
@@ -1172,6 +1176,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
|
||||
**/
|
||||
|
||||
@@ -939,7 +939,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, []>;
|
||||
/**
|
||||
|
||||
@@ -1352,8 +1352,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.
|
||||
*
|
||||
@@ -2556,7 +2557,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 +2955,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 +3018,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]>;
|
||||
/**
|
||||
@@ -3093,7 +3093,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>]>;
|
||||
@@ -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]>;
|
||||
@@ -4413,24 +4413,6 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
vest: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Unlock any vested funds of a `target` account.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* - `target`: The account whose vested funds should be unlocked. Must have funds still
|
||||
* locked under this pallet.
|
||||
*
|
||||
* Emits either `VestingCompleted` or `VestingUpdated`.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)`.
|
||||
* - DbWeight: 3 Reads, 3 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account
|
||||
* # </weight>
|
||||
**/
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||
/**
|
||||
* Create a vested transfer.
|
||||
*
|
||||
@@ -4450,6 +4432,24 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </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.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* - `target`: The account whose vested funds should be unlocked. Must have funds still
|
||||
* locked under this pallet.
|
||||
*
|
||||
* Emits either `VestingCompleted` or `VestingUpdated`.
|
||||
*
|
||||
* # <weight>
|
||||
* - `O(1)`.
|
||||
* - DbWeight: 3 Reads, 3 Writes
|
||||
* - Reads: Vesting Storage, Balances Locks, Target Account
|
||||
* - Writes: Vesting Storage, Balances Locks, Target Account
|
||||
* # </weight>
|
||||
**/
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [LookupSource]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RpcMethods, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
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 {
|
||||
@@ -265,9 +276,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
// manner to cater for both old and new:
|
||||
// - when the number of entries are 0, only remove the ones with isOptional (account & contracts)
|
||||
// - when non-zero, remove anything that is not in the array (we don't do this)
|
||||
protected _filterRpc (rpcMethods: RpcMethods, additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
|
||||
const methods = rpcMethods.methods.map((t) => t.toString());
|
||||
|
||||
protected _filterRpc (methods: string[], additional: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
|
||||
// add any specific user-base RPCs
|
||||
if (Object.keys(additional).length !== 0) {
|
||||
this._rpcCore.addUserInterfaces(additional);
|
||||
@@ -370,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`
|
||||
@@ -407,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 */
|
||||
@@ -416,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
|
||||
@@ -437,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(
|
||||
@@ -465,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(
|
||||
@@ -479,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])));
|
||||
}
|
||||
|
||||
@@ -490,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
|
||||
@@ -518,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)));
|
||||
}
|
||||
|
||||
@@ -544,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)
|
||||
@@ -571,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([]);
|
||||
}
|
||||
@@ -587,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();
|
||||
@@ -621,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);
|
||||
|
||||
@@ -213,7 +216,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
});
|
||||
});
|
||||
|
||||
this._filterRpcMethods(methods);
|
||||
this._filterRpc(methods, getSpecRpc(this.registry, source.runtimeChain, source.runtimeVersion.specName));
|
||||
|
||||
return [source.genesisHash, source.runtimeMetadata];
|
||||
}
|
||||
@@ -296,12 +299,12 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// initializes the registry & RPC
|
||||
this._initRegistry(this.registry, chain, runtimeVersion, metadata, chainProps);
|
||||
this._filterRpc(rpcMethods, getSpecRpc(this.registry, chain, runtimeVersion.specName));
|
||||
this._filterRpc(rpcMethods.methods.map((t) => t.toString()), getSpecRpc(this.registry, chain, runtimeVersion.specName));
|
||||
this._subscribeUpdates();
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ function consts (api: ApiPromise): void {
|
||||
console.log(
|
||||
api.consts.foo.bar,
|
||||
api.consts.balances.existentialDeposit.toNumber(),
|
||||
api.consts.balances.existentialDeposit.meta.documentation.map((s): string => s.toString()).join('')
|
||||
api.consts.balances.existentialDeposit.meta.docs.map((s): string => s.toString()).join('')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '5.5.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.0.1",
|
||||
"version": "5.5.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.0.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/util": "^7.0.1",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/rpc-provider": "5.5.2",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/util": "^7.2.1",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.0.1"
|
||||
"@polkadot/keyring": "^7.2.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';
|
||||
@@ -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.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.5.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "5.0.1",
|
||||
"version": "5.5.2",
|
||||
"type": "module",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
@@ -19,18 +19,18 @@
|
||||
"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.0.1",
|
||||
"@polkadot/util": "^7.0.1",
|
||||
"@polkadot/util-crypto": "^7.0.1",
|
||||
"@polkadot/x-fetch": "^7.0.1",
|
||||
"@polkadot/x-global": "^7.0.1",
|
||||
"@polkadot/x-ws": "^7.0.1",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/util": "^7.2.1",
|
||||
"@polkadot/util-crypto": "^7.2.1",
|
||||
"@polkadot/x-fetch": "^7.2.1",
|
||||
"@polkadot/x-global": "^7.2.1",
|
||||
"@polkadot/x-ws": "^7.2.1",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.0.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/keyring": "^7.2.1",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.1.1"
|
||||
}
|
||||
|
||||
@@ -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.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.5.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "5.0.1",
|
||||
"version": "5.5.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.0.1",
|
||||
"@polkadot/rpc-provider": "5.0.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/util": "^7.0.1",
|
||||
"@babel/core": "^7.15.0",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api": "5.5.2",
|
||||
"@polkadot/rpc-provider": "5.5.2",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/types-support": "5.5.2",
|
||||
"@polkadot/util": "^7.2.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,42 +31,41 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
||||
}
|
||||
|
||||
const items = constants
|
||||
.sort(compareName)
|
||||
.map(({ documentation, name, type }) => {
|
||||
const returnType = formatType(allDefs, type.toString(), imports);
|
||||
.map(({ docs, name, type }) => {
|
||||
const returnType = formatType(meta.registry, allDefs, type.toString(), imports);
|
||||
|
||||
setImports(allDefs, imports, [returnType]);
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
docs,
|
||||
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(({ documentation, name }) => ({
|
||||
docs: documentation,
|
||||
.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,43 +24,41 @@ 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, documentation, name }) => {
|
||||
const types = args.map((type) => formatType(allDefs, type.toString(), imports));
|
||||
.map(({ args, docs, name }) => {
|
||||
const types = args.map((type) => formatType(meta.registry, allDefs, type.toString(), imports));
|
||||
|
||||
setImports(allDefs, imports, types);
|
||||
|
||||
return {
|
||||
docs: documentation,
|
||||
docs,
|
||||
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,45 +104,44 @@ 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);
|
||||
|
||||
return {
|
||||
args,
|
||||
docs: storageEntry.documentation,
|
||||
docs: storageEntry.docs,
|
||||
entryType: 'AugmentedQuery',
|
||||
name: stringCamelCase(storageEntry.name),
|
||||
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,15 +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(({ info, name = '', type }): string => {
|
||||
const keys = (sub as TypeDef[]).map((def, index): string => {
|
||||
const { info, name = `unknown${index}`, type } = def;
|
||||
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
|
||||
const isComplexType = [TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||
const isComplex = [TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
||||
? ''
|
||||
: createGetter(definitions, `as${getter}`, isComplexType ? formatType(definitions, 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);
|
||||
@@ -63,6 +65,7 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
|
||||
switch (info) {
|
||||
case TypeDefInfo.Compact:
|
||||
case TypeDefInfo.Plain:
|
||||
case TypeDefInfo.Struct:
|
||||
case TypeDefInfo.Tuple:
|
||||
case TypeDefInfo.Vec:
|
||||
case TypeDefInfo.Option:
|
||||
@@ -80,18 +83,18 @@ function tsEnum (definitions: Record<string, ModuleTypes>, { name: enumName, sub
|
||||
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) {
|
||||
@@ -107,22 +110,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 */
|
||||
function tsSet (definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
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 (_: Registry, definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||
setImports(definitions, imports, ['Set']);
|
||||
|
||||
const types = (sub as TypeDef[]).map(({ name }): string => {
|
||||
@@ -135,11 +144,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);
|
||||
});
|
||||
@@ -148,12 +157,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') {
|
||||
@@ -162,39 +171,41 @@ 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));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function generateInterfaces (definitions: Record<string, ModuleTypes>, { types }: { types: Record<string, any> }, imports: Imports): [string, string][] {
|
||||
// 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 generators = {
|
||||
[TypeDefInfo.BTreeMap]: tsBTreeMap,
|
||||
[TypeDefInfo.BTreeSet]: tsBTreeSet,
|
||||
[TypeDefInfo.Compact]: tsCompact,
|
||||
[TypeDefInfo.DoNotConstruct]: tsDoNotConstruct,
|
||||
[TypeDefInfo.Enum]: tsEnum,
|
||||
[TypeDefInfo.HashMap]: tsHashMap,
|
||||
[TypeDefInfo.Int]: tsInt,
|
||||
[TypeDefInfo.Linkage]: errorUnhandled,
|
||||
[TypeDefInfo.Null]: errorUnhandled,
|
||||
[TypeDefInfo.Option]: tsOption,
|
||||
[TypeDefInfo.Plain]: tsPlain,
|
||||
[TypeDefInfo.Result]: tsResult,
|
||||
[TypeDefInfo.Set]: tsSet,
|
||||
[TypeDefInfo.Struct]: tsStruct,
|
||||
[TypeDefInfo.Tuple]: tsTuple,
|
||||
[TypeDefInfo.UInt]: tsUInt,
|
||||
[TypeDefInfo.Vec]: tsVec,
|
||||
[TypeDefInfo.VecFixed]: tsVec
|
||||
};
|
||||
// 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, (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string> = {
|
||||
[TypeDefInfo.BTreeMap]: tsBTreeMap,
|
||||
[TypeDefInfo.BTreeSet]: tsBTreeSet,
|
||||
[TypeDefInfo.Compact]: tsCompact,
|
||||
[TypeDefInfo.DoNotConstruct]: tsDoNotConstruct,
|
||||
[TypeDefInfo.Enum]: tsEnum,
|
||||
[TypeDefInfo.HashMap]: tsHashMap,
|
||||
[TypeDefInfo.Int]: tsInt,
|
||||
[TypeDefInfo.Linkage]: errorUnhandled,
|
||||
[TypeDefInfo.Null]: errorUnhandled,
|
||||
[TypeDefInfo.Option]: tsOption,
|
||||
[TypeDefInfo.Plain]: tsPlain,
|
||||
[TypeDefInfo.Range]: errorUnhandled,
|
||||
[TypeDefInfo.Result]: tsResult,
|
||||
[TypeDefInfo.Set]: tsSet,
|
||||
[TypeDefInfo.Si]: tsSi,
|
||||
[TypeDefInfo.Struct]: tsStruct,
|
||||
[TypeDefInfo.Tuple]: tsTuple,
|
||||
[TypeDefInfo.UInt]: tsUInt,
|
||||
[TypeDefInfo.Vec]: tsVec,
|
||||
[TypeDefInfo.VecFixed]: tsVec
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
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, generators[def.info](definitions, def, imports)];
|
||||
return [name, encoders[def.info](registry, definitions, def, imports)];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -208,10 +219,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 = [
|
||||
@@ -233,13 +244,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,14 +37,12 @@ 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, documentation, name }) => {
|
||||
.map(({ args, docs, name }) => {
|
||||
const params = args
|
||||
.map(({ name, type }) => {
|
||||
const typeStr = type.toString();
|
||||
@@ -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(', '),
|
||||
docs: documentation,
|
||||
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 {
|
||||
@@ -43,7 +43,7 @@ const DESC_RPC = 'The following sections contain RPC methods that are Remote Cal
|
||||
const DESC_STORAGE = `The following sections contain Storage methods are part of the default Substrate runtime. On the api, these are exposed via \`api.query.<module>.<method>\`. ${STATIC_TEXT}`;
|
||||
|
||||
/** @internal */
|
||||
function documentationVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||
const md = docLines
|
||||
.map((docLine) => docLine && docLine.substring(1)) // trim the leading space
|
||||
.reduce((md, docLine): string => // generate paragraphs
|
||||
@@ -94,7 +94,7 @@ function renderPage (page: Page): string {
|
||||
md += `\n- **${bullet}**: ${
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
item[bullet] instanceof Vec
|
||||
? documentationVecToMarkdown(item[bullet] as Vec<Text>, 2).toString()
|
||||
? docsVecToMarkdown(item[bullet] as Vec<Text>, 2).toString()
|
||||
: item[bullet]
|
||||
}`;
|
||||
});
|
||||
@@ -180,7 +180,7 @@ function addConstants (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
|
||||
name: `${methodName}: ` + '`' + func.type.toString() + '`',
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: sectionName
|
||||
@@ -211,12 +211,12 @@ 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}` + '`',
|
||||
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: sectionName
|
||||
@@ -234,12 +234,12 @@ 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}` + '`',
|
||||
name: `${methodName}(${arg}): ` + '`' + outputType + '`',
|
||||
summary: meta.documentation
|
||||
summary: meta.docs
|
||||
};
|
||||
}),
|
||||
name: 'substrate'
|
||||
@@ -268,7 +268,7 @@ function addExtrinsics (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.tx.${sectionName}.${methodName}` + '`',
|
||||
name: `${methodName}(${args})`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: sectionName
|
||||
@@ -295,7 +295,7 @@ function addEvents (metadata: MetadataLatest): string {
|
||||
return {
|
||||
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
|
||||
name: `${methodName}(${args})`,
|
||||
...(func.documentation.length && { summary: func.documentation })
|
||||
...(func.docs.length && { summary: func.docs })
|
||||
};
|
||||
}),
|
||||
name: stringCamelCase(meta.name)
|
||||
@@ -317,7 +317,7 @@ function addErrors (metadata: MetadataLatest): string {
|
||||
.map((error) => ({
|
||||
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
|
||||
name: error.name.toString(),
|
||||
...(error.documentation.length && { summary: error.documentation })
|
||||
...(error.docs.length && { summary: error.docs })
|
||||
})),
|
||||
name: stringLowerFirst(moduleMetadata.name)
|
||||
})),
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.5.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,92 +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 `O` & `E`, return a `Result<O, E>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatResult (innerOk: string, innerError: string): string {
|
||||
return `Result<${innerOk}, ${innerError}>`;
|
||||
}
|
||||
const sub = (typeDef.sub as TypeDef);
|
||||
|
||||
/**
|
||||
* Given the inner `T`, return a `Option<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatOption (inner: string): string {
|
||||
return paramsNotation('Option', inner);
|
||||
}
|
||||
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 inners `T[]`, return a `ITuple<...T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatTuple (inners: string[]): string {
|
||||
return paramsNotation('ITuple', `[${inners.join(', ')}]`);
|
||||
}
|
||||
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 inner `T`, return a `Vec<T>` string
|
||||
*/
|
||||
/** @internal */
|
||||
function formatVec (inner: string): string {
|
||||
return paramsNotation('Vec', inner);
|
||||
}
|
||||
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']);
|
||||
|
||||
// `(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)) {
|
||||
@@ -176,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;
|
||||
}
|
||||
|
||||
@@ -187,101 +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.Vec: {
|
||||
setImports(definitions, imports, ['Vec']);
|
||||
|
||||
return formatVec(formatType(definitions, (typeDef.sub as TypeDef).type, imports));
|
||||
}
|
||||
|
||||
case TypeDefInfo.Tuple: {
|
||||
setImports(definitions, imports, ['ITuple']);
|
||||
|
||||
// `(a,b)` gets transformed into `ITuple<[a, b]>`
|
||||
return formatTuple(
|
||||
((typeDef.sub as TypeDef[]).map((sub) => formatType(definitions, sub.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.0.1",
|
||||
"version": "5.5.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.1",
|
||||
"@polkadot/types": "5.0.1",
|
||||
"@polkadot/util": "^7.0.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/networks": "^7.2.1",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/util": "^7.2.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'
|
||||
};
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '5.0.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '5.5.2' };
|
||||
|
||||
@@ -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]
|
||||
];
|
||||
|
||||
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;
|
||||
|
||||
@@ -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.
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@polkadot/types-support",
|
||||
"version": "5.5.2",
|
||||
"type": "module",
|
||||
"description": "Supporting files for types, mostly for testing",
|
||||
"main": "index.js",
|
||||
"sideEffects": [
|
||||
"./detectPackage.js",
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
},
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
"maintainers": [],
|
||||
"contributors": [],
|
||||
"license": "Apache-2.0",
|
||||
"repository": "github:polkadot-js/api",
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-support#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "^7.2.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/types-support authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
import { packageInfo } from './packageInfo';
|
||||
|
||||
detectPackage(packageInfo, typeof __dirname !== 'undefined' && __dirname, []);
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2021 @polkadot/types-support authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './detectPackage';
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user