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 |
+2
-1
@@ -25,4 +25,5 @@
|
||||
4.11.2
|
||||
4.16.2
|
||||
|
||||
5.3.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
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
# 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.
|
||||
|
||||
+6
-5
@@ -26,14 +26,15 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.14.8",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@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.24",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"version": "5.4.1"
|
||||
"version": "5.5.2",
|
||||
"packageManager": "yarn@3.0.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "5.4.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.8",
|
||||
"@polkadot/api": "5.4.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/util": "^7.1.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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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' });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,14 +27,14 @@ 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: unknown[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
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: unknown[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||
return (options: BigInt | string | number | BN | ContractOptions, ...params: unknown[]): SubmittableExtrinsic<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)
|
||||
|
||||
@@ -10,22 +10,22 @@ import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions
|
||||
|
||||
export interface BlueprintDeploy<ApiType extends ApiTypes> {
|
||||
(options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...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: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...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: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...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: unknown[]): T;
|
||||
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...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'
|
||||
|
||||
@@ -17,14 +17,14 @@ import { extractOptions, isOptions } from '../util';
|
||||
export const EMPTY_SALT = new Uint8Array();
|
||||
|
||||
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> =>
|
||||
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: unknown[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: unknown[]): 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.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/api-contract', version: '5.5.2' };
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -24,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: unknown[]): [T, unknown[]] {
|
||||
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,18 +143,18 @@
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -162,29 +162,29 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"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)"
|
||||
},
|
||||
{
|
||||
"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,18 +191,18 @@
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -210,22 +210,22 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -236,21 +236,21 @@
|
||||
"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,11 +420,11 @@
|
||||
"ext": {
|
||||
"discriminant": 7
|
||||
},
|
||||
"info": 6,
|
||||
"info": "Plain",
|
||||
"name": "NotAllowed",
|
||||
"type": "Null"
|
||||
}
|
||||
],
|
||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||
}
|
||||
]
|
||||
]
|
||||
@@ -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,16 +50,16 @@
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -67,20 +67,20 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -89,34 +89,34 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
@@ -414,16 +414,16 @@
|
||||
{
|
||||
"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,18 +143,18 @@
|
||||
"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"
|
||||
}
|
||||
],
|
||||
@@ -162,33 +162,33 @@
|
||||
"name": "Occupied"
|
||||
}
|
||||
],
|
||||
"info": 3,
|
||||
"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)"
|
||||
},
|
||||
{
|
||||
"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.4.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.8",
|
||||
"@polkadot/api": "5.4.1",
|
||||
"@polkadot/rpc-core": "5.4.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.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.1.1",
|
||||
"@polkadot/rpc-provider": "5.4.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])
|
||||
];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/api-derive', version: '5.4.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;
|
||||
}
|
||||
|
||||
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "5.4.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.8",
|
||||
"@polkadot/api-derive": "5.4.1",
|
||||
"@polkadot/keyring": "^7.1.1",
|
||||
"@polkadot/rpc-core": "5.4.1",
|
||||
"@polkadot/rpc-provider": "5.4.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/types-known": "5.4.1",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,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);
|
||||
@@ -363,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}`);
|
||||
|
||||
|
||||
@@ -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.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/api', version: '5.5.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "5.4.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.8",
|
||||
"@polkadot/rpc-provider": "5.4.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/util": "^7.1.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.1.1"
|
||||
"@polkadot/keyring": "^7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.5.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "5.4.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.8",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.1",
|
||||
"@polkadot/x-fetch": "^7.1.1",
|
||||
"@polkadot/x-global": "^7.1.1",
|
||||
"@polkadot/x-ws": "^7.1.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.1.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/keyring": "^7.2.1",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.1.1"
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.5.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "5.4.1",
|
||||
"version": "5.5.2",
|
||||
"type": "module",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
@@ -26,17 +26,17 @@
|
||||
"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.8",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@polkadot/api": "5.4.1",
|
||||
"@polkadot/rpc-provider": "5.4.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/types-support": "5.4.1",
|
||||
"@polkadot/util": "^7.1.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.4",
|
||||
|
||||
@@ -189,6 +189,7 @@ const encoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<str
|
||||
[TypeDefInfo.Null]: errorUnhandled,
|
||||
[TypeDefInfo.Option]: tsOption,
|
||||
[TypeDefInfo.Plain]: tsPlain,
|
||||
[TypeDefInfo.Range]: errorUnhandled,
|
||||
[TypeDefInfo.Result]: tsResult,
|
||||
[TypeDefInfo.Set]: tsSet,
|
||||
[TypeDefInfo.Si]: tsSi,
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.5.2' };
|
||||
|
||||
@@ -129,6 +129,9 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
||||
|
||||
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)}`);
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "5.4.1",
|
||||
"version": "5.5.2",
|
||||
"type": "module",
|
||||
"description": "Known type definitions",
|
||||
"main": "index.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.8",
|
||||
"@polkadot/networks": "^7.1.1",
|
||||
"@polkadot/types": "5.4.1",
|
||||
"@polkadot/util": "^7.1.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/networks": "^7.2.1",
|
||||
"@polkadot/types": "5.5.2",
|
||||
"@polkadot/util": "^7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,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();
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '5.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-known', version: '5.5.2' };
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-support",
|
||||
"version": "5.4.1",
|
||||
"version": "5.5.2",
|
||||
"type": "module",
|
||||
"description": "Supporting files for types, mostly for testing",
|
||||
"main": "index.js",
|
||||
@@ -19,7 +19,7 @@
|
||||
"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.14.8",
|
||||
"@polkadot/util": "^7.1.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "^7.2.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types-support', version: '5.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/types-support', version: '5.5.2' };
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "5.4.1",
|
||||
"version": "5.5.2",
|
||||
"type": "module",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
@@ -19,14 +19,14 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.1",
|
||||
"rxjs": "^7.2.0"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "^7.2.1",
|
||||
"@polkadot/util-crypto": "^7.2.1",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.1.1",
|
||||
"@polkadot/types-support": "5.4.1",
|
||||
"@polkadot/keyring": "^7.2.1",
|
||||
"@polkadot/types-support": "5.5.2",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
}
|
||||
|
||||
@@ -29,8 +29,10 @@ assert(oo0.divn(123) && [...oo1.values()] && oo2[6].isAscii && oo3.divn(3) && oo
|
||||
const aa0 = registry.createType(' AccountId');
|
||||
const aa1 = registry.createType('BlockAttestations');
|
||||
const aa2 = registry.createType('ExtrinsicEra');
|
||||
const aa3 = registry.createType('VestingInfo');
|
||||
const aa4 = registry.createType('(Vec<ValidatorIndex>, CompactAssignmentsTo257, PhragmenScore, EraIndex)');
|
||||
|
||||
assert(aa0.isAscii && aa1.receipt && aa2.isMortalEra, 'All ok');
|
||||
assert(aa0.isAscii && aa1.receipt && aa2.isMortalEra && aa3.toHuman() && aa4[3].toNumber(), 'All ok');
|
||||
|
||||
// Should be Codec, we don't know this one
|
||||
const bb = registry.createType('Something');
|
||||
@@ -46,35 +48,52 @@ const vv = registry.createType('Vec< Vec< Vec< Vec<u8>> > >');
|
||||
// vec with tuple
|
||||
const vt = registry.createType('Vec<(u8, u16)>');
|
||||
// nested stuff from all-over
|
||||
const vn = registry.createType('Vec<(u32, (u32, u64), Vec<u8>, Vec<(u32, u64)>, [u8;32], [u128;32])>');
|
||||
const vn = registry.createType('Vec<(u32, (u32, u64), Vec<u8>, Vec<u32>, Vec<(u32, u64)>, [u8;32], [u128;32])>');
|
||||
// nested fixed
|
||||
const nf = registry.createType('[[[u8;32];5];3]');
|
||||
// with linkage
|
||||
const tl = registry.createType('(ValidatorPrefsWithCommission, Linkage<AccountId>)');
|
||||
|
||||
assert(ee[0].unwrap().unwrap().divn(123) && vb.unwrap().bitLength() && vv.toHuman() && vn.toHuman() && vt.toHuman(), 'All ok');
|
||||
assert(ee[0].unwrap().unwrap().divn(123) && vb.unwrap().bitLength() && vv.toHuman() && vn[0][3][0].bitLength && vt.toHuman() && nf.toHuman() && tl[1].next, 'All ok');
|
||||
|
||||
// tuple & struct
|
||||
const vs = registry.createType('(u8, {"a":"u32","b":"(u32,u64)"},(u8,u16),{"foo":"Bar"},u16)');
|
||||
// set
|
||||
const st = registry.createType('{"_set": { "A": 1, "B": 2, "C": 4 } }');
|
||||
// enum
|
||||
const en = registry.createType('{"_enum": { "A": 1, "B": 2, "C": 4 } }');
|
||||
|
||||
assert(vs.toHuman() && st.strings && en.index, 'All ok');
|
||||
|
||||
// Should end up as Raw
|
||||
const gg = registry.createType('[ u8 ;678]');
|
||||
|
||||
assert(gg.bitLength, 'All ok');
|
||||
assert(gg.subarray(1), 'All ok');
|
||||
|
||||
// Should end up as VecFixed<u128>
|
||||
const hh = registry.createType('[u128; 32]');
|
||||
// maps and sets
|
||||
const ms = registry.createType('(BTreeSet<u8>, BTreeMap<u16, u32>, HashMap<u64, u128>)');
|
||||
|
||||
assert(hh[0].bitLength(), 'All ok');
|
||||
assert(hh[0].bitLength() && ms[0].strings && ms[1].values && ms[2].keys, 'All ok');
|
||||
|
||||
// tuple! ITuple<[u32, Compact<u64>, u128, Codec]>
|
||||
const tt1 = registry.createType('(u32, Compact< u64 >, u128 , Something)');
|
||||
const tt1 = registry.createType('(u32, Compact<u64>, u128 , Something)');
|
||||
// unwraps into a u32
|
||||
const tt2 = registry.createType('( u32 )');
|
||||
// lots and lots of params
|
||||
const tt4 = registry.createType('(u8,u16,u32,u64,u128,u256,Break,u256,u128,u64,u32,u16,u8)');
|
||||
const tt2 = registry.createType('(((u32)))');
|
||||
// lots and lots of params (indicates recursion limit)
|
||||
const tt4 = registry.createType('(u8,u16,u32,u64,u128,u256,u8,u16,u32,u64,u128,u256,u8,u16,u32,u64,u128,u256)');
|
||||
// empty
|
||||
const tt5 = registry.createType('()');
|
||||
// nested tuples
|
||||
const tt6 = registry.createType('(u8, (u16, (u32, u64, u32)), (u64, u64))');
|
||||
const tt6 = registry.createType('(u8, (u16, (u32, u64, u128)), (u64, u128))');
|
||||
// more nested tuples
|
||||
const tt7 = registry.createType('(((u8, u8), (u8, u8)), u16)');
|
||||
const tt7 = registry.createType('(((u8, u16, u32), (u32, u16, u8)), u128, u256)');
|
||||
// nested tuples with a wrapper
|
||||
const tt8 = registry.createType('(u8, Vec<(u16, u32)>, Option<(u128, u128)>)');
|
||||
// same example as above
|
||||
const tt9 = registry.createType('(u32, (u32, u64), Vec<u8>, Vec<(u32, u64)>, [u8;32], [u128;32])');
|
||||
// tuple with nested fixed
|
||||
const tta = registry.createType('([u8;32], [u16;5])');
|
||||
|
||||
assert(tt1[2].bitLength() && tt2.bitLength() && tt4[3].bitLength() && tt5.isEmpty && tt6[1].toHuman() && tt7.toHuman() && tt8.toHuman() && tt9.toHuman(), 'All ok');
|
||||
assert(tt1[2].bitLength() && tt2.bitLength() && tt4[3].bitLength() && tt5.isEmpty && tt6[1].toHuman() && tt7.toHuman() && tt8.toHuman() && tt9.toHuman() && tta[1][1].bitLength(), 'All ok');
|
||||
|
||||
@@ -15,7 +15,7 @@ import { compareArray } from './utils/compareArray';
|
||||
* specific encoding/decoding on top of the base type.
|
||||
* @noInheritDoc
|
||||
*/
|
||||
export abstract class AbstractArray<T extends Codec> extends Array<T> implements IVec<Codec> {
|
||||
export abstract class AbstractArray<T extends Codec> extends Array<T> implements IVec<T> {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Constructor, Registry } from '../types';
|
||||
import type { AnyJson, Codec, Constructor, ISet, Registry } from '../types';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isHex, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
@@ -11,7 +11,7 @@ import { compareSet, decodeU8a, sortSet, typeToConstructor } from './utils';
|
||||
const l = logger('BTreeSet');
|
||||
|
||||
/** @internal */
|
||||
function decodeSetFromU8a<V extends Codec = Codec> (registry: Registry, ValClass: Constructor<V>, u8a: Uint8Array): Set<V> {
|
||||
function decodeSetFromU8a<V extends Codec> (registry: Registry, ValClass: Constructor<V>, u8a: Uint8Array): Set<V> {
|
||||
const output = new Set<V>();
|
||||
const [offset, length] = compactFromU8a(u8a);
|
||||
const types = [];
|
||||
@@ -30,7 +30,7 @@ function decodeSetFromU8a<V extends Codec = Codec> (registry: Registry, ValClass
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeSetFromSet<V extends Codec = Codec> (registry: Registry, ValClass: Constructor<V>, value: Set<any> | string[]): Set<V> {
|
||||
function decodeSetFromSet<V extends Codec> (registry: Registry, ValClass: Constructor<V>, value: Set<any> | string[]): Set<V> {
|
||||
const output = new Set<V>();
|
||||
|
||||
value.forEach((val: any) => {
|
||||
@@ -60,7 +60,7 @@ function decodeSetFromSet<V extends Codec = Codec> (registry: Registry, ValClass
|
||||
* @param jsonSet
|
||||
* @internal
|
||||
*/
|
||||
function decodeSet<V extends Codec = Codec> (registry: Registry, valType: Constructor<V> | string, value?: Uint8Array | string | string[] | Set<any>): Set<V> {
|
||||
function decodeSet<V extends Codec> (registry: Registry, valType: Constructor<V> | string, value?: Uint8Array | string | string[] | Set<any>): Set<V> {
|
||||
if (!value) {
|
||||
return new Set<V>();
|
||||
}
|
||||
@@ -76,7 +76,7 @@ function decodeSet<V extends Codec = Codec> (registry: Registry, valType: Constr
|
||||
throw new Error('BTreeSet: cannot decode type');
|
||||
}
|
||||
|
||||
export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
|
||||
export class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V> {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
@@ -125,6 +125,13 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements Codec {
|
||||
return this.size === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The actual set values as a string[]
|
||||
*/
|
||||
public get strings (): string[] {
|
||||
return [...super.values()].map((v) => v.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('Date', (): void => {
|
||||
});
|
||||
|
||||
describe('encode', (): void => {
|
||||
const testEncode = (to: 'toBigInt' | 'toBn' | 'toISOString' | 'toNumber' | CodecTo, expected: BigInt | BN | number | string | Uint8Array): void =>
|
||||
const testEncode = (to: 'toBigInt' | 'toBn' | 'toISOString' | 'toNumber' | CodecTo, expected: bigint | BN | number | string | Uint8Array): void =>
|
||||
it(`can encode ${to}`, (): void => {
|
||||
expect(new CodecDate(registry, 421)[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyNumber, Codec, Registry } from '../types';
|
||||
import type { AnyNumber, INumber, Registry } from '../types';
|
||||
import type { UIntBitLength } from './types';
|
||||
|
||||
import { BN, bnToBn, bnToHex, bnToU8a, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
@@ -33,7 +33,7 @@ function decodeDate (value: CodecDate | Date | AnyNumber): Date {
|
||||
* and has all the methods available that are applicable to any `Date`
|
||||
* @noInheritDoc
|
||||
*/
|
||||
export class CodecDate extends Date implements Codec {
|
||||
export class CodecDate extends Date implements INumber {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { AnyJson, Codec, Constructor, Registry } from '../types';
|
||||
import type { AnyJson, Codec, Constructor, IMap, Registry } from '../types';
|
||||
|
||||
import { compactFromU8a, compactToU8a, isHex, isObject, isU8a, logger, stringify, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
@@ -14,7 +14,7 @@ import { compareMap, decodeU8a, sortMap, typeToConstructor } from './utils';
|
||||
const l = logger('Map');
|
||||
|
||||
/** @internal */
|
||||
function decodeMapFromU8a<K extends Codec = Codec, V extends Codec = Codec> (registry: Registry, KeyClass: Constructor<K>, ValClass: Constructor<V>, u8a: Uint8Array): Map<K, V> {
|
||||
function decodeMapFromU8a<K extends Codec, V extends Codec> (registry: Registry, KeyClass: Constructor<K>, ValClass: Constructor<V>, u8a: Uint8Array): Map<K, V> {
|
||||
const output = new Map<K, V>();
|
||||
const [offset, length] = compactFromU8a(u8a);
|
||||
const types = [];
|
||||
@@ -33,7 +33,7 @@ function decodeMapFromU8a<K extends Codec = Codec, V extends Codec = Codec> (reg
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeMapFromMap<K extends Codec = Codec, V extends Codec = Codec> (registry: Registry, KeyClass: Constructor<K>, ValClass: Constructor<V>, value: Map<any, any>): Map<K, V> {
|
||||
function decodeMapFromMap<K extends Codec, V extends Codec> (registry: Registry, KeyClass: Constructor<K>, ValClass: Constructor<V>, value: Map<any, any>): Map<K, V> {
|
||||
const output = new Map<K, V>();
|
||||
|
||||
value.forEach((val: any, key: any) => {
|
||||
@@ -75,7 +75,7 @@ function decodeMapFromMap<K extends Codec = Codec, V extends Codec = Codec> (reg
|
||||
* @param jsonMap
|
||||
* @internal
|
||||
*/
|
||||
function decodeMap<K extends Codec = Codec, V extends Codec = Codec> (registry: Registry, keyType: Constructor<K> | string, valType: Constructor<V> | string, value?: Uint8Array | string | Map<any, any>): Map<K, V> {
|
||||
function decodeMap<K extends Codec, V extends Codec> (registry: Registry, keyType: Constructor<K> | string, valType: Constructor<V> | string, value?: Uint8Array | string | Map<any, any>): Map<K, V> {
|
||||
const KeyClass = typeToConstructor(registry, keyType);
|
||||
const ValClass = typeToConstructor(registry, valType);
|
||||
|
||||
@@ -92,7 +92,7 @@ function decodeMap<K extends Codec = Codec, V extends Codec = Codec> (registry:
|
||||
throw new Error('Map: cannot decode type');
|
||||
}
|
||||
|
||||
export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends Map<K, V> implements Codec {
|
||||
export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends Map<K, V> implements IMap<K, V> {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import { U32 } from '../primitive';
|
||||
import { Range } from '.';
|
||||
|
||||
describe('Range', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
let range: Range<U32>;
|
||||
|
||||
beforeEach((): void => {
|
||||
const Clazz = Range.with(U32);
|
||||
|
||||
range = new Clazz(
|
||||
registry,
|
||||
[new U32(registry, 1), new U32(registry, 2)]
|
||||
);
|
||||
});
|
||||
|
||||
it('decodes', (): void => {
|
||||
expect(range.toJSON()).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('encodes', (): void => {
|
||||
expect(range.toU8a()).toEqual(new Uint8Array([1, 0, 0, 0, 2, 0, 0, 0]));
|
||||
});
|
||||
|
||||
it('has a sane toRawType representation', (): void => {
|
||||
expect(range.toRawType()).toEqual('Range<u32>');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,66 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { AnyTuple, Constructor, INumber, Registry } from '../types';
|
||||
|
||||
import { Tuple } from '../codec/Tuple';
|
||||
|
||||
type RangeType = 'Range' | 'RangeInclusive';
|
||||
|
||||
/**
|
||||
* @name Range
|
||||
* @description
|
||||
* Rust `Range<T>` representation
|
||||
*/
|
||||
export class Range<T extends INumber> extends Tuple {
|
||||
#rangeName: RangeType;
|
||||
|
||||
constructor (registry: Registry, Type: Constructor<T> | string, value?: AnyTuple, rangeName: RangeType = 'Range') {
|
||||
super(registry, { end: Type, start: Type }, value);
|
||||
|
||||
this.#rangeName = rangeName;
|
||||
}
|
||||
|
||||
public static override with <T extends INumber> (Types: Constructor<T> | string): Constructor<Range<T>> {
|
||||
return class extends Range<T> {
|
||||
constructor (registry: Registry, value?: AnyTuple) {
|
||||
super(registry, Types, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the starting range value
|
||||
*/
|
||||
public get start (): T {
|
||||
return this[0] as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the ending range value
|
||||
*/
|
||||
public get end (): T {
|
||||
return this[1] as T;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public override toRawType (): string {
|
||||
return `${this.#rangeName}<${this.start.toRawType()}>`;
|
||||
}
|
||||
}
|
||||
|
||||
export class RangeInclusive<T extends INumber = INumber> extends Range<T> {
|
||||
constructor (registry: Registry, type: Constructor<T> | string, value?: AnyTuple) {
|
||||
super(registry, type, value, 'RangeInclusive');
|
||||
}
|
||||
|
||||
public static override with <T extends INumber> (Types: Constructor<T> | string): Constructor<RangeInclusive<T>> {
|
||||
return class extends RangeInclusive<T> {
|
||||
constructor (registry: Registry, value?: AnyTuple) {
|
||||
super(registry, Types, value);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Codec, Constructor, Registry } from '../types';
|
||||
import type { Codec, Constructor, IResult, Registry } from '../types';
|
||||
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Enum } from './Enum';
|
||||
* @description
|
||||
* A Result maps to the Rust Result type, that can either wrap a success or error value
|
||||
*/
|
||||
export class Result<O extends Codec, E extends Codec> extends Enum {
|
||||
export class Result<O extends Codec, E extends Codec> extends Enum implements IResult<O, E> {
|
||||
constructor (registry: Registry, Ok: Constructor<O> | string, Err: Constructor<E> | string, value?: unknown) {
|
||||
// NOTE This is order-dependent, Ok (with index 0) needs to be first
|
||||
// eslint-disable-next-line sort-keys
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { CodecHash, Hash } from '../interfaces/runtime';
|
||||
import type { Codec, Constructor, Registry } from '../types';
|
||||
import type { Constructor, ISet, Registry } from '../types';
|
||||
|
||||
import { assert, BN, bnToBn, bnToU8a, isBn, isNumber, isString, isU8a, isUndefined, stringCamelCase, stringify, stringUpperFirst, u8aToBn, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
@@ -18,25 +18,25 @@ function encodeSet (setValues: SetValues, value: string[]): BN {
|
||||
|
||||
/** @internal */
|
||||
function decodeSetArray (setValues: SetValues, value: string[]): string[] {
|
||||
return value.reduce((result, key): string[] => {
|
||||
return value.reduce<string[]>((result, key): string[] => {
|
||||
assert(!isUndefined(setValues[key]), () => `Set: Invalid key '${key}' passed to Set, allowed ${Object.keys(setValues).join(', ')}`);
|
||||
|
||||
result.push(key);
|
||||
|
||||
return result;
|
||||
}, [] as string[]);
|
||||
}, []);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeSetNumber (setValues: SetValues, _value: BN | number): string[] {
|
||||
const bn = bnToBn(_value);
|
||||
const result = Object.keys(setValues).reduce((result, key): string[] => {
|
||||
const result = Object.keys(setValues).reduce<string[]>((result, key): string[] => {
|
||||
if (bn.and(bnToBn(setValues[key])).eq(bnToBn(setValues[key]))) {
|
||||
result.push(key);
|
||||
}
|
||||
|
||||
return result;
|
||||
}, [] as string[]);
|
||||
}, []);
|
||||
|
||||
const computed = encodeSet(setValues, result);
|
||||
|
||||
@@ -74,8 +74,7 @@ function decodeSet (setValues: SetValues, value: string[] | Set<string> | Uint8A
|
||||
* An Set is an array of string values, represented an an encoded type by
|
||||
* a bitwise representation of the values.
|
||||
*/
|
||||
// FIXME This is a prime candidate to extend the JavaScript built-in Set
|
||||
export class CodecSet extends Set<string> implements Codec {
|
||||
export class CodecSet extends Set<string> implements ISet<string> {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
@@ -98,13 +97,12 @@ export class CodecSet extends Set<string> implements Codec {
|
||||
super(registry, values, value as undefined, bitLength);
|
||||
|
||||
Object.keys(values).forEach((_key): void => {
|
||||
const name = stringUpperFirst(stringCamelCase(_key));
|
||||
const iskey = `is${name}`;
|
||||
const iskey = `is${stringUpperFirst(stringCamelCase(_key))}`;
|
||||
|
||||
isUndefined(this[iskey as keyof this]) &&
|
||||
Object.defineProperty(this, iskey, {
|
||||
enumerable: true,
|
||||
get: (): boolean => this.strings.includes(_key)
|
||||
get: () => this.strings.includes(_key)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class Struct<
|
||||
// input values, mapped by key can be anything (construction)
|
||||
V extends { [K in keyof S]: any } = { [K in keyof S]: any },
|
||||
// type names, mapped by key, name of Class in S
|
||||
E extends { [K in keyof S]: string } = { [K in keyof S]: string }> extends Map<keyof S, Codec> implements IStruct {
|
||||
E extends { [K in keyof S]: string } = { [K in keyof S]: string }> extends Map<keyof S, Codec> implements IStruct<keyof S> {
|
||||
public readonly registry: Registry;
|
||||
|
||||
public createdAtHash?: Hash;
|
||||
@@ -147,9 +147,7 @@ export class Struct<
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
constructor (registry: Registry, Types: S, value: V | Map<unknown, unknown> | unknown[] | string = {} as V, jsonMap: Map<keyof S, string> = new Map()) {
|
||||
super(Object.entries(
|
||||
decodeStruct(registry, mapToTypeMap(registry, Types), value, jsonMap)
|
||||
) as [keyof S, Codec][]);
|
||||
super(Object.entries(decodeStruct(registry, mapToTypeMap(registry, Types), value, jsonMap)));
|
||||
|
||||
this.registry = registry;
|
||||
this.#jsonMap = jsonMap;
|
||||
@@ -181,7 +179,7 @@ export class Struct<
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The available keys for this enum
|
||||
* @description The available keys for this struct
|
||||
*/
|
||||
public get defKeys (): string[] {
|
||||
return Object.keys(this.#Types);
|
||||
@@ -207,7 +205,7 @@ export class Struct<
|
||||
*/
|
||||
public get Type (): E {
|
||||
return (Object
|
||||
.entries(this.#Types) as [keyof S, Constructor][])
|
||||
.entries(this.#Types))
|
||||
.reduce((result: E, [key, Type]): E => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
(result as any)[key] = new Type(this.registry).toRawType();
|
||||
@@ -301,9 +299,7 @@ export class Struct<
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return stringify(
|
||||
Struct.typesToMap(this.registry, this.#Types)
|
||||
);
|
||||
return stringify(Struct.typesToMap(this.registry, this.#Types));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import type { AnyNumber, AnyString, AnyU8a, Codec, Constructor, ITuple, Registry } from '../types';
|
||||
|
||||
import { isHex, isU8a, stringify, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { isFunction, isHex, isString, isU8a, stringify, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
import { AbstractArray } from './AbstractArray';
|
||||
import { decodeU8a, mapToTypeMap, typeToConstructor } from './utils';
|
||||
@@ -14,7 +14,9 @@ type TupleConstructors = Constructor[] | {
|
||||
[index: string]: Constructor;
|
||||
};
|
||||
|
||||
type TupleTypes = (Constructor | string)[] | {
|
||||
type TupleType = (Constructor | string);
|
||||
|
||||
type TupleTypes = TupleType[] | {
|
||||
[index: string]: Constructor | string;
|
||||
};
|
||||
|
||||
@@ -52,17 +54,19 @@ function decodeTuple (registry: Registry, _Types: TupleConstructors, value?: Any
|
||||
export class Tuple extends AbstractArray<Codec> implements ITuple<Codec[]> {
|
||||
private _Types: TupleConstructors;
|
||||
|
||||
constructor (registry: Registry, Types: TupleTypes, value?: AnyTuple) {
|
||||
constructor (registry: Registry, Types: TupleTypes | TupleType, value?: AnyTuple) {
|
||||
const Clazzes = Array.isArray(Types)
|
||||
? Types.map((type): Constructor => typeToConstructor(registry, type))
|
||||
: mapToTypeMap(registry, Types);
|
||||
? Types.map((t) => typeToConstructor(registry, t))
|
||||
: isFunction(Types) || isString(Types)
|
||||
? [typeToConstructor(registry, Types)]
|
||||
: mapToTypeMap(registry, Types);
|
||||
|
||||
super(registry, ...decodeTuple(registry, Clazzes, value));
|
||||
|
||||
this._Types = Clazzes;
|
||||
}
|
||||
|
||||
public static with (Types: TupleTypes): Constructor<Tuple> {
|
||||
public static with (Types: TupleTypes | TupleType): Constructor<Tuple> {
|
||||
return class extends Tuple {
|
||||
constructor (registry: Registry, value?: AnyTuple) {
|
||||
super(registry, Types, value);
|
||||
|
||||
@@ -19,6 +19,7 @@ export { Json } from './Json';
|
||||
export { Linkage } from './Linkage';
|
||||
export { CodecMap, CodecMap as Map } from './Map';
|
||||
export { Option } from './Option';
|
||||
export { Range, RangeInclusive } from './Range';
|
||||
export { Raw } from './Raw';
|
||||
export { Result } from './Result';
|
||||
export { CodecSet, CodecSet as Set } from './Set';
|
||||
|
||||
@@ -7,20 +7,11 @@ import type { TypeDef } from './types';
|
||||
|
||||
import { assert, isNumber, isUndefined, stringify } from '@polkadot/util';
|
||||
|
||||
import { BTreeMap, BTreeSet, CodecSet, Compact, DoNotConstruct, Enum, HashMap, Int, Option, Result, Struct, Tuple, U8aFixed, UInt, Vec, VecFixed } from '../codec';
|
||||
import { BTreeMap, BTreeSet, CodecSet, Compact, DoNotConstruct, Enum, HashMap, Int, Option, Range, RangeInclusive, Result, Struct, Tuple, U8aFixed, UInt, Vec, VecFixed } from '../codec';
|
||||
import { Bytes, Null } from '../primitive';
|
||||
import { getTypeDef } from './getTypeDef';
|
||||
import { TypeDefInfo } from './types';
|
||||
|
||||
export function createClass<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K): DetectConstructor<T, K> {
|
||||
return getTypeClass(
|
||||
registry,
|
||||
registry.isLookupType(type)
|
||||
? registry.lookup.getTypeDef(type)
|
||||
: getTypeDef(type)
|
||||
);
|
||||
}
|
||||
|
||||
function getSubDefArray (value: TypeDef): TypeDef[] {
|
||||
assert(value.sub && Array.isArray(value.sub), () => `Expected subtype as TypeDef[] in ${stringify(value)}`);
|
||||
|
||||
@@ -123,6 +114,9 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
[TypeDefInfo.Plain]: (registry: Registry, value: TypeDef): Constructor<Codec> =>
|
||||
registry.getOrUnknown(value.type),
|
||||
|
||||
[TypeDefInfo.Range]: (registry: Registry, value: TypeDef): Constructor<Codec> =>
|
||||
(value.type.includes('RangeInclusive') ? RangeInclusive : Range).with(getSubType(value)),
|
||||
|
||||
[TypeDefInfo.Result]: (registry: Registry, value: TypeDef): Constructor<Codec> => {
|
||||
const [Ok, Err] = getTypeClassArray(value);
|
||||
|
||||
@@ -180,14 +174,14 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
|
||||
// Returns the type Class for construction
|
||||
export function getTypeClass<T extends Codec = Codec> (registry: Registry, typeDef: TypeDef): Constructor<T> {
|
||||
let Type = registry.get<T>(typeDef.type) as Constructor<T> | undefined;
|
||||
let Type = registry.get(typeDef.type);
|
||||
|
||||
if (Type) {
|
||||
return Type;
|
||||
return Type as Constructor<T>;
|
||||
}
|
||||
|
||||
try {
|
||||
Type = infoMapping[typeDef.info](registry, typeDef) as Constructor<T>;
|
||||
Type = infoMapping[typeDef.info](registry, typeDef);
|
||||
|
||||
assert(Type, 'No class created');
|
||||
|
||||
@@ -198,8 +192,17 @@ export function getTypeClass<T extends Codec = Codec> (registry: Registry, typeD
|
||||
Type.__fallbackType = typeDef.fallbackType;
|
||||
}
|
||||
|
||||
return Type;
|
||||
return Type as Constructor<T>;
|
||||
} catch (error) {
|
||||
throw new Error(`Unable to construct class from ${stringify(typeDef)}: ${(error as Error).message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function createClass<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K): DetectConstructor<T, K> {
|
||||
return getTypeClass(
|
||||
registry,
|
||||
registry.isLookupType(type)
|
||||
? registry.lookup.getTypeDef(type)
|
||||
: getTypeDef(type)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { CodecSet, Int } from '../codec';
|
||||
import { createClass, createTypeUnsafe, TypeRegistry } from '.';
|
||||
import { createClass, TypeRegistry } from '.';
|
||||
|
||||
describe('createType', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
@@ -27,7 +27,7 @@ describe('createType', (): void => {
|
||||
|
||||
it('allows creation of a Struct', (): void => {
|
||||
const raw = '{"balance":"Balance","index":"u32"}';
|
||||
const struct = createTypeUnsafe(registry, raw, [{
|
||||
const struct = registry.createTypeUnsafe(raw, [{
|
||||
balance: 1234,
|
||||
index: '0x10'
|
||||
}]);
|
||||
@@ -41,49 +41,49 @@ describe('createType', (): void => {
|
||||
|
||||
it('allows creation of a BTreeMap', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'BTreeMap<Text,u32>', ['0x041c62617a7a696e6745000000']).toString()
|
||||
registry.createTypeUnsafe('BTreeMap<Text,u32>', ['0x041c62617a7a696e6745000000']).toString()
|
||||
).toEqual('{"bazzing":69}');
|
||||
});
|
||||
|
||||
it('allows creation of a BTreeSet', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'BTreeSet<u32>', ['0x1002000000180000001e00000050000000']).toString()
|
||||
registry.createTypeUnsafe('BTreeSet<u32>', ['0x1002000000180000001e00000050000000']).toString()
|
||||
).toEqual('[2,24,30,80]');
|
||||
});
|
||||
|
||||
it('allows creation of a Enum (simple)', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '{"_enum": ["A", "B", "C"]}', [1]).toJSON()
|
||||
registry.createTypeUnsafe('{"_enum": ["A", "B", "C"]}', [1]).toJSON()
|
||||
).toEqual('B');
|
||||
});
|
||||
|
||||
it('allows creation of a Enum (with types)', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '{"_enum": {"A": null, "B": "u32", "C": null} }', [1]).toJSON()
|
||||
registry.createTypeUnsafe('{"_enum": {"A": null, "B": "u32", "C": null} }', [1]).toJSON()
|
||||
).toEqual({ b: 0 });
|
||||
});
|
||||
|
||||
it('allows creation of a Enum (with indexes)', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '{"_enum": {"A": 42, "B": 69, "C": 255} }', [69]).toJSON()
|
||||
registry.createTypeUnsafe('{"_enum": {"A": 42, "B": 69, "C": 255} }', [69]).toJSON()
|
||||
).toEqual('B');
|
||||
});
|
||||
|
||||
it('allows creation of a Result', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'Result<u32,Text>', ['0x011064656667']).toJSON()
|
||||
registry.createTypeUnsafe('Result<u32,Text>', ['0x011064656667']).toJSON()
|
||||
).toEqual({ err: 'defg' });
|
||||
});
|
||||
|
||||
it('allows creation of a Set', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe<CodecSet>(registry, '{"_set": { "A": 1, "B": 2, "C": 4, "D": 8, "E": 16, "G": 32, "H": 64, "I": 128 } }', [1 + 4 + 16 + 64]).strings
|
||||
registry.createTypeUnsafe<CodecSet>('{"_set": { "A": 1, "B": 2, "C": 4, "D": 8, "E": 16, "G": 32, "H": 64, "I": 128 } }', [1 + 4 + 16 + 64]).strings
|
||||
).toEqual(['A', 'C', 'E', 'H']);
|
||||
});
|
||||
|
||||
it('allows creation of a Tuple', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '(Balance,u32)', [[1234, 5678]]).toJSON()
|
||||
registry.createTypeUnsafe('(Balance,u32)', [[1234, 5678]]).toJSON()
|
||||
).toEqual([
|
||||
1234, // '0x000000000000000000000000000004d2',
|
||||
5678
|
||||
@@ -92,13 +92,13 @@ describe('createType', (): void => {
|
||||
|
||||
it('allows creation for a UInt<bitLength>', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'UInt<2048>').toRawType()
|
||||
registry.createType('UInt<2048>').toRawType()
|
||||
).toEqual('u2048');
|
||||
});
|
||||
|
||||
it('fails creation for a UInt<bitLength> where bitLength is not power of 8', (): void => {
|
||||
expect(
|
||||
() => createTypeUnsafe(registry, 'UInt<20>').toRawType()
|
||||
() => registry.createType('UInt<20>').toRawType()
|
||||
).toThrow('UInt<20>: Only support for UInt<bitLength>, where length <= 8192 and a power of 8');
|
||||
});
|
||||
|
||||
@@ -112,44 +112,44 @@ describe('createType', (): void => {
|
||||
|
||||
it('allows creation of a [u8; 8]', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '[u8; 8]', [[0x12, 0x00, 0x23, 0x00, 0x45, 0x00, 0x67, 0x00]]).toHex()
|
||||
registry.createTypeUnsafe('[u8; 8]', [[0x12, 0x00, 0x23, 0x00, 0x45, 0x00, 0x67, 0x00]]).toHex()
|
||||
).toEqual('0x1200230045006700');
|
||||
});
|
||||
|
||||
it('allows creation of a [u16; 4]', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '[u16; 4]', [[0x1200, 0x2300, 0x4500, 0x6700]]).toU8a()
|
||||
registry.createTypeUnsafe('[u16; 4]', [[0x1200, 0x2300, 0x4500, 0x6700]]).toU8a()
|
||||
).toEqual(new Uint8Array([0x00, 0x12, 0x00, 0x23, 0x00, 0x45, 0x00, 0x67]));
|
||||
});
|
||||
|
||||
describe('isPedantic', (): void => {
|
||||
it('correctly decodes Bytes', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'Bytes', ['0x12345678'], { isPedantic: true }).toHex()
|
||||
registry.createTypeUnsafe('Bytes', ['0x12345678'], { isPedantic: true }).toHex()
|
||||
).toEqual('0x12345678');
|
||||
});
|
||||
|
||||
it('correctly decodes Bytes (prefixed)', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'Bytes', [new Uint8Array([4 << 2, 0x12, 0x34, 0x56, 0x78])], { isPedantic: true }).toHex()
|
||||
registry.createTypeUnsafe('Bytes', [new Uint8Array([4 << 2, 0x12, 0x34, 0x56, 0x78])], { isPedantic: true }).toHex()
|
||||
).toEqual('0x12345678');
|
||||
});
|
||||
|
||||
it('correctly decodes Text', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'Text', ['0x70726f7669646572'], { isPedantic: true }).toString()
|
||||
registry.createTypeUnsafe('Text', ['0x70726f7669646572'], { isPedantic: true }).toString()
|
||||
).toEqual('provider');
|
||||
});
|
||||
|
||||
it('correctly decodes Type', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, 'Type', ['0x5665633c75383e'], { isPedantic: true }).toString()
|
||||
registry.createTypeUnsafe('Type', ['0x5665633c75383e'], { isPedantic: true }).toString()
|
||||
).toEqual('Bytes'); // Vec<u8> -> Bytes
|
||||
});
|
||||
|
||||
it('correctly decodes [u16; 4]', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '[u16; 4]', ['0x0012002300450067'], { isPedantic: true }).toHex()
|
||||
registry.createTypeUnsafe('[u16; 4]', ['0x0012002300450067'], { isPedantic: true }).toHex()
|
||||
).toEqual('0x0012002300450067');
|
||||
});
|
||||
});
|
||||
@@ -180,12 +180,12 @@ describe('createType', (): void => {
|
||||
}
|
||||
});
|
||||
|
||||
const value = createTypeUnsafe(registry, 'TestComplex', [{
|
||||
const value = registry.createType('TestComplex', {
|
||||
accountId: '0x1234567812345678123456781234567812345678123456781234567812345678',
|
||||
balance: 123,
|
||||
fromSrml: 0,
|
||||
log: [456, 789]
|
||||
}]);
|
||||
});
|
||||
|
||||
expect(value instanceof createClass(registry, 'TestComplex')).toBe(true);
|
||||
});
|
||||
@@ -218,7 +218,7 @@ describe('createType', (): void => {
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const cmpDef: any = createTypeUnsafe(registry, 'TestComplex');
|
||||
const cmpDef: any = registry.createType('TestComplex');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
||||
expect(cmpDef.balance.bitLength()).toEqual(128);
|
||||
@@ -226,7 +226,7 @@ describe('createType', (): void => {
|
||||
registry.register({ Balance: 'u32' });
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const cmpu32: any = createTypeUnsafe(registry, 'TestComplex');
|
||||
const cmpu32: any = registry.createType('TestComplex');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
||||
expect(cmpu32.balance.bitLength()).toEqual(32);
|
||||
|
||||
@@ -12,18 +12,25 @@ import { createClass } from './createClass';
|
||||
|
||||
// With isPedantic, actually check that the encoding matches that supplied. This
|
||||
// is much slower, but verifies that we have the correct types defined
|
||||
function checkInstance (created: Codec, value: Uint8Array): void {
|
||||
function checkInstance (created: Codec, matcher: Uint8Array): void {
|
||||
const u8a = created.toU8a();
|
||||
const rawType = created.toRawType();
|
||||
|
||||
assert(
|
||||
u8aEq(value, u8a) || (
|
||||
// when length-prefixed from hex, just check the actual length
|
||||
const isOk = (
|
||||
// full match, all ok
|
||||
u8aEq(u8a, matcher) ||
|
||||
(
|
||||
// on a length-prefixed type, just check the actual length
|
||||
['Bytes', 'Text', 'Type'].includes(rawType) &&
|
||||
value.length === (created as Bytes).length
|
||||
),
|
||||
() => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(value, 512)} (${value.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`
|
||||
matcher.length === (created as Bytes).length
|
||||
) ||
|
||||
(
|
||||
// when the created is empty and matcher is also empty, let it slide...
|
||||
created.isEmpty &&
|
||||
matcher.every((v) => !v)
|
||||
)
|
||||
);
|
||||
|
||||
assert(isOk, () => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(matcher, 512)} (${matcher.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`);
|
||||
}
|
||||
|
||||
function checkPedantic (created: Codec, [value]: unknown[], isPedantic = false): void {
|
||||
@@ -38,7 +45,7 @@ function checkPedantic (created: Codec, [value]: unknown[], isPedantic = false):
|
||||
|
||||
// Initializes a type with a value. This also checks for fallbacks and in the cases
|
||||
// where isPedantic is specified (storage decoding), also check the format/structure
|
||||
function initType<T extends Codec = Codec, K extends string = string> (registry: Registry, Type: Constructor, params: unknown[] = [], { blockHash, isOptional, isPedantic }: CreateOptions = {}): DetectCodec<T, K> {
|
||||
function initType<T extends Codec> (registry: Registry, Type: Constructor, params: unknown[] = [], { blockHash, isOptional, isPedantic }: CreateOptions = {}): T {
|
||||
const created = new (isOptional ? Option.with(Type) : Type)(registry, ...params);
|
||||
|
||||
checkPedantic(created, params, isPedantic);
|
||||
@@ -59,7 +66,7 @@ export function createTypeUnsafe<T extends Codec = Codec, K extends string = str
|
||||
let firstError: Error | null = null;
|
||||
|
||||
try {
|
||||
Clazz = createClass<T, K>(registry, type);
|
||||
Clazz = createClass(registry, type);
|
||||
|
||||
return initType(registry, Clazz, params, options);
|
||||
} catch (error) {
|
||||
@@ -68,7 +75,7 @@ export function createTypeUnsafe<T extends Codec = Codec, K extends string = str
|
||||
|
||||
if (Clazz && Clazz.__fallbackType) {
|
||||
try {
|
||||
Clazz = createClass<T, K>(registry, Clazz.__fallbackType as unknown as K);
|
||||
Clazz = createClass(registry, Clazz.__fallbackType as unknown as K);
|
||||
|
||||
return initType(registry, Clazz, params, options);
|
||||
} catch {
|
||||
@@ -86,5 +93,5 @@ export function createTypeUnsafe<T extends Codec = Codec, K extends string = str
|
||||
* @param params - The value to instantiate the type with
|
||||
*/
|
||||
export function createType<T extends Codec = Codec, K extends string = string> (registry: Registry, type: K, ...params: unknown[]): DetectCodec<T, K> {
|
||||
return createTypeUnsafe<T, K>(registry, type, params);
|
||||
return createTypeUnsafe(registry, type, params);
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ const encoders: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef) => st
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
[TypeDefInfo.Plain]: (registry: Registry, typeDef: TypeDef) =>
|
||||
typeDef.displayName || typeDef.type,
|
||||
[TypeDefInfo.Range]: (registry: Registry, typeDef: TypeDef) =>
|
||||
encodeWithParams(registry, typeDef, typeDef.type.includes('RangeInclusive') ? 'RangeInclusive' : 'Range'),
|
||||
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef) =>
|
||||
encodeWithParams(registry, typeDef, 'Result'),
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
|
||||
@@ -142,6 +142,14 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number
|
||||
return value;
|
||||
}
|
||||
|
||||
function _decodeRange (value: TypeDef, _: string, subType: string): TypeDef {
|
||||
const Type = getTypeDef(subType);
|
||||
|
||||
value.sub = [Type, Type];
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// decode a tuple
|
||||
function _decodeTuple (value: TypeDef, _: string, subType: string, count: number): TypeDef {
|
||||
value.sub = subType.length === 0
|
||||
@@ -195,6 +203,9 @@ const nestedExtraction: [string, string, TypeDefInfo, (value: TypeDef, type: str
|
||||
['BTreeMap<', '>', TypeDefInfo.BTreeMap, _decodeTuple],
|
||||
['HashMap<', '>', TypeDefInfo.HashMap, _decodeTuple],
|
||||
['Int<', '>', TypeDefInfo.Int, _decodeInt],
|
||||
// Not sure about these, have a specific implementation?
|
||||
['Range<', '>', TypeDefInfo.Tuple, _decodeRange],
|
||||
['RangeInclusive<', '>', TypeDefInfo.Tuple, _decodeRange],
|
||||
['Result<', '>', TypeDefInfo.Result, _decodeTuple],
|
||||
['UInt<', '>', TypeDefInfo.UInt, _decodeUInt],
|
||||
['DoNotConstruct<', '>', TypeDefInfo.DoNotConstruct, _decodeDoNotConstruct]
|
||||
|
||||
@@ -8,7 +8,7 @@ interface SanitizeOptions {
|
||||
type Mapper = (value: string, options?: SanitizeOptions) => string;
|
||||
|
||||
const BOUNDED = ['BTreeMap', 'BTreeSet', 'HashMap', 'Vec'];
|
||||
const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Result', 'Option', 'UInt']);
|
||||
const ALLOWED_BOXES = BOUNDED.concat(['Compact', 'DoNotConstruct', 'Int', 'Linkage', 'Range', 'RangeInclusive', 'Result', 'Option', 'UInt']);
|
||||
const BOX_PRECEDING = ['<', '(', '[', '"', ',', ' ']; // start of vec, tuple, fixed array, part of struct def or in tuple
|
||||
|
||||
const mappings: Mapper[] = [
|
||||
|
||||
@@ -5,23 +5,23 @@ export enum TypeDefInfo {
|
||||
BTreeMap,
|
||||
BTreeSet,
|
||||
Compact,
|
||||
DoNotConstruct,
|
||||
Enum,
|
||||
Linkage,
|
||||
Option,
|
||||
Plain,
|
||||
Result,
|
||||
Set,
|
||||
Struct,
|
||||
Tuple,
|
||||
Vec,
|
||||
VecFixed,
|
||||
HashMap,
|
||||
Int,
|
||||
UInt,
|
||||
DoNotConstruct,
|
||||
Linkage,
|
||||
Null,
|
||||
Option,
|
||||
Plain,
|
||||
Range,
|
||||
Result,
|
||||
Set,
|
||||
Si,
|
||||
// anything not fully supported (keep this as the last entry)
|
||||
Null
|
||||
Struct,
|
||||
Tuple,
|
||||
UInt,
|
||||
Vec,
|
||||
VecFixed
|
||||
}
|
||||
|
||||
export interface TypeDef {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { GenericAccountIndex } from '../generic/AccountIndex';
|
||||
import { GenericEthereumAccountId } from './AccountId';
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type AnyAddress = BigInt | BN | GenericEthereumLookupSource | GenericEthereumAccountId | GenericAccountIndex | number[] | Uint8Array | number | string;
|
||||
type AnyAddress = bigint | BN | GenericEthereumLookupSource | GenericEthereumAccountId | GenericAccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ export const allExtensions: ExtDef = {
|
||||
// This may not match 100% with the current defaults and are used when not specified
|
||||
// in the metadata (which is for very old chains). The order is important here, as
|
||||
// applied by default
|
||||
export const fallbackExtensions: Array<keyof typeof allExtensions> = [
|
||||
export const fallbackExtensions = [
|
||||
'CheckVersion',
|
||||
'CheckGenesis',
|
||||
'CheckEra',
|
||||
|
||||
@@ -17,7 +17,7 @@ const MAX_2BYTE = new BN(1).shln(16);
|
||||
const MAX_4BYTE = new BN(1).shln(32);
|
||||
|
||||
/** @internal */
|
||||
function decodeAccountIndex (value: AnyNumber): BN | BigInt | Uint8Array | number | string {
|
||||
function decodeAccountIndex (value: AnyNumber): BN | bigint | Uint8Array | number | string {
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
if (value instanceof GenericAccountIndex) {
|
||||
// `value.toBn()` on AccountIndex returns a pure BN (i.e. not an
|
||||
|
||||
@@ -12,7 +12,7 @@ import { GenericAccountId } from './AccountId';
|
||||
import { GenericAccountIndex } from './AccountIndex';
|
||||
|
||||
// eslint-disable-next-line no-use-before-define
|
||||
type AnyAddress = BigInt | BN | GenericLookupSource | GenericAccountId | GenericAccountIndex | number[] | Uint8Array | number | string;
|
||||
type AnyAddress = bigint | BN | GenericLookupSource | GenericAccountId | GenericAccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { Codec } from './types';
|
||||
import metadataStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||
|
||||
import * as definitions from './interfaces/definitions';
|
||||
import { createTypeUnsafe, TypeRegistry } from './create';
|
||||
import { TypeRegistry } from './create';
|
||||
import * as exported from './index.types';
|
||||
import { Metadata } from './metadata';
|
||||
|
||||
@@ -34,7 +34,7 @@ function testTypes (type: string, typeNames: string[]): void {
|
||||
typeNames.forEach((name): void => {
|
||||
it(`creates an empty ${name}`, (): void => {
|
||||
const constructFn = (): Codec =>
|
||||
createTypeUnsafe(registry, name);
|
||||
registry.createType(name);
|
||||
|
||||
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
|
||||
expect(constructFn).toThrow();
|
||||
@@ -49,7 +49,7 @@ function testTypes (type: string, typeNames: string[]): void {
|
||||
typeNames.forEach((name): void => {
|
||||
it(`creates an empty ${name} (from empty bytes)`, (): void => {
|
||||
const constructFn = (): Codec =>
|
||||
createTypeUnsafe(registry, name, [createTypeUnsafe(registry, 'Bytes')]);
|
||||
registry.createType(name, registry.createType('Bytes'));
|
||||
|
||||
if (UNCONSTRUCTABLE.includes(name.toLowerCase())) {
|
||||
expect(constructFn).toThrow();
|
||||
|
||||
@@ -159,7 +159,7 @@ export default {
|
||||
DisputeStatementSet: {
|
||||
candidateHash: 'CandidateHash',
|
||||
session: 'SessionIndex',
|
||||
statements: 'Vec<(DisputeStatement, ValidatorIndex, ValidatorSignature)>'
|
||||
statements: 'Vec<(DisputeStatement, ParaValidatorIndex, ValidatorSignature)>'
|
||||
},
|
||||
MultiDisputeStatementSet: 'Vec<DisputeStatementSet>',
|
||||
DisputeStatement: {
|
||||
@@ -169,12 +169,12 @@ export default {
|
||||
}
|
||||
},
|
||||
ValidDisputeStatementKind: {
|
||||
_enum: [
|
||||
'Explicit',
|
||||
'BackingSeconded',
|
||||
'BackingValid',
|
||||
'ApprovalChecking'
|
||||
]
|
||||
_enum: {
|
||||
Explicit: 'Null',
|
||||
BackingSeconded: 'Hash',
|
||||
BackingValid: 'Hash',
|
||||
ApprovalChecking: 'Null'
|
||||
}
|
||||
},
|
||||
InvalidDisputeStatementKind: {
|
||||
_enum: [
|
||||
|
||||
@@ -6,7 +6,6 @@ import type { ITuple } from '@polkadot/types/types';
|
||||
import type { Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AccountId, Balance, BalanceOf, BlockNumber, H256, Hash, Header, StorageProof, ValidatorId, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import type { MembershipProof, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { ValidatorIndex } from '@polkadot/types/interfaces/staking';
|
||||
|
||||
/** @name AbridgedCandidateReceipt */
|
||||
export interface AbridgedCandidateReceipt extends Struct {
|
||||
@@ -189,7 +188,7 @@ export interface DisputeStatement extends Enum {
|
||||
export interface DisputeStatementSet extends Struct {
|
||||
readonly candidateHash: CandidateHash;
|
||||
readonly session: SessionIndex;
|
||||
readonly statements: Vec<ITuple<[DisputeStatement, ValidatorIndex, ValidatorSignature]>>;
|
||||
readonly statements: Vec<ITuple<[DisputeStatement, ParaValidatorIndex, ValidatorSignature]>>;
|
||||
}
|
||||
|
||||
/** @name DoubleVoteReport */
|
||||
@@ -661,7 +660,9 @@ export interface ValidatorSignature extends Signature {}
|
||||
export interface ValidDisputeStatementKind extends Enum {
|
||||
readonly isExplicit: boolean;
|
||||
readonly isBackingSeconded: boolean;
|
||||
readonly asBackingSeconded: Hash;
|
||||
readonly isBackingValid: boolean;
|
||||
readonly asBackingValid: Hash;
|
||||
readonly isApprovalChecking: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { createTypeUnsafe, TypeRegistry } from '../../create';
|
||||
import { TypeRegistry } from '../../create';
|
||||
|
||||
const ACTUAL = '0x' +
|
||||
// Vec<ValidatorIndex>
|
||||
@@ -181,15 +181,15 @@ describe('CompactAssignments', (): void => {
|
||||
|
||||
it('has a valid vote1 ([Type; <number>] equivalency)', (): void => {
|
||||
expect(test.votes1.toHex()).toEqual(
|
||||
createTypeUnsafe(registry, 'Vec<(u32, u16)>', [[
|
||||
registry.createType('Vec<(u32, u16)>', [
|
||||
[1, 3]
|
||||
]]).toHex()
|
||||
]).toHex()
|
||||
);
|
||||
});
|
||||
|
||||
it('hash valid vote2 (actual tuple values)', (): void => {
|
||||
expect(test.votes2.toHex()).toEqual(
|
||||
createTypeUnsafe(registry, 'Vec<(u32, [(u16, u16); 1], u16)>', [votes2]).toHex()
|
||||
registry.createType('Vec<(u32, [(u16, u16); 1], u16)>', votes2).toHex()
|
||||
);
|
||||
});
|
||||
|
||||
@@ -199,7 +199,7 @@ describe('CompactAssignments', (): void => {
|
||||
|
||||
it('decodes an actual solution from the chain', (): void => {
|
||||
expect(
|
||||
createTypeUnsafe(registry, '(Vec<ValidatorIndex>, CompactAssignmentsTo257, PhragmenScore, EraIndex)', [ACTUAL]).toHex()
|
||||
registry.createType('(Vec<ValidatorIndex>, CompactAssignmentsTo257, PhragmenScore, EraIndex)', ACTUAL).toHex()
|
||||
).toEqual(ACTUAL);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,7 +30,7 @@ interface IterFn {
|
||||
meta: StorageEntryMetadataLatest;
|
||||
}
|
||||
|
||||
type Arg = boolean | string | number | null | BN | BigInt | Uint8Array | Codec;
|
||||
type Arg = boolean | string | number | null | BN | bigint | Uint8Array | Codec;
|
||||
|
||||
/** @internal */
|
||||
function createKeyRaw (registry: Registry, itemFn: CreateItemFn, keys: Type[], hashers: StorageHasher[], args: Arg[]): Uint8Array {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Auto-generated by @polkadot/dev, do not edit
|
||||
|
||||
export const packageInfo = { name: '@polkadot/types', version: '5.4.1' };
|
||||
export const packageInfo = { name: '@polkadot/types', version: '5.5.2' };
|
||||
|
||||
@@ -8,4 +8,7 @@ import { Int } from '../codec/Int';
|
||||
* @description
|
||||
* A 128-bit signed integer
|
||||
*/
|
||||
export class i128 extends Int.with(128) {}
|
||||
export class i128 extends Int.with(128) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __IntType = 'i128';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { Int } from '../codec/Int';
|
||||
* @description
|
||||
* A 16-bit signed integer
|
||||
*/
|
||||
export class i16 extends Int.with(16) {}
|
||||
export class i16 extends Int.with(16) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __IntType = 'i16';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { Int } from '../codec/Int';
|
||||
* @description
|
||||
* A 256-bit signed integer
|
||||
*/
|
||||
export class i256 extends Int.with(256) {}
|
||||
export class i256 extends Int.with(256) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __IntType = 'i256';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { Int } from '../codec/Int';
|
||||
* @description
|
||||
* A 32-bit signed integer
|
||||
*/
|
||||
export class i32 extends Int.with(32) {}
|
||||
export class i32 extends Int.with(32) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __IntType = 'i32';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { Int } from '../codec/Int';
|
||||
* @description
|
||||
* A 64-bit signed integer
|
||||
*/
|
||||
export class i64 extends Int.with(64) {}
|
||||
export class i64 extends Int.with(64) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __IntType = 'i64';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { Int } from '../codec/Int';
|
||||
* @description
|
||||
* An 8-bit signed integer
|
||||
*/
|
||||
export class i8 extends Int.with(8) {}
|
||||
export class i8 extends Int.with(8) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __IntType = 'i8';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { UInt } from '../codec/UInt';
|
||||
* @description
|
||||
* A 128-bit unsigned integer
|
||||
*/
|
||||
export class u128 extends UInt.with(128) {}
|
||||
export class u128 extends UInt.with(128) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __UIntType = 'u128';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { UInt } from '../codec/UInt';
|
||||
* @description
|
||||
* A 16-bit unsigned integer
|
||||
*/
|
||||
export class u16 extends UInt.with(16) {}
|
||||
export class u16 extends UInt.with(16) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __UIntType = 'u16';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { UInt } from '../codec/UInt';
|
||||
* @description
|
||||
* A 256-bit unsigned integer
|
||||
*/
|
||||
export class u256 extends UInt.with(256) {}
|
||||
export class u256 extends UInt.with(256) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __UIntType = 'u256';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { UInt } from '../codec/UInt';
|
||||
* @description
|
||||
* A 32-bit unsigned integer
|
||||
*/
|
||||
export class u32 extends UInt.with(32) {}
|
||||
export class u32 extends UInt.with(32) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __UIntType = 'u32';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { UInt } from '../codec/UInt';
|
||||
* @description
|
||||
* A 64-bit unsigned integer
|
||||
*/
|
||||
export class u64 extends UInt.with(64) {}
|
||||
export class u64 extends UInt.with(64) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __UIntType = 'u64';
|
||||
}
|
||||
|
||||
@@ -8,4 +8,7 @@ import { UInt } from '../codec/UInt';
|
||||
* @description
|
||||
* An 8-bit unsigned integer
|
||||
*/
|
||||
export class u8 extends UInt.with(8) {}
|
||||
export class u8 extends UInt.with(8) {
|
||||
// NOTE without this, we cannot properly determine extensions
|
||||
public readonly __UIntType = 'u8';
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ export type AnyJson = string | number | boolean | null | undefined | AnyJson[] |
|
||||
|
||||
export type AnyFunction = (...args: any[]) => any;
|
||||
|
||||
export type AnyNumber = BN | BigInt | Uint8Array | number | string;
|
||||
export type AnyNumber = BN | bigint | Uint8Array | number | string;
|
||||
|
||||
export type AnyString = string | string;
|
||||
|
||||
|
||||
@@ -1,106 +1,157 @@
|
||||
// Copyright 2017-2021 @polkadot/types authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Compact, Option, Raw, Vec, VecFixed } from '../codec';
|
||||
import type { Bytes } from '../primitive';
|
||||
import type { BTreeMap, BTreeSet, CodecSet, Compact, Enum, HashMap, Linkage, Option, Range, RangeInclusive, Result, Struct, U8aFixed, Vec, VecFixed } from '../codec';
|
||||
import type { Bytes, Null, u8 } from '../primitive';
|
||||
import type { Codec, Constructor } from './codec';
|
||||
import type { ICompact, IEnum, INumber, IOption, IStruct, ITuple, IU8a, IVec } from './interfaces';
|
||||
import type { ICompact, IEnum, IMap, IMethod, INumber, IOption, IResult, ISet, IStruct, ITuple, IU8a, IVec } from './interfaces';
|
||||
import type { InterfaceTypes } from './registry';
|
||||
|
||||
export type DetectCodec<T extends Codec, K extends string> = __Expand<K, T>;
|
||||
|
||||
export type DetectConstructor<T extends Codec, K extends string> = Constructor<__Expand<K, T>>;
|
||||
|
||||
// trim leading and trailing spaces
|
||||
export type Trim<K extends string> =
|
||||
K extends ` ${infer X} ` | ` ${infer X}` | `${infer X} `
|
||||
? Trim<X>
|
||||
: K;
|
||||
|
||||
export type __Wrappers = 'Compact' | 'Option' | 'Vec';
|
||||
|
||||
export type __Expand<K extends string, T extends Codec = Codec> = __ExpandImpl<Trim<K>, T>;
|
||||
export type __ExpandImpl<K extends string, T extends Codec> =
|
||||
export type DetectCodec<T extends Codec, K extends string> =
|
||||
// This is weird - it looks the wrong way around (i.e. T check should be done first), however
|
||||
// it does work (as evident with checkTypes) and is problematic the other way around
|
||||
K extends keyof InterfaceTypes
|
||||
? InterfaceTypes[K]
|
||||
: T extends ICompact | IEnum | INumber | IOption | IStruct | ITuple | IU8a | IVec
|
||||
: T extends ICompact | IEnum | IMap | IMethod | INumber | IOption | IResult | ISet | IStruct | ITuple | IU8a | IVec
|
||||
? T
|
||||
: __Unwrap<K, T>;
|
||||
: __Codec<__Codecs<__Tokenize<__Sanitize<K>>[0]>>;
|
||||
|
||||
// ensure whatever we wrap is always Compact-capable
|
||||
export type __Compact<X extends string> = __CompactImpl<__Expand<X>>;
|
||||
export type __CompactImpl<T extends Codec> =
|
||||
T extends INumber
|
||||
? Compact<T>
|
||||
export type DetectConstructor<T extends Codec, K extends string> = Constructor<DetectCodec<T, K>>;
|
||||
|
||||
export type __Codec<V extends Codec[]> =
|
||||
V[0] extends Codec
|
||||
? V[0]
|
||||
: Codec;
|
||||
|
||||
// trim leading and trailing spaces and unused portions, e.g `...;<length>]`
|
||||
export type __Sanitize<K extends string> =
|
||||
K extends ` ${infer X}` | `${infer X} ` | ` ${infer X} `
|
||||
? __Sanitize<X>
|
||||
: K extends `${infer A} ${infer B}`
|
||||
? __Sanitize<`${A}${B}`>
|
||||
: K extends `${infer A};${string}]${infer B}`
|
||||
? __Sanitize<`${A}${B}`>
|
||||
: K extends `${infer X};${string}]`
|
||||
? __Sanitize<X>
|
||||
: K;
|
||||
|
||||
export type __Value = string | Record<string, unknown> | __Value[];
|
||||
|
||||
export type __MapWrapOne<C extends Codec> = {
|
||||
'BTreeSet<': BTreeSet<C>;
|
||||
'Compact<': C extends INumber ? Compact<C> : Codec;
|
||||
'Linkage<': Linkage<C>;
|
||||
'Option<': Option<C>;
|
||||
'Range<': C extends INumber ? Range<C> : Codec;
|
||||
'RangeInclusive<': C extends INumber ? RangeInclusive<C> : Codec;
|
||||
'Vec<': C extends u8 ? Bytes : Vec<C>;
|
||||
'[': C extends u8 ? U8aFixed : VecFixed<C>;
|
||||
};
|
||||
|
||||
// FIXME We don't cater for Int< & UInt< here. These could be problematic, since it has
|
||||
// a variable number of inner arguments, better would be to just strip them inside the sanitize
|
||||
export type __MapWrapTwo<K extends Codec, V extends Codec> = {
|
||||
'BTreeMap<': BTreeMap<K, V>;
|
||||
'HashMap<': HashMap<K, V>;
|
||||
'Result<': Result<K, V>;
|
||||
};
|
||||
|
||||
export type __WrapOne = keyof __MapWrapOne<Codec>;
|
||||
|
||||
export type __WrapTwo = keyof __MapWrapTwo<Codec, Codec>;
|
||||
|
||||
export type __Wrap = __WrapOne | __WrapTwo;
|
||||
|
||||
export type __ToStruct<K extends Record<string, unknown>> =
|
||||
K['_enum'] extends true
|
||||
? Enum
|
||||
: K['_set'] extends true
|
||||
? CodecSet
|
||||
: Struct;
|
||||
|
||||
export type __ToTuple<O extends Codec[]> =
|
||||
O[0] extends Codec
|
||||
? O[1] extends Codec
|
||||
? ITuple<O>
|
||||
: O[0]
|
||||
: Null;
|
||||
|
||||
export type __CodecFirst<K extends unknown> =
|
||||
K extends keyof InterfaceTypes
|
||||
? InterfaceTypes[K]
|
||||
: K extends unknown[]
|
||||
? __ToTuple<__Codecs<K>>
|
||||
: K extends Record<string, unknown>
|
||||
? __ToStruct<K>
|
||||
: Codec;
|
||||
|
||||
export type __CodecsNext<K extends unknown, C extends Codec[]> =
|
||||
K extends __WrapOne
|
||||
? C extends [Codec, ...infer X]
|
||||
? [__MapWrapOne<C[0]>[K], ...X]
|
||||
: Codec
|
||||
: K extends __WrapTwo
|
||||
? C extends [Codec, Codec, ...infer X]
|
||||
? [__MapWrapTwo<C[0], C[1]>[K], ...X]
|
||||
: Codec
|
||||
: [__CodecFirst<K>, ...C];
|
||||
|
||||
export type __Codecs<T extends unknown[]> =
|
||||
T extends [infer K, ...infer N]
|
||||
? __CodecsNext<K, __Codecs<N>>
|
||||
: [];
|
||||
|
||||
export type __Combine<V extends __Value[], I extends string> =
|
||||
I extends ''
|
||||
? V
|
||||
: [...V, I];
|
||||
|
||||
export type __CombineInner<V extends __Value[], I extends string, X extends __Value> =
|
||||
I extends ''
|
||||
? [...V, X]
|
||||
: [I, ...V, X];
|
||||
|
||||
// FIXME At this point enum/set/struct are empty, no field indicators, just type indicators
|
||||
export type __TokenizeStruct<T extends [__Value[], string], V extends __Value[], I extends string, R extends string> =
|
||||
__Tokenize<T[1], __CombineInner<V, I, R extends `"_set"${string}`
|
||||
? { _set: true }
|
||||
: R extends `"_enum"${string}`
|
||||
? { _enum: true }
|
||||
: { _fields: true }
|
||||
>>;
|
||||
|
||||
export type __TokenizeTuple<T extends [__Value[], string], V extends __Value[], I extends string> =
|
||||
__Tokenize<T[1], __CombineInner<V, I, T[0]>>;
|
||||
|
||||
export type __TokenizeWrapped<K extends string, V extends __Value[], I extends string, R extends string> =
|
||||
K extends `${infer X}${R}`
|
||||
? X extends '['
|
||||
? __Tokenize<R, [...__Combine<V, I>, '[']>
|
||||
: __Tokenize<R, __Combine<V, `${I}${X}`>>
|
||||
: never;
|
||||
|
||||
// handle option types
|
||||
export type __Option<X extends string> = __OptionImpl<__Expand<X>>;
|
||||
export type __OptionImpl<T extends Codec> =
|
||||
T extends Codec
|
||||
? Option<T>
|
||||
export type __TokenizeKnown<K extends string, V extends __Value[], I extends string, R extends string> =
|
||||
K extends `${infer X}${',' | '>'}${R}`
|
||||
? __Tokenize<R, __Combine<V, `${I}${X}`>>
|
||||
: never;
|
||||
|
||||
export type __Params<X extends string> = __ParamsImpl<Trim<X>>;
|
||||
export type __ParamsImpl<X extends string> =
|
||||
X extends `Vec<${infer A}>,${infer B}`
|
||||
? [__Vec<A>, ...__Params<B>]
|
||||
: X extends `Option<${infer A}>,${infer B}`
|
||||
? [__Option<A>, ...__Params<B>]
|
||||
: X extends `Vec<${infer A}>`
|
||||
? [__Vec<A>]
|
||||
: X extends `Option<${infer A}>`
|
||||
? [__Option<A>]
|
||||
: X extends `${infer A},${infer B}`
|
||||
? __ParamsTuple<A, B>
|
||||
: [__ParamsExpand<X>];
|
||||
export type __ParamsTuple<A extends string, B extends string> = __ParamsTupleImpl<Trim<A>, Trim<B>>;
|
||||
export type __ParamsTupleImpl<A extends string, B extends string> =
|
||||
B extends `(${infer C}),${infer D}`
|
||||
? [__ParamsExpand<A>, __Tuple<C>, ...__Params<D>]
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
: B extends `[${infer C}]` | `(${infer C})`
|
||||
? [__ParamsExpand<A>, __Expand<B>]
|
||||
: [__ParamsExpand<A>, ...__Params<B>];
|
||||
export type __ParamsExpand<X extends string> = __ParamsExpandImpl<Trim<X>>;
|
||||
export type __ParamsExpandImpl<X extends string> =
|
||||
// flatten nested tuples
|
||||
X extends `(${infer A})` | `(${infer A}` | `${infer A})`
|
||||
? __ParamsExpand<A>
|
||||
: __Expand<X>;
|
||||
|
||||
export type __Tuple<X extends string> = __TupleImpl<Trim<X>>;
|
||||
export type __TupleImpl<X extends string> =
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
X extends `${infer A},${infer B}`
|
||||
? ITuple<__Params<X>>
|
||||
: __Expand<X>;
|
||||
|
||||
// vec support with short-circuit for u8
|
||||
export type __Vec<X extends string> = __VecImpl<Trim<X>>;
|
||||
export type __VecImpl<X extends string> =
|
||||
X extends 'u8'
|
||||
? Bytes
|
||||
: Vec<__Expand<X>>;
|
||||
|
||||
// fixed vec support
|
||||
export type __VecFixed<X extends string, L extends string> = __VecFixedImpl<Trim<X>, L>;
|
||||
export type __VecFixedImpl<X extends string, L extends string> =
|
||||
L extends string
|
||||
? X extends 'u8'
|
||||
? Raw
|
||||
: VecFixed<__Expand<X>>
|
||||
: never;
|
||||
|
||||
export type __Unwrap<K extends string, T extends Codec> =
|
||||
K extends `Compact<${infer X}>`
|
||||
? __Compact<X>
|
||||
: K extends `Option<${infer X}>`
|
||||
? __Option<X>
|
||||
: K extends `Vec<${infer X}>`
|
||||
? __Vec<X>
|
||||
: K extends `[${infer X};${infer L}]`
|
||||
? __VecFixed<X, L>
|
||||
: K extends `(${infer X})`
|
||||
? __Tuple<X>
|
||||
: T;
|
||||
// NOTE For recursion limits, it is more optimal to use __Sanitize with conjunction with __Tokenize
|
||||
// below, even while we do more matching (Number of characters iterated through is the most problematic)
|
||||
export type __Tokenize<K extends string, V extends __Value[] = [], I extends string = ''> =
|
||||
K extends '' | '>' | ')' | '}'
|
||||
? [__Combine<V, I>, '']
|
||||
: K extends `${__Wrap}${infer R}`
|
||||
? __TokenizeWrapped<K, V, I, R>
|
||||
: K extends `${',' | '>'}${infer R}`
|
||||
? __Tokenize<R, __Combine<V, I>>
|
||||
: K extends `${')' | '}'}${infer R}`
|
||||
? [__Combine<V, I>, R]
|
||||
: K extends `(${infer R}`
|
||||
? __TokenizeTuple<__Tokenize<R>, V, I>
|
||||
: K extends `{${infer R}`
|
||||
? __TokenizeStruct<__Tokenize<R>, V, I, R>
|
||||
: K extends `${keyof InterfaceTypes}${',' | '>'}${infer R}`
|
||||
? __TokenizeKnown<K, V, I, R>
|
||||
: K extends `${infer C}${infer R}`
|
||||
? __Tokenize<R, V, `${I}${C}`>
|
||||
: [__Combine<V, I>, ''];
|
||||
|
||||
@@ -15,14 +15,18 @@ export interface ICompact<T extends INumber = INumber> extends Codec {
|
||||
}
|
||||
|
||||
export interface IEnum extends Codec {
|
||||
index: number;
|
||||
isBasic: boolean
|
||||
type: string;
|
||||
value: Codec;
|
||||
readonly defIndexes: number[];
|
||||
readonly defKeys: string[];
|
||||
readonly index: number;
|
||||
readonly isBasic: boolean
|
||||
readonly type: string;
|
||||
readonly value: Codec;
|
||||
|
||||
toNumber (): number;
|
||||
}
|
||||
|
||||
export interface IMap<K extends Codec = Codec, V extends Codec = Codec> extends Map<K, V>, Codec {}
|
||||
|
||||
export interface INumber extends Codec {
|
||||
bitLength (): number;
|
||||
toBigInt (): bigint;
|
||||
@@ -31,33 +35,52 @@ export interface INumber extends Codec {
|
||||
}
|
||||
|
||||
export interface IOption<T extends Codec = Codec> extends Codec {
|
||||
isNone: boolean;
|
||||
isSome: boolean;
|
||||
value: Codec;
|
||||
readonly isNone: boolean;
|
||||
readonly isSome: boolean;
|
||||
readonly value: Codec;
|
||||
|
||||
unwrap (): T;
|
||||
unwrapOr <O>(other: O): T | O;
|
||||
unwrapOrDefault (): T;
|
||||
}
|
||||
|
||||
export interface IStruct extends Map<unknown, Codec>, Codec {}
|
||||
export interface IResult<O extends Codec = Codec, E extends Codec = Codec> extends IEnum {
|
||||
readonly asErr: E;
|
||||
readonly asOk: O;
|
||||
readonly isErr: boolean;
|
||||
readonly isOk: boolean;
|
||||
}
|
||||
|
||||
// A type alias for [Type1, Type2] & Codec, representing a tuple (Type1, Type2)
|
||||
// FIXME Implement this generic <Sub> on Tuple.ts itself.
|
||||
export type ITuple<S extends AnyTuple = Codec[]> = S & Codec;
|
||||
export interface ISet<K = string> extends Set<K>, Codec {
|
||||
readonly strings: string[];
|
||||
}
|
||||
|
||||
export interface IStruct<K = string, V extends Codec = Codec> extends Map<K, V>, Codec {
|
||||
readonly defKeys: string[];
|
||||
|
||||
getAtIndex (index: number): Codec
|
||||
toArray (): Codec[];
|
||||
}
|
||||
|
||||
export type ITuple<T extends AnyTuple = Codec[]> = T & Codec;
|
||||
|
||||
export interface IU8a extends Uint8Array, Codec {
|
||||
readonly isAscii: boolean;
|
||||
|
||||
bitLength (): number;
|
||||
toHuman (isExtended?: boolean): any;
|
||||
toJSON (): any;
|
||||
toUtf8 (): string;
|
||||
}
|
||||
|
||||
export interface IVec<S extends Codec = Codec> extends Array<S>, Codec {}
|
||||
export interface IVec<T extends Codec = Codec> extends Array<T>, Codec {
|
||||
toArray (): T[];
|
||||
}
|
||||
|
||||
export interface IKeyringPair {
|
||||
address: string;
|
||||
addressRaw: Uint8Array;
|
||||
publicKey: Uint8Array;
|
||||
readonly address: string;
|
||||
readonly addressRaw: Uint8Array;
|
||||
readonly publicKey: Uint8Array;
|
||||
|
||||
sign: (data: Uint8Array, options?: SignOptions) => Uint8Array;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user