Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2ff40f735 | ||
|
|
9c51ea14be | ||
|
|
e3f912cef5 | ||
|
|
21808f0283 | ||
|
|
714380575c | ||
|
|
ec76f2cefd | ||
|
|
2121a1eea0 | ||
|
|
c0e0346987 | ||
|
|
9b5004df9b | ||
|
|
dd7ad37dbf | ||
|
|
92d6f6b98f | ||
|
|
fcb317d65b | ||
|
|
b8d4b034ab | ||
|
|
60398d9f47 | ||
|
|
7a1525d3e2 | ||
|
|
1ee461dd59 | ||
|
|
cfa15f98f7 | ||
|
|
18671cc650 | ||
|
|
a790e8c3ee | ||
|
|
bb6e16eac7 | ||
|
|
23e191eaf7 | ||
|
|
cec0325820 | ||
|
|
ffd8d74e3a | ||
|
|
91a04ad159 | ||
|
|
434f969208 | ||
|
|
34a5cbed90 | ||
|
|
72469ae6da | ||
|
|
14f2a9da39 | ||
|
|
12750bc83d | ||
|
|
9a2b67aa25 |
+18
-1
@@ -1,5 +1,22 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 8.14.1 Jul 23, 2022
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Update `@substrate/connect` with dual ESM/CJS support (Thanks to https://github.com/wirednkod)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- `{BTree|Hash}Map.toHuman()` now display `Raw` keys as ascii (if detected)
|
||||||
|
- Add `toPrimitive()` to all base `Codec` interfaces (string/boolean/number)
|
||||||
|
- Adjust metadata conversion with `objectSpread` (where missing)
|
||||||
|
- Support for `TransactionPaymentCallApi` runtime interface
|
||||||
|
- Check `registry.getModuleInstances` against metadata paths (fallback)
|
||||||
|
- Update to `@polkadot/util` 10.1.1
|
||||||
|
- Update to latest Kusama metadata (Substrate & Polkadot are current)
|
||||||
|
|
||||||
|
|
||||||
## 8.13.1 Jul 16, 2022
|
## 8.13.1 Jul 16, 2022
|
||||||
|
|
||||||
Changes:
|
Changes:
|
||||||
@@ -332,7 +349,7 @@ Changes:
|
|||||||
- Only explicitly support LSB on `BitVec` types
|
- Only explicitly support LSB on `BitVec` types
|
||||||
- Change `toHuman()` on `BitVec` to output default LSB
|
- Change `toHuman()` on `BitVec` to output default LSB
|
||||||
- Add `bytes{Sent, Recv}` to provider stats
|
- Add `bytes{Sent, Recv}` to provider stats
|
||||||
- Clear connection timout on provider `disconnect()`
|
- Clear connection timeout on provider `disconnect()`
|
||||||
- Add support for `dev_getBlockStats` RPC
|
- Add support for `dev_getBlockStats` RPC
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
3136 Jaco 8.13.1 (#5078)
|
3150 Jaco 8.14.1 (#5102)
|
||||||
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
|
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
|
||||||
37 Keith Ingram Update contract types and rpc (#4541)
|
37 Keith Ingram Update contract types and rpc (#4541)
|
||||||
35 Stefanie Doll Updated child storage parameters (#1709)
|
35 Stefanie Doll Updated child storage parameters (#1709)
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
15 Jeremías Díaz feat(types): add correct tuple type to storage key (#3054)
|
15 Jeremías Díaz feat(types): add correct tuple type to storage key (#3054)
|
||||||
11 Ian He HttpProvider support clone() (#3949)
|
11 Ian He HttpProvider support clone() (#3949)
|
||||||
10 Axel Chalon Make Enum/Tuple constructor use value directly if instance (#1954)
|
10 Axel Chalon Make Enum/Tuple constructor use value directly if instance (#1954)
|
||||||
6 Nikos Kontakis Bump substrate connect to 0.7.8 (#5058)
|
7 Nikos Kontakis Bump substrate connect to 0.7.9 (Add CommonJS Support) (#5088)
|
||||||
5 Chevdor Fix metadata package link (#3458)
|
5 Chevdor Fix metadata package link (#3458)
|
||||||
5 Jake Naviasky Fixing approvalFlagsToBools. (#1250)
|
5 Jake Naviasky Fixing approvalFlagsToBools. (#1250)
|
||||||
4 Alex D Use derive customAccount and customLocks for balance overrides (#3248)
|
4 Alex D Use derive customAccount and customLocks for balance overrides (#3248)
|
||||||
|
|||||||
+7
-7
@@ -11,10 +11,10 @@
|
|||||||
},
|
},
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"versions": {
|
"versions": {
|
||||||
"git": "8.13.1",
|
"git": "8.14.1",
|
||||||
"npm": "8.13.1"
|
"npm": "8.14.1"
|
||||||
},
|
},
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
@@ -34,10 +34,10 @@
|
|||||||
"test:one": "NODE_OPTIONS=--experimental-vm-modules polkadot-dev-run-test --detectOpenHandles --forceExit"
|
"test:one": "NODE_OPTIONS=--experimental-vm-modules polkadot-dev-run-test --detectOpenHandles --forceExit"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.18.6",
|
"@babel/core": "^7.18.9",
|
||||||
"@babel/register": "^7.18.6",
|
"@babel/register": "^7.18.9",
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/dev": "^0.67.79",
|
"@polkadot/dev": "^0.67.84",
|
||||||
"@polkadot/typegen": "workspace:packages/typegen",
|
"@polkadot/typegen": "workspace:packages/typegen",
|
||||||
"@types/jest": "^28.1.6",
|
"@types/jest": "^28.1.6",
|
||||||
"copyfiles": "^2.4.1"
|
"copyfiles": "^2.4.1"
|
||||||
|
|||||||
@@ -20,18 +20,18 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/api-base": "8.13.1",
|
"@polkadot/api-base": "8.14.1",
|
||||||
"@polkadot/rpc-augment": "8.13.1",
|
"@polkadot/rpc-augment": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-augment": "8.13.1",
|
"@polkadot/types-augment": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2"
|
"@polkadot/util": "^10.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/types-support": "8.13.1"
|
"@polkadot/types-support": "8.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -945,6 +945,10 @@ declare module '@polkadot/api-base/types/errors' {
|
|||||||
MetadataExceedsMaxLen: AugmentedError<ApiType>;
|
MetadataExceedsMaxLen: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount does not meet the minimum bond to either join or create a pool.
|
* The amount does not meet the minimum bond to either join or create a pool.
|
||||||
|
*
|
||||||
|
* The depositor can never unbond to a value less than
|
||||||
|
* `Pallet::depositor_min_bond`. The caller does not have nominating
|
||||||
|
* permissions for the pool. Members can never unbond to a value below `MinJoinBond`.
|
||||||
**/
|
**/
|
||||||
MinimumBondNotMet: AugmentedError<ApiType>;
|
MinimumBondNotMet: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -952,10 +956,6 @@ declare module '@polkadot/api-base/types/errors' {
|
|||||||
* other members to be permissionlessly unbonded.
|
* other members to be permissionlessly unbonded.
|
||||||
**/
|
**/
|
||||||
NotDestroying: AugmentedError<ApiType>;
|
NotDestroying: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* Not enough points. Ty unbonding less.
|
|
||||||
**/
|
|
||||||
NotEnoughPointsToUnbond: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Either a) the caller cannot make a valid kick or b) the pool is not destroying.
|
* Either a) the caller cannot make a valid kick or b) the pool is not destroying.
|
||||||
**/
|
**/
|
||||||
@@ -964,11 +964,6 @@ declare module '@polkadot/api-base/types/errors' {
|
|||||||
* The caller does not have nominating permissions for the pool.
|
* The caller does not have nominating permissions for the pool.
|
||||||
**/
|
**/
|
||||||
NotNominator: AugmentedError<ApiType>;
|
NotNominator: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The depositor must be the only member in the bonded pool in order to unbond. And the
|
|
||||||
* depositor must be the only member in the sub pools in order to withdraw unbonded.
|
|
||||||
**/
|
|
||||||
NotOnlyPoolMember: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* The pool is not open to join
|
* The pool is not open to join
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/api-augment', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,13 +20,13 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/rpc-core": "8.13.1",
|
"@polkadot/rpc-core": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"rxjs": "^7.5.6"
|
"rxjs": "^7.5.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/api-base', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,20 +20,20 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/api": "8.13.1",
|
"@polkadot/api": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/types-create": "8.13.1",
|
"@polkadot/types-create": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2",
|
"@polkadot/util-crypto": "^10.1.1",
|
||||||
"rxjs": "^7.5.6"
|
"rxjs": "^7.5.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/api-augment": "8.13.1",
|
"@polkadot/api-augment": "8.14.1",
|
||||||
"@polkadot/keyring": "^10.0.2"
|
"@polkadot/keyring": "^10.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ import { v0ToV1 } from './toV1';
|
|||||||
import { v1ToV2 } from './toV2';
|
import { v1ToV2 } from './toV2';
|
||||||
import { v2ToV3 } from './toV3';
|
import { v2ToV3 } from './toV3';
|
||||||
|
|
||||||
type Versions = 'V3' | 'V2' | 'V1' | 'V0';
|
// The versions where an enum is used, aka V0 is missing
|
||||||
|
// (Order from newest, i.e. we expect more on newest vs oldest)
|
||||||
|
export const enumVersions = <const> ['V3', 'V2', 'V1'];
|
||||||
|
|
||||||
|
type Versions = typeof enumVersions[number] | 'V0';
|
||||||
|
|
||||||
type Converter = (registry: Registry, vx: any) => ContractMetadataLatest;
|
type Converter = (registry: Registry, vx: any) => ContractMetadataLatest;
|
||||||
|
|
||||||
@@ -26,10 +30,6 @@ export const v2ToLatest = createConverter(v3ToLatest, v2ToV3);
|
|||||||
export const v1ToLatest = createConverter(v2ToLatest, v1ToV2);
|
export const v1ToLatest = createConverter(v2ToLatest, v1ToV2);
|
||||||
export const v0ToLatest = createConverter(v1ToLatest, v0ToV1);
|
export const v0ToLatest = createConverter(v1ToLatest, v0ToV1);
|
||||||
|
|
||||||
// The versions where an enum is used, aka V0 is missing
|
|
||||||
// (Order from newest, i.e. we expect more on newest vs oldest)
|
|
||||||
export const enumVersions = ['V3', 'V2', 'V1'];
|
|
||||||
|
|
||||||
export const convertVersions: [Versions, Converter][] = [
|
export const convertVersions: [Versions, Converter][] = [
|
||||||
['V3', v3ToLatest],
|
['V3', v3ToLatest],
|
||||||
['V2', v2ToLatest],
|
['V2', v2ToLatest],
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ interface ArgsEntry <T extends WithArgs> extends NamedEntry {
|
|||||||
args: GetArgsType<T>['args'][0][];
|
args: GetArgsType<T>['args'][0][];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ARG_TYPES = {
|
const ARG_TYPES = <const> {
|
||||||
ContractConstructorSpec: 'ContractMessageParamSpecV2',
|
ContractConstructorSpec: 'ContractMessageParamSpecV2',
|
||||||
ContractEventSpec: 'ContractEventParamSpecV2',
|
ContractEventSpec: 'ContractEventParamSpecV2',
|
||||||
ContractMessageSpec: 'ContractMessageParamSpecV2'
|
ContractMessageSpec: 'ContractMessageParamSpecV2'
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/api-contract', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,25 +20,25 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/api": "8.13.1",
|
"@polkadot/api": "8.14.1",
|
||||||
"@polkadot/api-augment": "8.13.1",
|
"@polkadot/api-augment": "8.14.1",
|
||||||
"@polkadot/api-base": "8.13.1",
|
"@polkadot/api-base": "8.14.1",
|
||||||
"@polkadot/rpc-core": "8.13.1",
|
"@polkadot/rpc-core": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2",
|
"@polkadot/util-crypto": "^10.1.1",
|
||||||
"rxjs": "^7.5.6"
|
"rxjs": "^7.5.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/api": "8.13.1",
|
"@polkadot/api": "8.14.1",
|
||||||
"@polkadot/api-augment": "8.13.1",
|
"@polkadot/api-augment": "8.14.1",
|
||||||
"@polkadot/rpc-augment": "8.13.1",
|
"@polkadot/rpc-augment": "8.14.1",
|
||||||
"@polkadot/rpc-provider": "8.13.1",
|
"@polkadot/rpc-provider": "8.14.1",
|
||||||
"@polkadot/types-support": "8.13.1"
|
"@polkadot/types-support": "8.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,8 @@ function querySystemAccount (api: DeriveApi, accountId: AccountId): Observable<R
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function account (instanceId: string, api: DeriveApi): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
export function account (instanceId: string, api: DeriveApi): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName, 'balances');
|
||||||
|
const nonDefaultBalances = balanceInstances && (balanceInstances.length !== 1 || balanceInstances[0] !== 'balances');
|
||||||
|
|
||||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||||
api.derive.accounts.accountId(address).pipe(
|
api.derive.accounts.accountId(address).pipe(
|
||||||
@@ -158,7 +159,7 @@ export function account (instanceId: string, api: DeriveApi): (address: AccountI
|
|||||||
(accountId
|
(accountId
|
||||||
? combineLatest([
|
? combineLatest([
|
||||||
of(accountId),
|
of(accountId),
|
||||||
balanceInstances
|
nonDefaultBalances
|
||||||
? queryBalancesAccount(api, accountId, balanceInstances)
|
? queryBalancesAccount(api, accountId, balanceInstances)
|
||||||
: isFunction(api.query.system?.account)
|
: isFunction(api.query.system?.account)
|
||||||
? querySystemAccount(api, accountId)
|
? querySystemAccount(api, accountId)
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ function queryCurrent (api: DeriveApi, accountId: AccountId | string, balanceIns
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function all (instanceId: string, api: DeriveApi): (address: AccountId | string) => Observable<DeriveBalancesAll> {
|
export function all (instanceId: string, api: DeriveApi): (address: AccountId | string) => Observable<DeriveBalancesAll> {
|
||||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName, 'balances');
|
||||||
|
|
||||||
return memo(instanceId, (address: AccountId | string): Observable<DeriveBalancesAll> =>
|
return memo(instanceId, (address: AccountId | string): Observable<DeriveBalancesAll> =>
|
||||||
combineLatest([
|
combineLatest([
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { DeriveCustom } from '@polkadot/api-base/types';
|
import type { DeriveCustom } from '@polkadot/api-base/types';
|
||||||
import type { AnyFunction } from '@polkadot/types/types';
|
import type { AnyFunction, AnyString } from '@polkadot/types/types';
|
||||||
import type { ExactDerive } from './derive';
|
import type { ExactDerive } from './derive';
|
||||||
import type { DeriveApi } from './types';
|
import type { DeriveApi } from './types';
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ const checks: Record<string, Avail> = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getModuleInstances (api: DeriveApi, specName: string, moduleName: string): string[] {
|
function getModuleInstances (api: DeriveApi, specName: AnyString, moduleName: string): string[] {
|
||||||
return api.registry.getModuleInstances(specName, moduleName) || [];
|
return api.registry.getModuleInstances(specName, moduleName) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ function injectFunctions (instanceId: string, api: DeriveApi, derives: DeriveCus
|
|||||||
const result: Record<string, Record<string, AnyFunction>> = {};
|
const result: Record<string, Record<string, AnyFunction>> = {};
|
||||||
const names = Object.keys(derives);
|
const names = Object.keys(derives);
|
||||||
const keys = Object.keys(api.query);
|
const keys = Object.keys(api.query);
|
||||||
const specName = api.runtimeVersion.specName.toString();
|
const specName = api.runtimeVersion.specName;
|
||||||
|
|
||||||
const filterKeys = (q: string) => keys.includes(q);
|
const filterKeys = (q: string) => keys.includes(q);
|
||||||
const filterInstances = (q: string) => getModuleInstances(api, specName, q).some(filterKeys);
|
const filterInstances = (q: string) => getModuleInstances(api, specName, q).some(filterKeys);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { isFunction } from '@polkadot/util';
|
|||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
export function getInstance (api: DeriveApi, section: string): DeriveApi['query']['council'] {
|
export function getInstance (api: DeriveApi, section: string): DeriveApi['query']['council'] {
|
||||||
const instances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), section);
|
const instances = api.registry.getModuleInstances(api.runtimeVersion.specName, section);
|
||||||
const name = instances && instances.length
|
const name = instances && instances.length
|
||||||
? instances[0]
|
? instances[0]
|
||||||
: section;
|
: section;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ function getConstants (api: DeriveApi, elections: string | null): Partial<Derive
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getModules (api: DeriveApi): [string, string | null] {
|
function getModules (api: DeriveApi): [string, string | null] {
|
||||||
const [council] = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'council') || ['council'];
|
const [council] = api.registry.getModuleInstances(api.runtimeVersion.specName, 'council') || ['council'];
|
||||||
const elections = api.query.phragmenElection
|
const elections = api.query.phragmenElection
|
||||||
? 'phragmenElection'
|
? 'phragmenElection'
|
||||||
: api.query.electionsPhragmen
|
: api.query.electionsPhragmen
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/api-derive', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
+18
-18
@@ -20,29 +20,29 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/api-augment": "8.13.1",
|
"@polkadot/api-augment": "8.14.1",
|
||||||
"@polkadot/api-base": "8.13.1",
|
"@polkadot/api-base": "8.14.1",
|
||||||
"@polkadot/api-derive": "8.13.1",
|
"@polkadot/api-derive": "8.14.1",
|
||||||
"@polkadot/keyring": "^10.0.2",
|
"@polkadot/keyring": "^10.1.1",
|
||||||
"@polkadot/rpc-augment": "8.13.1",
|
"@polkadot/rpc-augment": "8.14.1",
|
||||||
"@polkadot/rpc-core": "8.13.1",
|
"@polkadot/rpc-core": "8.14.1",
|
||||||
"@polkadot/rpc-provider": "8.13.1",
|
"@polkadot/rpc-provider": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-augment": "8.13.1",
|
"@polkadot/types-augment": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/types-create": "8.13.1",
|
"@polkadot/types-create": "8.14.1",
|
||||||
"@polkadot/types-known": "8.13.1",
|
"@polkadot/types-known": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2",
|
"@polkadot/util-crypto": "^10.1.1",
|
||||||
"eventemitter3": "^4.0.7",
|
"eventemitter3": "^4.0.7",
|
||||||
"rxjs": "^7.5.6"
|
"rxjs": "^7.5.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/api-augment": "8.13.1",
|
"@polkadot/api-augment": "8.14.1",
|
||||||
"@polkadot/types-support": "8.13.1"
|
"@polkadot/types-support": "8.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -626,7 +626,9 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
|
|
||||||
const lazySection = (section: string) =>
|
const lazySection = (section: string) =>
|
||||||
lazyMethods({}, Object.keys(tx[section]), (method: string) =>
|
lazyMethods({}, Object.keys(tx[section]), (method: string) =>
|
||||||
this._decorateExtrinsicEntry(tx[section][method], result)
|
method.startsWith('$')
|
||||||
|
? tx[section][method]
|
||||||
|
: this._decorateExtrinsicEntry(tx[section][method], result)
|
||||||
);
|
);
|
||||||
|
|
||||||
const sections = Object.keys(tx);
|
const sections = Object.keys(tx);
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/api', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,13 +20,13 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/rpc-core": "8.13.1",
|
"@polkadot/rpc-core": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2"
|
"@polkadot/util": "^10.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/rpc-augment', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,18 +20,18 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/rpc-augment": "8.13.1",
|
"@polkadot/rpc-augment": "8.14.1",
|
||||||
"@polkadot/rpc-provider": "8.13.1",
|
"@polkadot/rpc-provider": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"rxjs": "^7.5.6"
|
"rxjs": "^7.5.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^10.0.2",
|
"@polkadot/keyring": "^10.1.1",
|
||||||
"@polkadot/rpc-augment": "8.13.1"
|
"@polkadot/rpc-augment": "8.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/rpc-core', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,21 +20,21 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/keyring": "^10.0.2",
|
"@polkadot/keyring": "^10.1.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-support": "8.13.1",
|
"@polkadot/types-support": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2",
|
"@polkadot/util-crypto": "^10.1.1",
|
||||||
"@polkadot/x-fetch": "^10.0.2",
|
"@polkadot/x-fetch": "^10.1.1",
|
||||||
"@polkadot/x-global": "^10.0.2",
|
"@polkadot/x-global": "^10.1.1",
|
||||||
"@polkadot/x-ws": "^10.0.2",
|
"@polkadot/x-ws": "^10.1.1",
|
||||||
"@substrate/connect": "0.7.8",
|
"@substrate/connect": "0.7.9",
|
||||||
"eventemitter3": "^4.0.7",
|
"eventemitter3": "^4.0.7",
|
||||||
"mock-socket": "^9.1.5",
|
"mock-socket": "^9.1.5",
|
||||||
"nock": "^13.2.8"
|
"nock": "^13.2.9"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,4 @@
|
|||||||
export { HttpProvider } from './http';
|
export { HttpProvider } from './http';
|
||||||
export { packageInfo } from './packageInfo';
|
export { packageInfo } from './packageInfo';
|
||||||
export { WsProvider } from './ws';
|
export { WsProvider } from './ws';
|
||||||
|
export { ScProvider } from './substrate-connect';
|
||||||
// ESM-only, only export top-level when we have dual versions
|
|
||||||
// export { ScProvider } from './substrate-connect';
|
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/rpc-provider', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
|
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
|
||||||
@@ -30,21 +30,21 @@
|
|||||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
|
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.18.6",
|
"@babel/core": "^7.18.9",
|
||||||
"@babel/register": "^7.18.6",
|
"@babel/register": "^7.18.9",
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/api": "8.13.1",
|
"@polkadot/api": "8.14.1",
|
||||||
"@polkadot/api-augment": "8.13.1",
|
"@polkadot/api-augment": "8.14.1",
|
||||||
"@polkadot/rpc-augment": "8.13.1",
|
"@polkadot/rpc-augment": "8.14.1",
|
||||||
"@polkadot/rpc-provider": "8.13.1",
|
"@polkadot/rpc-provider": "8.14.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-augment": "8.13.1",
|
"@polkadot/types-augment": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/types-create": "8.13.1",
|
"@polkadot/types-create": "8.14.1",
|
||||||
"@polkadot/types-support": "8.13.1",
|
"@polkadot/types-support": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2",
|
"@polkadot/util-crypto": "^10.1.1",
|
||||||
"@polkadot/x-ws": "^10.0.2",
|
"@polkadot/x-ws": "^10.1.1",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"websocket": "^1.0.34",
|
"websocket": "^1.0.34",
|
||||||
"yargs": "^17.5.1"
|
"yargs": "^17.5.1"
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/typegen', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,12 +20,12 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2"
|
"@polkadot/util": "^10.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/types-augment', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,17 +20,17 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/x-bigint": "^10.0.2"
|
"@polkadot/x-bigint": "^10.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-augment": "8.13.1",
|
"@polkadot/types-augment": "8.14.1",
|
||||||
"@polkadot/types-support": "8.13.1",
|
"@polkadot/types-support": "8.14.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2"
|
"@polkadot/util-crypto": "^10.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,6 +140,19 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
|
const result = new Array<AnyJson>(this.length);
|
||||||
|
|
||||||
|
for (let i = 0; i < this.length; i++) {
|
||||||
|
result[i] = this[i] && this[i].toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -83,6 +83,13 @@ export abstract class AbstractBase<T extends Codec> implements Codec {
|
|||||||
return this.#raw.toJSON();
|
return this.#raw.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
|
return this.#raw.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the string representation of the value
|
* @description Returns the string representation of the value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -207,6 +207,15 @@ export abstract class AbstractInt extends BN implements INumber {
|
|||||||
: this.toNumber();
|
: this.toNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Returns the value in a primitive form, either number when <= 52 bits, or string otherwise
|
||||||
|
*/
|
||||||
|
public toPrimitive (): number | string {
|
||||||
|
return super.bitLength() > MAX_NUMBER_BITS
|
||||||
|
? this.toString()
|
||||||
|
: this.toNumber();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -171,6 +171,13 @@ export class Compact<T extends INumber> implements ICompact<T> {
|
|||||||
return this.#raw.toNumber();
|
return this.#raw.toNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): string | number {
|
||||||
|
return this.#raw.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -72,6 +72,10 @@ export class DoNotConstruct implements Codec {
|
|||||||
throw this.#neverError;
|
throw this.#neverError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toPrimitive (): AnyJson {
|
||||||
|
throw this.#neverError;
|
||||||
|
}
|
||||||
|
|
||||||
toRawType (): string {
|
toRawType (): string {
|
||||||
throw this.#neverError;
|
throw this.#neverError;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -414,6 +414,15 @@ export class Enum implements IEnum {
|
|||||||
return this.index;
|
return this.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
|
return this.#isBasic
|
||||||
|
? this.type
|
||||||
|
: { [stringCamelCase(this.type)]: this.#raw.toPrimitive() };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns a raw struct representation of the enum types
|
* @description Returns a raw struct representation of the enum types
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -69,6 +69,13 @@ export class Null implements Codec {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): null {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -206,6 +206,15 @@ export class Option<T extends Codec> implements IOption<T> {
|
|||||||
: this.#raw.toJSON();
|
: this.#raw.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
|
return this.isNone
|
||||||
|
? null
|
||||||
|
: this.#raw.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -193,6 +193,19 @@ export class BTreeSet<V extends Codec = Codec> extends Set<V> implements ISet<V>
|
|||||||
return `BTreeSet<${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
return `BTreeSet<${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
|
const json: AnyJson = [];
|
||||||
|
|
||||||
|
for (const v of this.values()) {
|
||||||
|
json.push(v.toPrimitive());
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the string representation of the value
|
* @description Returns the string representation of the value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { compactFromU8aLim, compactToU8a, isHex, isObject, isU8a, logger, string
|
|||||||
|
|
||||||
import { AbstractArray } from '../abstract/Array';
|
import { AbstractArray } from '../abstract/Array';
|
||||||
import { Enum } from '../base/Enum';
|
import { Enum } from '../base/Enum';
|
||||||
|
import { Raw } from '../native/Raw';
|
||||||
import { Struct } from '../native/Struct';
|
import { Struct } from '../native/Struct';
|
||||||
import { compareMap, decodeU8a, sortMap, typeToConstructor } from '../utils';
|
import { compareMap, decodeU8a, sortMap, typeToConstructor } from '../utils';
|
||||||
|
|
||||||
@@ -182,7 +183,11 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
|
|||||||
const json: Record<string, AnyJson> = {};
|
const json: Record<string, AnyJson> = {};
|
||||||
|
|
||||||
for (const [k, v] of this.entries()) {
|
for (const [k, v] of this.entries()) {
|
||||||
json[k.toString()] = v.toHuman(isExtended);
|
json[
|
||||||
|
k instanceof Raw && k.isAscii
|
||||||
|
? k.toUtf8()
|
||||||
|
: k.toString()
|
||||||
|
] = v.toHuman(isExtended);
|
||||||
}
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
@@ -201,6 +206,23 @@ export class CodecMap<K extends Codec = Codec, V extends Codec = Codec> extends
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
|
const json: Record<string, AnyJson> = {};
|
||||||
|
|
||||||
|
for (const [k, v] of this.entries()) {
|
||||||
|
json[
|
||||||
|
k instanceof Raw && k.isAscii
|
||||||
|
? k.toUtf8()
|
||||||
|
: k.toString()
|
||||||
|
] = v.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -92,6 +92,15 @@ export class WrapperKeepOpaque<T extends Codec> extends Bytes {
|
|||||||
: super.toHuman();
|
: super.toHuman();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public override toPrimitive (): any {
|
||||||
|
return this.#decoded
|
||||||
|
? this.#decoded.toPrimitive()
|
||||||
|
: super.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -105,6 +105,13 @@ export class bool extends Boolean implements Codec {
|
|||||||
return this.valueOf();
|
return this.valueOf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): boolean {
|
||||||
|
return this.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -136,6 +136,13 @@ export class CodecDate extends Date implements INumber {
|
|||||||
return Math.ceil(this.getTime() / 1000);
|
return Math.ceil(this.getTime() / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): number {
|
||||||
|
return this.toNumber();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -112,6 +112,13 @@ export class Float extends Number implements IFloat {
|
|||||||
return this.valueOf();
|
return this.valueOf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): number {
|
||||||
|
return this.toNumber();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -109,6 +109,19 @@ export class Json extends Map<string, any> implements Codec {
|
|||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): Record<string, AnyJson> {
|
||||||
|
return [...this.entries()].reduce<Record<string, AnyJson>>((json, [key, value]): Record<string, AnyJson> => {
|
||||||
|
json[key] = isFunction((value as Codec).toHuman)
|
||||||
|
? (value as Codec).toPrimitive()
|
||||||
|
: value as AnyJson;
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ describe('Raw', (): void => {
|
|||||||
|
|
||||||
testEncode('toJSON', '0x0102030405');
|
testEncode('toJSON', '0x0102030405');
|
||||||
testEncode('toHex', '0x0102030405');
|
testEncode('toHex', '0x0102030405');
|
||||||
|
testEncode('toPrimitive', '0x0102030405');
|
||||||
testEncode('toString', '0x0102030405');
|
testEncode('toString', '0x0102030405');
|
||||||
testEncode('toU8a', Uint8Array.from([1, 2, 3, 4, 5]));
|
testEncode('toU8a', Uint8Array.from([1, 2, 3, 4, 5]));
|
||||||
|
|
||||||
@@ -79,6 +80,11 @@ describe('Raw', (): void => {
|
|||||||
expect(new Raw(registry, '0x2021222324').isAscii).toBe(true);
|
expect(new Raw(registry, '0x2021222324').isAscii).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has valid toPrimitive', (): void => {
|
||||||
|
expect(new Raw(registry, 'testing').toPrimitive()).toEqual('testing');
|
||||||
|
expect(new Raw(registry, '0xe4bda0e5a5bd').toPrimitive()).toEqual('0xe4bda0e5a5bd');
|
||||||
|
});
|
||||||
|
|
||||||
it('has valid toUtf8', (): void => {
|
it('has valid toUtf8', (): void => {
|
||||||
expect(new Raw(registry, 'Приветствую, ми').toUtf8()).toEqual('Приветствую, ми');
|
expect(new Raw(registry, 'Приветствую, ми').toUtf8()).toEqual('Приветствую, ми');
|
||||||
expect(new Raw(registry, '0xe4bda0e5a5bd').toUtf8()).toEqual('你好');
|
expect(new Raw(registry, '0xe4bda0e5a5bd').toUtf8()).toEqual('你好');
|
||||||
|
|||||||
@@ -111,6 +111,20 @@ export class Raw extends Uint8Array implements IU8a {
|
|||||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||||
*/
|
*/
|
||||||
public toHuman (): AnyJson {
|
public toHuman (): AnyJson {
|
||||||
|
return this.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||||
|
*/
|
||||||
|
public toJSON (): string {
|
||||||
|
return this.toHex();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): AnyJson {
|
||||||
if (this.isAscii) {
|
if (this.isAscii) {
|
||||||
const text = this.toUtf8();
|
const text = this.toUtf8();
|
||||||
|
|
||||||
@@ -123,13 +137,6 @@ export class Raw extends Uint8Array implements IU8a {
|
|||||||
return this.toJSON();
|
return this.toJSON();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
|
||||||
*/
|
|
||||||
public toJSON (): string {
|
|
||||||
return this.toHex();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -229,6 +229,13 @@ export class CodecSet extends Set<string> implements ISet<string> {
|
|||||||
return this.valueEncoded.toNumber();
|
return this.valueEncoded.toNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): string[] {
|
||||||
|
return this.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -33,6 +33,116 @@ describe('Struct', (): void => {
|
|||||||
testDecode('hex', '0x1c62617a7a696e6745000000');
|
testDecode('hex', '0x1c62617a7a696e6745000000');
|
||||||
testDecode('object', { foo: 'bazzing', bar: 69 });
|
testDecode('object', { foo: 'bazzing', bar: 69 });
|
||||||
testDecode('Uint8Array', Uint8Array.from([28, 98, 97, 122, 122, 105, 110, 103, 69, 0, 0, 0]));
|
testDecode('Uint8Array', Uint8Array.from([28, 98, 97, 122, 122, 105, 110, 103, 69, 0, 0, 0]));
|
||||||
|
|
||||||
|
it('decodes null/undefined/empty correctly (& equivalent)', (): void => {
|
||||||
|
const Clazz = Struct.with({
|
||||||
|
txt: Text,
|
||||||
|
u32: U32
|
||||||
|
});
|
||||||
|
const expected = { txt: '', u32: '0' };
|
||||||
|
|
||||||
|
expect(new Clazz(registry, {}).toHuman()).toEqual(expected);
|
||||||
|
expect(new Clazz(registry, null).toHuman()).toEqual(expected);
|
||||||
|
expect(new Clazz(registry, undefined).toHuman()).toEqual(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('decodes with Optionals', (): void => {
|
||||||
|
const Clazz = Struct.with({
|
||||||
|
a: 'Option<Bool>',
|
||||||
|
b: 'Option<Bool>'
|
||||||
|
});
|
||||||
|
|
||||||
|
const c = new Clazz(registry, { a: false }) as unknown as { a: Option<Bool>, b: Option<Bool> };
|
||||||
|
|
||||||
|
expect(c.a.isSome).toEqual(true);
|
||||||
|
expect(c.a.unwrap().isTrue).toEqual(false);
|
||||||
|
expect(c.b.isSome).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('decodes reusing instantiated inputs', (): void => {
|
||||||
|
const foo = new Text(registry, 'bar');
|
||||||
|
|
||||||
|
expect(
|
||||||
|
(new Struct(
|
||||||
|
registry,
|
||||||
|
{ foo: Text },
|
||||||
|
{ foo }
|
||||||
|
)).get('foo')
|
||||||
|
).toBe(foo);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('decodes a more complicated type', (): void => {
|
||||||
|
const s = new Struct(registry, {
|
||||||
|
foo: Vec.with(Struct.with({
|
||||||
|
bar: Text
|
||||||
|
}))
|
||||||
|
}, { foo: [{ bar: 1 }, { bar: 2 }] });
|
||||||
|
|
||||||
|
expect(s.toString()).toBe('{"foo":[{"bar":"1"},{"bar":"2"}]}');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('decodes a previously problematic input', (): void => {
|
||||||
|
let data;
|
||||||
|
|
||||||
|
try {
|
||||||
|
data = new Struct(registry, {
|
||||||
|
a: 'u32',
|
||||||
|
b: 'H256',
|
||||||
|
c: 'H256',
|
||||||
|
swap: Enum.with({
|
||||||
|
A: 'u256',
|
||||||
|
B: 'u256'
|
||||||
|
}),
|
||||||
|
d: Vec.with('u8'),
|
||||||
|
e: 'u8'
|
||||||
|
}, TEST_A);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(data.get('d')).toHaveLength(50000);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('decodes from a Map input', (): void => {
|
||||||
|
const s = new Struct(registry, {
|
||||||
|
txt: Text,
|
||||||
|
foo: U32,
|
||||||
|
bar: U32
|
||||||
|
}, new Map<string, unknown>([['a', 42], ['txt', 'fubar']]));
|
||||||
|
|
||||||
|
expect(s.toString()).toEqual('{"txt":"fubar","foo":0,"bar":0}');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('decodes from a snake_case input', (): void => {
|
||||||
|
const input = new Struct(registry, {
|
||||||
|
snakeCaseA: U32,
|
||||||
|
snakeCaseB: Text,
|
||||||
|
other: U32
|
||||||
|
}, { snake_case_a: 42, snake_case_b: 'fubar', other: 69 } as any);
|
||||||
|
|
||||||
|
expect(input.toString()).toEqual('{"snakeCaseA":42,"snakeCaseB":"fubar","other":69}');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws when it cannot decode', (): void => {
|
||||||
|
expect(
|
||||||
|
(): Struct<any> => new (
|
||||||
|
Struct.with({
|
||||||
|
txt: Text,
|
||||||
|
u32: U32
|
||||||
|
})
|
||||||
|
)(registry, 'ABC')
|
||||||
|
).toThrowError(/Cannot decode value/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('throws a sensical error on incorrect array values passed to structs', (): void => {
|
||||||
|
expect(
|
||||||
|
() => new Struct(registry, {
|
||||||
|
_: 'Vec<u32>'
|
||||||
|
}, [123, 456])
|
||||||
|
).toThrow(/array to object with known keys/);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('encoding', (): void => {
|
describe('encoding', (): void => {
|
||||||
@@ -52,116 +162,6 @@ describe('Struct', (): void => {
|
|||||||
testEncode('toString', '{"foo":"bazzing","bar":69}');
|
testEncode('toString', '{"foo":"bazzing","bar":69}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('decodes null/undefined/empty correctly (& equivalently)', (): void => {
|
|
||||||
const Clazz = Struct.with({
|
|
||||||
txt: Text,
|
|
||||||
u32: U32
|
|
||||||
});
|
|
||||||
const expected = { txt: '', u32: '0' };
|
|
||||||
|
|
||||||
expect(new Clazz(registry, {}).toHuman()).toEqual(expected);
|
|
||||||
expect(new Clazz(registry, null).toHuman()).toEqual(expected);
|
|
||||||
expect(new Clazz(registry, undefined).toHuman()).toEqual(expected);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decodes with Optionals', (): void => {
|
|
||||||
const Clazz = Struct.with({
|
|
||||||
a: 'Option<Bool>',
|
|
||||||
b: 'Option<Bool>'
|
|
||||||
});
|
|
||||||
|
|
||||||
const c = new Clazz(registry, { a: false }) as unknown as { a: Option<Bool>, b: Option<Bool> };
|
|
||||||
|
|
||||||
expect(c.a.isSome).toEqual(true);
|
|
||||||
expect(c.a.unwrap().isTrue).toEqual(false);
|
|
||||||
expect(c.b.isSome).toEqual(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decodes reusing instantiated inputs', (): void => {
|
|
||||||
const foo = new Text(registry, 'bar');
|
|
||||||
|
|
||||||
expect(
|
|
||||||
(new Struct(
|
|
||||||
registry,
|
|
||||||
{ foo: Text },
|
|
||||||
{ foo }
|
|
||||||
)).get('foo')
|
|
||||||
).toBe(foo);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decodes a more complicated type', (): void => {
|
|
||||||
const s = new Struct(registry, {
|
|
||||||
foo: Vec.with(Struct.with({
|
|
||||||
bar: Text
|
|
||||||
}))
|
|
||||||
}, { foo: [{ bar: 1 }, { bar: 2 }] });
|
|
||||||
|
|
||||||
expect(s.toString()).toBe('{"foo":[{"bar":"1"},{"bar":"2"}]}');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decodes a previously problematic input', (): void => {
|
|
||||||
let data;
|
|
||||||
|
|
||||||
try {
|
|
||||||
data = new Struct(registry, {
|
|
||||||
a: 'u32',
|
|
||||||
b: 'H256',
|
|
||||||
c: 'H256',
|
|
||||||
swap: Enum.with({
|
|
||||||
A: 'u256',
|
|
||||||
B: 'u256'
|
|
||||||
}),
|
|
||||||
d: Vec.with('u8'),
|
|
||||||
e: 'u8'
|
|
||||||
}, TEST_A);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(data.get('d')).toHaveLength(50000);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decodes from a Map input', (): void => {
|
|
||||||
const s = new Struct(registry, {
|
|
||||||
txt: Text,
|
|
||||||
foo: U32,
|
|
||||||
bar: U32
|
|
||||||
}, new Map<string, unknown>([['a', 42], ['txt', 'fubar']]));
|
|
||||||
|
|
||||||
expect(s.toString()).toEqual('{"txt":"fubar","foo":0,"bar":0}');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decodes from a snake_case input', (): void => {
|
|
||||||
const input = new Struct(registry, {
|
|
||||||
snakeCaseA: U32,
|
|
||||||
snakeCaseB: Text,
|
|
||||||
other: U32
|
|
||||||
}, { snake_case_a: 42, snake_case_b: 'fubar', other: 69 } as any);
|
|
||||||
|
|
||||||
expect(input.toString()).toEqual('{"snakeCaseA":42,"snakeCaseB":"fubar","other":69}');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('throws when it cannot decode', (): void => {
|
|
||||||
expect(
|
|
||||||
(): Struct<any> => new (
|
|
||||||
Struct.with({
|
|
||||||
txt: Text,
|
|
||||||
u32: U32
|
|
||||||
})
|
|
||||||
)(registry, 'ABC')
|
|
||||||
).toThrowError(/Cannot decode value/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('throws a sensical error on incorrect array values passed to structs', (): void => {
|
|
||||||
expect(
|
|
||||||
() => new Struct(registry, {
|
|
||||||
_: 'Vec<u32>'
|
|
||||||
}, [123, 456])
|
|
||||||
).toThrow(/array to object with known keys/);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('provides a clean toString()', (): void => {
|
it('provides a clean toString()', (): void => {
|
||||||
expect(
|
expect(
|
||||||
new (
|
new (
|
||||||
@@ -257,6 +257,83 @@ describe('Struct', (): void => {
|
|||||||
}, test).eq(test)
|
}, test).eq(test)
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has a sane toPrimitive', (): void => {
|
||||||
|
const S = Struct.with({
|
||||||
|
name: 'Text',
|
||||||
|
description: 'Vec<Text>',
|
||||||
|
fooA: 'Bytes',
|
||||||
|
fooB: 'Bytes',
|
||||||
|
fooC: Struct.with({
|
||||||
|
a: 'u32',
|
||||||
|
b: 'u128',
|
||||||
|
c: 'Compact<u128>',
|
||||||
|
d: 'bool'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
new S(registry, {
|
||||||
|
name: 'Something',
|
||||||
|
description: ['One line', 'Another line'],
|
||||||
|
fooA: 'hello world!',
|
||||||
|
fooB: '0x123456',
|
||||||
|
fooC: {
|
||||||
|
a: 1234,
|
||||||
|
b: BigInt('1234567890111213141516'),
|
||||||
|
c: 123456,
|
||||||
|
d: true
|
||||||
|
}
|
||||||
|
}).toPrimitive()
|
||||||
|
).toEqual({
|
||||||
|
name: 'Something',
|
||||||
|
description: ['One line', 'Another line'],
|
||||||
|
fooA: 'hello world!',
|
||||||
|
fooB: '0x123456',
|
||||||
|
fooC: {
|
||||||
|
a: 1234,
|
||||||
|
b: '1234567890111213141516',
|
||||||
|
c: 123456,
|
||||||
|
d: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('generates sane toRawType', (): void => {
|
||||||
|
expect(
|
||||||
|
new Struct(registry, {
|
||||||
|
accountId: 'AccountId',
|
||||||
|
balanceCompact: registry.createClass('Compact<Balance>'),
|
||||||
|
blockNumber: registry.createClass('BlockNumber'),
|
||||||
|
compactNumber: registry.createClass('Compact<BlockNumber>'),
|
||||||
|
optionNumber: registry.createClass('Option<BlockNumber>'),
|
||||||
|
counter: U32,
|
||||||
|
vector: Vec.with('AccountId')
|
||||||
|
}).toRawType()
|
||||||
|
).toEqual(JSON.stringify({
|
||||||
|
accountId: 'AccountId',
|
||||||
|
balanceCompact: 'Compact<Balance>', // Override in Uint
|
||||||
|
blockNumber: 'BlockNumber',
|
||||||
|
compactNumber: 'Compact<BlockNumber>',
|
||||||
|
optionNumber: 'Option<BlockNumber>',
|
||||||
|
counter: 'u32',
|
||||||
|
vector: 'Vec<AccountId>'
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('generates sane toRawType (via with)', (): void => {
|
||||||
|
const Type = Struct.with({
|
||||||
|
accountId: 'AccountId',
|
||||||
|
balance: registry.createClass('Balance')
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(
|
||||||
|
new Type(registry).toRawType()
|
||||||
|
).toEqual(JSON.stringify({
|
||||||
|
accountId: 'AccountId',
|
||||||
|
balance: 'Balance' // Override in Uint
|
||||||
|
}));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('allows toString with large numbers', (): void => {
|
it('allows toString with large numbers', (): void => {
|
||||||
@@ -268,42 +345,6 @@ describe('Struct', (): void => {
|
|||||||
).toEqual('{"blockNumber":279694831}');
|
).toEqual('{"blockNumber":279694831}');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates sane toRawType', (): void => {
|
|
||||||
expect(
|
|
||||||
new Struct(registry, {
|
|
||||||
accountId: 'AccountId',
|
|
||||||
balanceCompact: registry.createClass('Compact<Balance>'),
|
|
||||||
blockNumber: registry.createClass('BlockNumber'),
|
|
||||||
compactNumber: registry.createClass('Compact<BlockNumber>'),
|
|
||||||
optionNumber: registry.createClass('Option<BlockNumber>'),
|
|
||||||
counter: U32,
|
|
||||||
vector: Vec.with('AccountId')
|
|
||||||
}).toRawType()
|
|
||||||
).toEqual(JSON.stringify({
|
|
||||||
accountId: 'AccountId',
|
|
||||||
balanceCompact: 'Compact<Balance>', // Override in Uint
|
|
||||||
blockNumber: 'BlockNumber',
|
|
||||||
compactNumber: 'Compact<BlockNumber>',
|
|
||||||
optionNumber: 'Option<BlockNumber>',
|
|
||||||
counter: 'u32',
|
|
||||||
vector: 'Vec<AccountId>'
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('generates sane toRawType (via with)', (): void => {
|
|
||||||
const Type = Struct.with({
|
|
||||||
accountId: 'AccountId',
|
|
||||||
balance: registry.createClass('Balance')
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(
|
|
||||||
new Type(registry).toRawType()
|
|
||||||
).toEqual(JSON.stringify({
|
|
||||||
accountId: 'AccountId',
|
|
||||||
balance: 'Balance' // Override in Uint
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toU8a', (): void => {
|
describe('toU8a', (): void => {
|
||||||
const def: Record<string, any> = {
|
const def: Record<string, any> = {
|
||||||
foo: 'Bytes',
|
foo: 'Bytes',
|
||||||
|
|||||||
@@ -293,6 +293,23 @@ export class Struct<
|
|||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): Record<string, AnyJson> {
|
||||||
|
const json: Record<string, AnyJson> = {};
|
||||||
|
|
||||||
|
for (const [k, v] of this.entries()) {
|
||||||
|
const jsonKey = this.#jsonMap.get(k) || k;
|
||||||
|
|
||||||
|
// We actually log inside the U8a decoding and use JSON.stringify(...), which
|
||||||
|
// means that the Vec may be partially populated (same applies to toHuman, same check)
|
||||||
|
json[jsonKey as string] = v && v.toPrimitive();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -147,6 +147,13 @@ export class Text extends String implements IText {
|
|||||||
return this.toString();
|
return this.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public toPrimitive (): string {
|
||||||
|
return this.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/types-codec', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ export interface Codec {
|
|||||||
*/
|
*/
|
||||||
toJSON (): AnyJson;
|
toJSON (): AnyJson;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
toPrimitive (): AnyJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
@@ -105,6 +110,6 @@ export interface CodecClass<T = Codec> {
|
|||||||
new(registry: Registry, ...args: any[]): T;
|
new(registry: Registry, ...args: any[]): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CodecTo = 'toHex' | 'toJSON' | 'toString' | 'toU8a';
|
export type CodecTo = 'toHex' | 'toJSON' | 'toPrimitive' | 'toString' | 'toU8a';
|
||||||
|
|
||||||
export type ArgsDef = Record<string, CodecClass | string>;
|
export type ArgsDef = Record<string, CodecClass | string>;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export interface INumber extends Codec {
|
|||||||
toBigInt (): bigint;
|
toBigInt (): bigint;
|
||||||
toBn (): BN;
|
toBn (): BN;
|
||||||
toNumber (): number;
|
toNumber (): number;
|
||||||
|
toPrimitive (): string | number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IFloat extends Codec {
|
export interface IFloat extends Codec {
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2"
|
"@polkadot/util": "^10.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/types": "8.13.1"
|
"@polkadot/types": "8.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/types-create', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/networks": "^10.0.2",
|
"@polkadot/networks": "^10.1.1",
|
||||||
"@polkadot/types": "8.13.1",
|
"@polkadot/types": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/types-create": "8.13.1",
|
"@polkadot/types-create": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2"
|
"@polkadot/util": "^10.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/types-known', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -20,10 +20,10 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/util": "^10.0.2"
|
"@polkadot/util": "^10.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -41967,7 +41967,11 @@
|
|||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 8,
|
"index": 8,
|
||||||
"docs": [
|
"docs": [
|
||||||
"The amount does not meet the minimum bond to either join or create a pool."
|
"The amount does not meet the minimum bond to either join or create a pool.",
|
||||||
|
"",
|
||||||
|
"The depositor can never unbond to a value less than",
|
||||||
|
"`Pallet::depositor_min_bond`. The caller does not have nominating",
|
||||||
|
"permissions for the pool. Members can never unbond to a value below `MinJoinBond`."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -41987,19 +41991,10 @@
|
|||||||
"other members to be permissionlessly unbonded."
|
"other members to be permissionlessly unbonded."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "NotOnlyPoolMember",
|
|
||||||
"fields": [],
|
|
||||||
"index": 11,
|
|
||||||
"docs": [
|
|
||||||
"The depositor must be the only member in the bonded pool in order to unbond. And the",
|
|
||||||
"depositor must be the only member in the sub pools in order to withdraw unbonded."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "NotNominator",
|
"name": "NotNominator",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 12,
|
"index": 11,
|
||||||
"docs": [
|
"docs": [
|
||||||
"The caller does not have nominating permissions for the pool."
|
"The caller does not have nominating permissions for the pool."
|
||||||
]
|
]
|
||||||
@@ -42007,7 +42002,7 @@
|
|||||||
{
|
{
|
||||||
"name": "NotKickerOrDestroying",
|
"name": "NotKickerOrDestroying",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 13,
|
"index": 12,
|
||||||
"docs": [
|
"docs": [
|
||||||
"Either a) the caller cannot make a valid kick or b) the pool is not destroying."
|
"Either a) the caller cannot make a valid kick or b) the pool is not destroying."
|
||||||
]
|
]
|
||||||
@@ -42015,7 +42010,7 @@
|
|||||||
{
|
{
|
||||||
"name": "NotOpen",
|
"name": "NotOpen",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 14,
|
"index": 13,
|
||||||
"docs": [
|
"docs": [
|
||||||
"The pool is not open to join"
|
"The pool is not open to join"
|
||||||
]
|
]
|
||||||
@@ -42023,7 +42018,7 @@
|
|||||||
{
|
{
|
||||||
"name": "MaxPools",
|
"name": "MaxPools",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 15,
|
"index": 14,
|
||||||
"docs": [
|
"docs": [
|
||||||
"The system is maxed out on pools."
|
"The system is maxed out on pools."
|
||||||
]
|
]
|
||||||
@@ -42031,7 +42026,7 @@
|
|||||||
{
|
{
|
||||||
"name": "MaxPoolMembers",
|
"name": "MaxPoolMembers",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 16,
|
"index": 15,
|
||||||
"docs": [
|
"docs": [
|
||||||
"Too many members in the pool or system."
|
"Too many members in the pool or system."
|
||||||
]
|
]
|
||||||
@@ -42039,7 +42034,7 @@
|
|||||||
{
|
{
|
||||||
"name": "CanNotChangeState",
|
"name": "CanNotChangeState",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 17,
|
"index": 16,
|
||||||
"docs": [
|
"docs": [
|
||||||
"The pools state cannot be changed."
|
"The pools state cannot be changed."
|
||||||
]
|
]
|
||||||
@@ -42047,7 +42042,7 @@
|
|||||||
{
|
{
|
||||||
"name": "DoesNotHavePermission",
|
"name": "DoesNotHavePermission",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 18,
|
"index": 17,
|
||||||
"docs": [
|
"docs": [
|
||||||
"The caller does not have adequate permissions."
|
"The caller does not have adequate permissions."
|
||||||
]
|
]
|
||||||
@@ -42055,7 +42050,7 @@
|
|||||||
{
|
{
|
||||||
"name": "MetadataExceedsMaxLen",
|
"name": "MetadataExceedsMaxLen",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 19,
|
"index": 18,
|
||||||
"docs": [
|
"docs": [
|
||||||
"Metadata exceeds [`Config::MaxMetadataLen`]"
|
"Metadata exceeds [`Config::MaxMetadataLen`]"
|
||||||
]
|
]
|
||||||
@@ -42070,24 +42065,16 @@
|
|||||||
"docs": []
|
"docs": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"index": 20,
|
"index": 19,
|
||||||
"docs": [
|
"docs": [
|
||||||
"Some error occurred that should never happen. This should be reported to the",
|
"Some error occurred that should never happen. This should be reported to the",
|
||||||
"maintainers."
|
"maintainers."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "NotEnoughPointsToUnbond",
|
|
||||||
"fields": [],
|
|
||||||
"index": 21,
|
|
||||||
"docs": [
|
|
||||||
"Not enough points. Ty unbonding less."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "PartialUnbondNotAllowedPermissionlessly",
|
"name": "PartialUnbondNotAllowedPermissionlessly",
|
||||||
"fields": [],
|
"fields": [],
|
||||||
"index": 22,
|
"index": 20,
|
||||||
"docs": [
|
"docs": [
|
||||||
"Partial unbonding now allowed permissionlessly."
|
"Partial unbonding now allowed permissionlessly."
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/types-support', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/types-support', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
+10
-10
@@ -20,20 +20,20 @@
|
|||||||
"./detectPackage.cjs"
|
"./detectPackage.cjs"
|
||||||
],
|
],
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "8.13.1",
|
"version": "8.14.1",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.18.6",
|
"@babel/runtime": "^7.18.9",
|
||||||
"@polkadot/keyring": "^10.0.2",
|
"@polkadot/keyring": "^10.1.1",
|
||||||
"@polkadot/types-augment": "8.13.1",
|
"@polkadot/types-augment": "8.14.1",
|
||||||
"@polkadot/types-codec": "8.13.1",
|
"@polkadot/types-codec": "8.14.1",
|
||||||
"@polkadot/types-create": "8.13.1",
|
"@polkadot/types-create": "8.14.1",
|
||||||
"@polkadot/util": "^10.0.2",
|
"@polkadot/util": "^10.1.1",
|
||||||
"@polkadot/util-crypto": "^10.0.2",
|
"@polkadot/util-crypto": "^10.1.1",
|
||||||
"rxjs": "^7.5.6"
|
"rxjs": "^7.5.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^10.0.2",
|
"@polkadot/keyring": "^10.1.1",
|
||||||
"@polkadot/types-support": "8.13.1"
|
"@polkadot/types-support": "8.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2017-2022 @polkadot/types authors & contributors
|
// Copyright 2017-2022 @polkadot/types authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Codec, CodecClass, IU8a } from '@polkadot/types-codec/types';
|
import type { AnyString, Codec, CodecClass, IU8a } from '@polkadot/types-codec/types';
|
||||||
import type { CreateOptions, TypeDef } from '@polkadot/types-create/types';
|
import type { CreateOptions, TypeDef } from '@polkadot/types-create/types';
|
||||||
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
||||||
import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant } from '../interfaces/types';
|
import type { ChainProperties, DispatchErrorModule, DispatchErrorModuleU8, DispatchErrorModuleU8a, EventMetadataLatest, Hash, MetadataLatest, SiField, SiLookupTypeId, SiVariant } from '../interfaces/types';
|
||||||
@@ -105,20 +105,48 @@ function injectEvents (registry: TypeRegistry, { lookup, pallets }: MetadataLate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create extrinsic mapping from metadata
|
// create extrinsic mapping from metadata
|
||||||
function injectExtrinsics (registry: TypeRegistry, { lookup, pallets }: MetadataLatest, version: number, result: Record<string, Record<string, CallFunction>>): void {
|
function injectExtrinsics (registry: TypeRegistry, { lookup, pallets }: MetadataLatest, version: number, result: Record<string, Record<string, CallFunction>>, mapping: Record<string, string[]>): void {
|
||||||
const filtered = pallets.filter(filterCallsSome);
|
const filtered = pallets.filter(filterCallsSome);
|
||||||
|
|
||||||
clearRecord(result);
|
clearRecord(result);
|
||||||
|
clearRecord(mapping);
|
||||||
|
|
||||||
for (let i = 0; i < filtered.length; i++) {
|
for (let i = 0; i < filtered.length; i++) {
|
||||||
const { calls, index, name } = filtered[i];
|
const { calls, index, name } = filtered[i];
|
||||||
const sectionIndex = version >= 12 ? index.toNumber() : i;
|
const sectionIndex = version >= 12 ? index.toNumber() : i;
|
||||||
|
const sectionName = stringCamelCase(name);
|
||||||
|
const allCalls = calls.unwrap();
|
||||||
|
|
||||||
lazyMethod(result, sectionIndex, () =>
|
lazyMethod(result, sectionIndex, () =>
|
||||||
lazyVariants(lookup, calls.unwrap(), getVariantStringIdx, (variant: SiVariant) =>
|
lazyVariants(lookup, allCalls, getVariantStringIdx, (variant: SiVariant) =>
|
||||||
createCallFunction(registry, lookup, variant, stringCamelCase(name), sectionIndex)
|
createCallFunction(registry, lookup, variant, sectionName, sectionIndex)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const { path } = registry.lookup.getSiType(allCalls.type);
|
||||||
|
|
||||||
|
// frame_system::pallet::Call / pallet_balances::pallet::Call / polkadot_runtime_parachains::configuration::pallet::Call /
|
||||||
|
const palletIdx = path.findIndex((v) => v.eq('pallet'));
|
||||||
|
|
||||||
|
if (palletIdx !== -1) {
|
||||||
|
const name = stringCamelCase(
|
||||||
|
path
|
||||||
|
.slice(0, palletIdx)
|
||||||
|
.map((p, i) =>
|
||||||
|
i === 0
|
||||||
|
// frame_system || pallet_balances
|
||||||
|
? p.replace(/^(frame|pallet)_/, '')
|
||||||
|
: p
|
||||||
|
)
|
||||||
|
.join(' ')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!mapping[name]) {
|
||||||
|
mapping[name] = [sectionName];
|
||||||
|
} else {
|
||||||
|
mapping[name].push(sectionName);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,6 +184,8 @@ export class TypeRegistry implements Registry {
|
|||||||
|
|
||||||
readonly #metadataEvents: Record<string, Record<string, CodecClass<GenericEventData>>> = {};
|
readonly #metadataEvents: Record<string, Record<string, CodecClass<GenericEventData>>> = {};
|
||||||
|
|
||||||
|
readonly #moduleMap: Record<string, string[]> = {};
|
||||||
|
|
||||||
#unknownTypes = new Map<string, boolean>();
|
#unknownTypes = new Map<string, boolean>();
|
||||||
|
|
||||||
#chainProperties?: ChainProperties;
|
#chainProperties?: ChainProperties;
|
||||||
@@ -403,8 +433,8 @@ export class TypeRegistry implements Registry {
|
|||||||
return this.#definitions.get(typeName);
|
return this.#definitions.get(typeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getModuleInstances (specName: string, moduleName: string): string[] | undefined {
|
public getModuleInstances (specName: AnyString, moduleName: string): string[] | undefined {
|
||||||
return this.#knownTypes?.typesBundle?.spec?.[specName]?.instances?.[moduleName];
|
return this.#knownTypes?.typesBundle?.spec?.[specName.toString()]?.instances?.[moduleName] || this.#moduleMap[moduleName];
|
||||||
}
|
}
|
||||||
|
|
||||||
public getOrThrow <T extends Codec = Codec, K extends string = string, R = DetectCodec<T, K>> (name: K, msg?: string): CodecClass<R> {
|
public getOrThrow <T extends Codec = Codec, K extends string = string, R = DetectCodec<T, K>> (name: K, msg?: string): CodecClass<R> {
|
||||||
@@ -527,7 +557,7 @@ export class TypeRegistry implements Registry {
|
|||||||
// attach the lookup at this point (before injecting)
|
// attach the lookup at this point (before injecting)
|
||||||
this.setLookup(this.#metadata.lookup);
|
this.setLookup(this.#metadata.lookup);
|
||||||
|
|
||||||
injectExtrinsics(this, this.#metadata, this.#metadataVersion, this.#metadataCalls);
|
injectExtrinsics(this, this.#metadata, this.#metadataVersion, this.#metadataCalls, this.#moduleMap);
|
||||||
injectErrors(this, this.#metadata, this.#metadataVersion, this.#metadataErrors);
|
injectErrors(this, this.#metadata, this.#metadataVersion, this.#metadataErrors);
|
||||||
injectEvents(this, this.#metadata, this.#metadataVersion, this.#metadataEvents);
|
injectEvents(this, this.#metadata, this.#metadataVersion, this.#metadataEvents);
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ export class GenericEthereumAccountId extends U8aFixed {
|
|||||||
return this.toString();
|
return this.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public override toPrimitive (): string {
|
||||||
|
return this.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the string representation of the value
|
* @description Returns the string representation of the value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ describe('Extrinsic', (): void => {
|
|||||||
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0]));
|
expect(extrinsic.callIndex).toEqual(new Uint8Array([6, 0]));
|
||||||
expect(extrinsic.args[0].toHex()).toEqual('0x00495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718');
|
expect(extrinsic.args[0].toHex()).toEqual('0x00495e1e506f266418af07fa0c5c108dd436f2faa59fe7d9e54403779f5bbd7718');
|
||||||
expect(extrinsic.args[1].toHuman()).toEqual('104,560,923,320,000'); // ('104.5609 Unit');
|
expect(extrinsic.args[1].toHuman()).toEqual('104,560,923,320,000'); // ('104.5609 Unit');
|
||||||
|
expect(extrinsic.toPrimitive()).toEqual({ method: { args: { dest: { id: '5DiuK2zR4asj2CEh77SKtUgTswTLkD8eiAKrByg5G3wL5w9b' }, value: 104560923320000 }, callIndex: '0x0600' }, signature: { era: { mortalEra: [1024, 186] }, nonce: 68, signature: { ed25519: '0xd99ffe3e610ad234e1414bda5831395a6df9098bf80b01561ce89a5065ae89d5c10e1619c6c99131b0bea4fb73ef04d07c07770e2ae9df5c325c331769ccb300' }, signer: { id: '5Hn8KKEp8qruCGWaN9MEsjTs4FXB4wv9xn7g1RWkNeKKNXCr' }, tip: 30000000000 } });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,6 +62,13 @@ export class GenericAccountId extends U8aFixed {
|
|||||||
return this.toString();
|
return this.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public override toPrimitive (): string {
|
||||||
|
return this.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the string representation of the value
|
* @description Returns the string representation of the value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ export class GenericAccountIndex extends u32 {
|
|||||||
return this.toString();
|
return this.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public override toPrimitive (): string {
|
||||||
|
return this.toJSON();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the string representation of the value
|
* @description Returns the string representation of the value
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ export class GenericCallIndex extends U8aFixed {
|
|||||||
constructor (registry: Registry, value?: AnyU8a) {
|
constructor (registry: Registry, value?: AnyU8a) {
|
||||||
super(registry, value, 16);
|
super(registry, value, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public override toPrimitive (): string {
|
||||||
|
return this.toHex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { GenericVote } from '.';
|
|||||||
describe('GenericVote', (): void => {
|
describe('GenericVote', (): void => {
|
||||||
const registry = new TypeRegistry();
|
const registry = new TypeRegistry();
|
||||||
|
|
||||||
describe.only('construction', (): void => {
|
describe('construction', (): void => {
|
||||||
it('constructs via boolean true', (): void => {
|
it('constructs via boolean true', (): void => {
|
||||||
expect(new GenericVote(registry, true).toU8a()).toEqual(new Uint8Array([128]));
|
expect(new GenericVote(registry, true).toU8a()).toEqual(new Uint8Array([128]));
|
||||||
expect(new GenericVote(registry, true).isAye).toBe(true);
|
expect(new GenericVote(registry, true).isAye).toBe(true);
|
||||||
@@ -58,7 +58,7 @@ describe('GenericVote', (): void => {
|
|||||||
expect(new GenericVote(registry, new Uint8Array([1])).isNay).toBe(true);
|
expect(new GenericVote(registry, new Uint8Array([1])).isNay).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it.only('constructs via Uint8Array (aye)', (): void => {
|
it('constructs via Uint8Array (aye)', (): void => {
|
||||||
const test = new GenericVote(registry, new Uint8Array([0b10000010]));
|
const test = new GenericVote(registry, new Uint8Array([0b10000010]));
|
||||||
|
|
||||||
expect(test.isNay).toBe(false);
|
expect(test.isNay).toBe(false);
|
||||||
@@ -68,12 +68,20 @@ describe('GenericVote', (): void => {
|
|||||||
|
|
||||||
describe('Vote with conviction', (): void => {
|
describe('Vote with conviction', (): void => {
|
||||||
it('constructs Vote with raw boolean', (): void => {
|
it('constructs Vote with raw boolean', (): void => {
|
||||||
|
const vote = new GenericVote(registry, {
|
||||||
|
aye: true,
|
||||||
|
conviction: 'Locked1x'
|
||||||
|
});
|
||||||
|
|
||||||
expect(
|
expect(
|
||||||
new GenericVote(registry, {
|
vote.toU8a()
|
||||||
aye: true,
|
|
||||||
conviction: 'Locked1x'
|
|
||||||
}).toU8a()
|
|
||||||
).toEqual(new Uint8Array([0b10000001]));
|
).toEqual(new Uint8Array([0b10000001]));
|
||||||
|
expect(
|
||||||
|
vote.toPrimitive()
|
||||||
|
).toEqual({
|
||||||
|
aye: true,
|
||||||
|
conviction: 'Locked1x'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('constructs with Vote aye is false, conviction is None', (): void => {
|
it('constructs with Vote aye is false, conviction is None', (): void => {
|
||||||
|
|||||||
@@ -115,6 +115,16 @@ export class GenericVote extends U8aFixed {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Converts the value in a best-fit primitive form
|
||||||
|
*/
|
||||||
|
public override toPrimitive (): any {
|
||||||
|
return {
|
||||||
|
aye: this.isAye,
|
||||||
|
conviction: this.conviction.toPrimitive()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Returns the base runtime type name for this instance
|
* @description Returns the base runtime type name for this instance
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
// order important in structs... :)
|
// order important in structs... :)
|
||||||
/* eslint-disable sort-keys */
|
/* eslint-disable sort-keys */
|
||||||
|
|
||||||
export const AllHashers = {
|
export const AllHashers = <const> {
|
||||||
Blake2_128: null, // eslint-disable-line camelcase
|
Blake2_128: null, // eslint-disable-line camelcase
|
||||||
Blake2_256: null, // eslint-disable-line camelcase
|
Blake2_256: null, // eslint-disable-line camelcase
|
||||||
Blake2_128Concat: null, // eslint-disable-line camelcase
|
Blake2_128Concat: null, // eslint-disable-line camelcase
|
||||||
|
|||||||
@@ -38,5 +38,40 @@ export const runtime: DefinitionsCall = {
|
|||||||
},
|
},
|
||||||
version: 1
|
version: 1
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
TransactionPaymentCallApi: [
|
||||||
|
{
|
||||||
|
methods: {
|
||||||
|
query_call_fee_details: {
|
||||||
|
description: 'The call fee details',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
name: 'call',
|
||||||
|
type: 'Call'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'len',
|
||||||
|
type: 'u32'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
type: 'FeeDetails'
|
||||||
|
},
|
||||||
|
query_call_info: {
|
||||||
|
description: 'The call info',
|
||||||
|
params: [
|
||||||
|
{
|
||||||
|
name: 'call',
|
||||||
|
type: 'Call'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'len',
|
||||||
|
type: 'u32'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
type: 'RuntimeDispatchInfo'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
version: 1
|
||||||
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,11 +17,15 @@ import { toLatest } from './v14/toLatest';
|
|||||||
import { MagicNumber } from './MagicNumber';
|
import { MagicNumber } from './MagicNumber';
|
||||||
import { getUniqTypes, toCallsOnly } from './util';
|
import { getUniqTypes, toCallsOnly } from './util';
|
||||||
|
|
||||||
type MetaMapped = MetadataV9 | MetadataV10 | MetadataV11 | MetadataV12 | MetadataV13 | MetadataV14;
|
// Use these to generate all the Meta* types below via template keys
|
||||||
type MetaAsX = 'asV9' | 'asV10' | 'asV11' | 'asV12' | 'asV13' | 'asV14';
|
// NOTE: Keep from latest -> earliest, see the LATEST_VERSION 0 index
|
||||||
type MetaVersions = 'latest' | 9 | 10 | 11 | 12 | 13 | 14;
|
const KNOWN_VERSIONS = <const> [14, 13, 12, 11, 10, 9];
|
||||||
|
const LATEST_VERSION = KNOWN_VERSIONS[0];
|
||||||
|
|
||||||
const LATEST_VERSION = 14;
|
type MetaAll = typeof KNOWN_VERSIONS[number];
|
||||||
|
type MetaAsX = `asV${MetaAll}`;
|
||||||
|
type MetaMapped = MetadataAll[MetaAsX];
|
||||||
|
type MetaVersions = MetaAll | 'latest';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name MetadataVersioned
|
* @name MetadataVersioned
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import type { AnyJson, Registry } from '@polkadot/types-codec/types';
|
|||||||
import type { MetadataLatest, PalletCallMetadataLatest } from '../../interfaces/metadata';
|
import type { MetadataLatest, PalletCallMetadataLatest } from '../../interfaces/metadata';
|
||||||
|
|
||||||
import { Option, Text, u8 } from '@polkadot/types-codec';
|
import { Option, Text, u8 } from '@polkadot/types-codec';
|
||||||
|
import { objectSpread } from '@polkadot/util';
|
||||||
|
|
||||||
interface ModuleMetadataTrimmed {
|
interface ModuleMetadataTrimmed {
|
||||||
calls: Option<PalletCallMetadataLatest>;
|
calls: Option<PalletCallMetadataLatest>;
|
||||||
@@ -29,10 +30,7 @@ export function toCallsOnly (registry: Registry, { extrinsic, lookup, pallets }:
|
|||||||
types: lookup.types.map(({ id, type }) =>
|
types: lookup.types.map(({ id, type }) =>
|
||||||
registry.createTypeUnsafe('PortableType', [{
|
registry.createTypeUnsafe('PortableType', [{
|
||||||
id,
|
id,
|
||||||
type: {
|
type: objectSpread({}, type, { docs: trimDocs(type.docs) })
|
||||||
...type,
|
|
||||||
docs: trimDocs(type.docs)
|
|
||||||
}
|
|
||||||
}])
|
}])
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
import type { Registry } from '@polkadot/types-codec/types';
|
import type { Registry } from '@polkadot/types-codec/types';
|
||||||
import type { MetadataV11, MetadataV12, ModuleMetadataV12 } from '../../interfaces/metadata';
|
import type { MetadataV11, MetadataV12, ModuleMetadataV12 } from '../../interfaces/metadata';
|
||||||
|
|
||||||
|
import { objectSpread } from '@polkadot/util';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @internal
|
* @internal
|
||||||
**/
|
**/
|
||||||
@@ -11,10 +13,7 @@ export function toV12 (registry: Registry, { extrinsic, modules }: MetadataV11):
|
|||||||
return registry.createTypeUnsafe('MetadataV12', [{
|
return registry.createTypeUnsafe('MetadataV12', [{
|
||||||
extrinsic,
|
extrinsic,
|
||||||
modules: modules.map((mod): ModuleMetadataV12 =>
|
modules: modules.map((mod): ModuleMetadataV12 =>
|
||||||
registry.createTypeUnsafe('ModuleMetadataV12', [{
|
registry.createTypeUnsafe('ModuleMetadataV12', [objectSpread({}, mod, { index: 255 })])
|
||||||
...mod,
|
|
||||||
index: 255
|
|
||||||
}])
|
|
||||||
)
|
)
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
import type { Registry } from '@polkadot/types-codec/types';
|
import type { Registry } from '@polkadot/types-codec/types';
|
||||||
import type { MetadataV9, MetadataV10, ModuleMetadataV9, ModuleMetadataV10, StorageEntryMetadataV9, StorageEntryTypeV9, StorageHasherV9, StorageHasherV10 } from '../../interfaces/metadata';
|
import type { MetadataV9, MetadataV10, ModuleMetadataV9, ModuleMetadataV10, StorageEntryMetadataV9, StorageEntryTypeV9, StorageHasherV9, StorageHasherV10 } from '../../interfaces/metadata';
|
||||||
|
|
||||||
|
import { objectSpread } from '@polkadot/util';
|
||||||
|
|
||||||
// migrate a storage hasher type
|
// migrate a storage hasher type
|
||||||
// see https://github.com/paritytech/substrate/pull/4462
|
// see https://github.com/paritytech/substrate/pull/4462
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@@ -20,18 +22,16 @@ function createStorageHasher (registry: Registry, hasher: StorageHasherV9): Stor
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
function createStorageType (registry: Registry, entryType: StorageEntryTypeV9): [any, number] {
|
function createStorageType (registry: Registry, entryType: StorageEntryTypeV9): [any, number] {
|
||||||
if (entryType.isMap) {
|
if (entryType.isMap) {
|
||||||
return [{
|
return [objectSpread({}, entryType.asMap, {
|
||||||
...entryType.asMap,
|
|
||||||
hasher: createStorageHasher(registry, entryType.asMap.hasher)
|
hasher: createStorageHasher(registry, entryType.asMap.hasher)
|
||||||
}, 1];
|
}), 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entryType.isDoubleMap) {
|
if (entryType.isDoubleMap) {
|
||||||
return [{
|
return [objectSpread({}, entryType.asDoubleMap, {
|
||||||
...entryType.asDoubleMap,
|
|
||||||
hasher: createStorageHasher(registry, entryType.asDoubleMap.hasher),
|
hasher: createStorageHasher(registry, entryType.asDoubleMap.hasher),
|
||||||
key2Hasher: createStorageHasher(registry, entryType.asDoubleMap.key2Hasher)
|
key2Hasher: createStorageHasher(registry, entryType.asDoubleMap.key2Hasher)
|
||||||
}, 2];
|
}), 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [entryType.asPlain, 0];
|
return [entryType.asPlain, 0];
|
||||||
@@ -41,18 +41,17 @@ function createStorageType (registry: Registry, entryType: StorageEntryTypeV9):
|
|||||||
function convertModule (registry: Registry, mod: ModuleMetadataV9): ModuleMetadataV10 {
|
function convertModule (registry: Registry, mod: ModuleMetadataV9): ModuleMetadataV10 {
|
||||||
const storage = mod.storage.unwrapOr(null);
|
const storage = mod.storage.unwrapOr(null);
|
||||||
|
|
||||||
return registry.createTypeUnsafe('ModuleMetadataV10', [{
|
return registry.createTypeUnsafe('ModuleMetadataV10', [objectSpread({}, mod, {
|
||||||
...mod,
|
|
||||||
storage: storage
|
storage: storage
|
||||||
? {
|
? objectSpread({}, storage, {
|
||||||
...storage,
|
items: storage.items.map((item: StorageEntryMetadataV9): any =>
|
||||||
items: storage.items.map((item: StorageEntryMetadataV9): any => ({
|
objectSpread({}, item, {
|
||||||
...item,
|
type: registry.createTypeUnsafe('StorageEntryTypeV10', createStorageType(registry, item.type))
|
||||||
type: registry.createTypeUnsafe('StorageEntryTypeV10', createStorageType(registry, item.type))
|
})
|
||||||
}))
|
)
|
||||||
}
|
})
|
||||||
: null
|
: null
|
||||||
}]);
|
})]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Do not edit, auto-generated by @polkadot/dev
|
// Do not edit, auto-generated by @polkadot/dev
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/types', path: 'auto', type: 'auto', version: '8.13.1' };
|
export const packageInfo = { name: '@polkadot/types', path: 'auto', type: 'auto', version: '8.14.1' };
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import '@polkadot/types-codec/types/registry';
|
import '@polkadot/types-codec/types/registry';
|
||||||
import '@polkadot/types-create/types/augmentRegistry';
|
import '@polkadot/types-create/types/augmentRegistry';
|
||||||
|
|
||||||
import type { Codec, CodecClass } from '@polkadot/types-codec/types';
|
import type { AnyString, Codec, CodecClass } from '@polkadot/types-codec/types';
|
||||||
import type { TypeDef } from '@polkadot/types-create/types';
|
import type { TypeDef } from '@polkadot/types-create/types';
|
||||||
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
import type { ExtDef } from '../extrinsic/signedExtensions/types';
|
||||||
import type { MetadataLatest } from '../interfaces/metadata';
|
import type { MetadataLatest } from '../interfaces/metadata';
|
||||||
@@ -41,7 +41,7 @@ declare module '@polkadot/types-codec/types/registry' {
|
|||||||
get <T extends Codec = Codec, K extends string = string> (name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<DetectCodec<T, K>> | undefined;
|
get <T extends Codec = Codec, K extends string = string> (name: K, withUnknown?: boolean, knownTypeDef?: TypeDef): CodecClass<DetectCodec<T, K>> | undefined;
|
||||||
getChainProperties (): ChainProperties | undefined;
|
getChainProperties (): ChainProperties | undefined;
|
||||||
getDefinition (typeName: string): string | undefined;
|
getDefinition (typeName: string): string | undefined;
|
||||||
getModuleInstances (specName: string, moduleName: string): string[] | undefined;
|
getModuleInstances (specName: AnyString, moduleName: string): string[] | undefined;
|
||||||
|
|
||||||
setKnownTypes (types: RegisteredTypes): void;
|
setKnownTypes (types: RegisteredTypes): void;
|
||||||
setChainProperties (properties?: ChainProperties): void;
|
setChainProperties (properties?: ChainProperties): void;
|
||||||
|
|||||||
Reference in New Issue
Block a user