Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69c129595e | ||
|
|
3f79415e02 | ||
|
|
8747cd4682 | ||
|
|
dd9e96c3e7 | ||
|
|
1c93388de7 | ||
|
|
7a87034f0e | ||
|
|
9e4db51dd7 | ||
|
|
5382cb60b0 | ||
|
|
d6b2760de5 | ||
|
|
2ee89b8c72 | ||
|
|
802da709f0 | ||
|
|
836346909f | ||
|
|
8ec5c2abc3 | ||
|
|
cc953efd58 | ||
|
|
857b9cbaea | ||
|
|
4551093fe7 | ||
|
|
69afe1a203 | ||
|
|
f5600afa31 | ||
|
|
3f0a471484 | ||
|
|
bc0e2cfc14 | ||
|
|
3e9d2d6b8f | ||
|
|
3b48825fe6 | ||
|
|
5e4e5cbaa7 | ||
|
|
255b8047b7 | ||
|
|
87edaa5bed | ||
|
|
8a58f018a7 | ||
|
|
e39be09c97 | ||
|
|
007b4aa6c1 | ||
|
|
cc2a4dbfdd | ||
|
|
e2cde32cba | ||
|
|
2a5f584f42 | ||
|
|
cc60eeb663 | ||
|
|
edb0a40843 | ||
|
|
f0c45733ee | ||
|
|
a40028a1e4 | ||
|
|
789089c80d | ||
|
|
41925a9893 | ||
|
|
4ac3a1fa80 | ||
|
|
5025e3656d | ||
|
|
e0a7ff8c8d | ||
|
|
36aea69b75 | ||
|
|
74c7925491 | ||
|
|
f1edf476e8 | ||
|
|
b321a4adbc | ||
|
|
d7f87defee | ||
|
|
420b1d9724 | ||
|
|
bc0391ef3e | ||
|
|
296cffa266 | ||
|
|
77a9b2bfdf | ||
|
|
b0109c1c83 | ||
|
|
37033f5068 | ||
|
|
ed9a760bcb | ||
|
|
b4eda7d137 | ||
|
|
830871515b | ||
|
|
e4a19dcefd | ||
|
|
11d5a4edf0 | ||
|
|
2eb901a954 | ||
|
|
b63164d6ea | ||
|
|
c40fa16217 | ||
|
|
afcbe96fd1 | ||
|
|
7d53c4b45d | ||
|
|
62bfcf84dd | ||
|
|
b2cfac4edd | ||
|
|
7b2e5ed59f | ||
|
|
fdab9818d5 | ||
|
|
85fc0bff7d | ||
|
|
7a545de0c2 | ||
|
|
b22b26d021 | ||
|
|
30f72f915e | ||
|
|
b522bc76af | ||
|
|
fee3c6b1be | ||
|
|
79bed8eda3 | ||
|
|
1aae7b59bb | ||
|
|
2d84bac287 | ||
|
|
789957b0af | ||
|
|
d26f289199 | ||
|
|
1fe06e63e5 | ||
|
|
3790f48e03 | ||
|
|
fc5aae8a84 | ||
|
|
0c79e13aba | ||
|
|
6e65bdbb5c | ||
|
|
95d113e03f | ||
|
|
a9a92d0bf8 | ||
|
|
c1fb6e8218 | ||
|
|
7cfc1950ae | ||
|
|
fabf9e9160 | ||
|
|
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 |
+80
-1
@@ -1,5 +1,84 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 9.2.2 Aug 16, 2022
|
||||
|
||||
Changes:
|
||||
|
||||
- Replace `rpc.payment.queryInfo` usage with `call.transactionPaymentApi.queryInfo`
|
||||
- Ensure that `api.call.*` is decorated on historic blocks
|
||||
|
||||
|
||||
## 9.2.1 Aug 13, 2022
|
||||
|
||||
- **Important** If using `import { WellKnownChain } from '@polkadot/rpc-provider'` it is recommended that you rather use `ScProvider.WellKnownChain` (the import may be dropped in a future major version)
|
||||
|
||||
Changes:
|
||||
|
||||
- Don't assume non-empty path specifiers on portable variant/composites
|
||||
- Explicit param length checks for all generic portable overrides
|
||||
- Re-export `ScProvider` in `@polkadot/api`, aligning with `{Http, Ws}Provider`
|
||||
- Expose `WellKnownChain` as static on `ScProvider.WellKnownChain`
|
||||
- Checks for non-available interface types & runtime/rpc definitions
|
||||
- Ensure `.entries/.keys` arguments is less than map-entry query
|
||||
- Add Polkadot 9260 upgrade block
|
||||
- Add Westend 9271 upgrade block
|
||||
- Update to latest Substrate metadata
|
||||
|
||||
|
||||
## 9.1.1 Aug 6, 2022
|
||||
|
||||
Contributed:
|
||||
|
||||
- Update `@substrate/connect` to latest (Thanks to https://github.com/wirednkod)
|
||||
- Handle both string and object keys in `CodecMap` (Thanks to https://github.com/CertainLach)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `noInitWarn: boolean` flag to API options, disabling runtime & RPC warnings
|
||||
- Only log missing runtime calls on new (detected) specVersion
|
||||
- Add shallow/one-blockHash cache for `api.at(...)` instances
|
||||
- Add Westend 9270 upgrade block
|
||||
- Update to latest Substrate, Polkadot & Kusama metadata
|
||||
|
||||
|
||||
## 9.0.1 Jul 30, 2022
|
||||
|
||||
- **Breaking change** The decorated field getters on `Struct` were moved to the prototype class for performance reasons. While `struct.<field>` access still behaves in the same way, with the same results, this does mean that the prototype getters are not visible when doing an `Object.keys(struct)` or when doing an object spread.
|
||||
- **Breaking change** Deprecated interfaces have been removed including `tx.sign(...)` (use `signAsync`), `Result.{is, as}Error` (use `{is, as}Err`) as well as storage `.range(...)` operations.
|
||||
- **Breaking change** Deprecated interfaces on `api-contract` have been removed. Always ensure you pass an options object to construction and query methods.
|
||||
- **Breaking change** Contracts access via `api-contract` will now detect the usage of `storageDepositLimit` in params, if not available the contract interfaces will not be decorated.
|
||||
|
||||
Changes:
|
||||
|
||||
- Decorate `Struct/Enum/Set` field getters on class prototypes
|
||||
- Convert `api-contract` usage of `api.rpc.*` to `api.call.*`
|
||||
- Drop support for contract runtimes without `storageDepositLimit` (runtime `contractsApi` only has support for latest)
|
||||
- Export `api.rx.call.*` for internal usage (derive, contracts)
|
||||
- Remove old-style param passing as opposed to options in `api-contract`
|
||||
- Support for alliance/motion collective derives
|
||||
- Add Kusama 9260 upgrade block
|
||||
- Add Polkadot 9230 & 9250 upgrade blocks
|
||||
- Add Westend 9251, 9260 & 9261 upgrade blocks
|
||||
- Update to latest Substrate, Polkadot & Kusama metadata
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
Changes:
|
||||
@@ -332,7 +411,7 @@ Changes:
|
||||
- Only explicitly support LSB on `BitVec` types
|
||||
- Change `toHuman()` on `BitVec` to output default LSB
|
||||
- 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
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
3136 Jaco 8.13.1 (#5078)
|
||||
3192 Jaco 9.2.2 (#5166)
|
||||
83 Amaury Martiny StatementKind: Regular and Saft (#2303)
|
||||
37 Keith Ingram Update contract types and rpc (#4541)
|
||||
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)
|
||||
11 Ian He HttpProvider support clone() (#3949)
|
||||
10 Axel Chalon Make Enum/Tuple constructor use value directly if instance (#1954)
|
||||
6 Nikos Kontakis Bump substrate connect to 0.7.8 (#5058)
|
||||
8 Nikos Kontakis Bump substrate connect to 0.7.10; Fixes #5120 (#5123)
|
||||
5 Chevdor Fix metadata package link (#3458)
|
||||
5 Jake Naviasky Fixing approvalFlagsToBools. (#1250)
|
||||
4 Alex D Use derive customAccount and customLocks for balance overrides (#3248)
|
||||
@@ -41,6 +41,7 @@
|
||||
2 sung wu Update tx.md (#2485)
|
||||
2 Veliko Abi constructor takes different parameters (#3347)
|
||||
2 Wei Tang Use /usr/bin/env bash instead of /bin/bash (#2053)
|
||||
2 Yaroslav Bolyukin feat: allow objects to be supplied as map keys (#5128)
|
||||
2 Zannis Kalampoukis fix: Typegen handles structs and vectors of structs without erroring (#4743)
|
||||
2 扩散性百万甜面包 Typo, deocrateMethod -> decorateMethod (#1594)
|
||||
1 Alan Sapede Adds Eth feeHistory & maxPriorityFeePerGas rpc (#4956)
|
||||
@@ -101,7 +102,6 @@
|
||||
1 Sergei Pepyakin INK! -> ink! (#1347)
|
||||
1 WoeOm adapt Darwinia, Crab Network types (#3498)
|
||||
1 Xat_MassacrE Fix packages/types/src/codec/utils/encodeTypes.ts encodeSubTypes bug (#1544)
|
||||
1 Yaroslav Bolyukin Support BTreeMap/BTreeSet in typegen (#4682)
|
||||
1 yjh fix MetadataVersioned.asV12 (#2983)
|
||||
1 Yuri fixes #3693 Fix uniques return types (#3694)
|
||||
1 Zeke Mostov fix: Allow sudo for polkadot indexed proxy enum (#3286)
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"imports": {
|
||||
"https://esm.sh/v90/@types/bn.js@~5.2/index.d.ts": "https://esm.sh/v90/@types/bn.js@5.1.0/index.d.ts"
|
||||
}
|
||||
}
|
||||
+9
-8
@@ -11,10 +11,10 @@
|
||||
},
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"versions": {
|
||||
"git": "8.13.1",
|
||||
"npm": "8.13.1"
|
||||
"git": "9.2.2",
|
||||
"npm": "9.2.2"
|
||||
},
|
||||
"workspaces": [
|
||||
"packages/*"
|
||||
@@ -23,6 +23,7 @@
|
||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||
"build:extra": "(cd packages/typegen && copyfiles scripts/* build)",
|
||||
"build:interfaces": "polkadot-types-internal-interfaces",
|
||||
"build:metadata": "yarn build:interfaces && yarn test:one packages/types/src/metadata/v14",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"build:rollup": "polkadot-exec-rollup --config",
|
||||
"chain:info": "polkadot-types-chain-info",
|
||||
@@ -34,12 +35,12 @@
|
||||
"test:one": "NODE_OPTIONS=--experimental-vm-modules polkadot-dev-run-test --detectOpenHandles --forceExit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/register": "^7.18.6",
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/dev": "^0.67.79",
|
||||
"@babel/core": "^7.18.10",
|
||||
"@babel/register": "^7.18.9",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/dev": "^0.67.97",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^28.1.6",
|
||||
"@types/jest": "^28.1.7",
|
||||
"copyfiles": "^2.4.1"
|
||||
},
|
||||
"resolutions": {
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api-base": "8.13.1",
|
||||
"@polkadot/rpc-augment": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-augment": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/api-base": "9.2.2",
|
||||
"@polkadot/rpc-augment": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-augment": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types-support": "8.13.1"
|
||||
"@polkadot/types-support": "9.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -945,6 +945,10 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
MetadataExceedsMaxLen: AugmentedError<ApiType>;
|
||||
/**
|
||||
* 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>;
|
||||
/**
|
||||
@@ -952,10 +956,6 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* other members to be permissionlessly unbonded.
|
||||
**/
|
||||
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.
|
||||
**/
|
||||
@@ -964,11 +964,6 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* The caller does not have nominating permissions for the pool.
|
||||
**/
|
||||
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
|
||||
**/
|
||||
|
||||
@@ -585,12 +585,12 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* pool.
|
||||
* - `points` is the number of points that are issued as a result of `balance` being
|
||||
* dissolved into the corresponding unbonding pool.
|
||||
*
|
||||
* - `era` is the era in which the balance will be unbonded.
|
||||
* In the absence of slashing, these values will match. In the presence of slashing, the
|
||||
* number of points that are issued in the unbonding pool will be less than the amount
|
||||
* requested to be unbonded.
|
||||
**/
|
||||
Unbonded: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, balance: u128, points: u128], { member: AccountId32, poolId: u32, balance: u128, points: u128 }>;
|
||||
Unbonded: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, balance: u128, points: u128, era: u32], { member: AccountId32, poolId: u32, balance: u128, points: u128, era: u32 }>;
|
||||
/**
|
||||
* The unbond pool at `era` of pool `pool_id` has been slashed to `balance`.
|
||||
**/
|
||||
|
||||
@@ -1532,10 +1532,6 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* This is basically in sync with the call to [`pallet_session::SessionManager::new_session`].
|
||||
**/
|
||||
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Rewards for the last `HISTORY_DEPTH` eras.
|
||||
* If reward hasn't been set or has been removed then 0 reward is returned.
|
||||
|
||||
@@ -17,9 +17,10 @@ import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AuthorityList, GrandpaEquivocationProof, SetId } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
|
||||
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrLeafIndex, MmrProof } from '@polkadot/types/interfaces/mmr';
|
||||
import type { NpApiError } from '@polkadot/types/interfaces/nompools';
|
||||
import type { CandidateCommitments, CandidateEvent, CommittedCandidateReceipt, CoreState, GroupRotationInfo, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, ParaId, ParaValidatorIndex, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes, SessionInfo, ValidationCode, ValidationCodeHash, ValidatorSignature } from '@polkadot/types/interfaces/parachains';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { AccountId, Block, Hash, Header, Index, KeyTypeId, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, Balance, Block, Hash, Header, Index, KeyTypeId, Slot, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
|
||||
@@ -206,6 +207,17 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x17a6bc0d0062aeb3/1 */
|
||||
nominationPoolsApi: {
|
||||
/**
|
||||
* Returns the pending rewards for the given member.
|
||||
**/
|
||||
pendingRewards: AugmentedCall<ApiType, (member: AccountId | string | Uint8Array) => Observable<Result<Balance, NpApiError>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xf78b278be53f454c/2 */
|
||||
offchainWorkerApi: {
|
||||
/**
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -1320,10 +1320,6 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* This is basically in sync with the call to [`pallet_session::SessionManager::new_session`].
|
||||
**/
|
||||
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Rewards for the last `HISTORY_DEPTH` eras.
|
||||
* If reward hasn't been set or has been removed then 0 reward is returned.
|
||||
|
||||
@@ -17,6 +17,14 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* nominated.
|
||||
**/
|
||||
AccountNonGrata: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The founders/fellows/allies have already been initialized.
|
||||
**/
|
||||
AllianceAlreadyInitialized: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The Alliance has not been initialized yet, therefore accounts cannot join it.
|
||||
**/
|
||||
AllianceNotYetInitialized: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Account is already an elevated (fellow) member.
|
||||
**/
|
||||
@@ -33,10 +41,6 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* Balance is insufficient for the required deposit.
|
||||
**/
|
||||
InsufficientFunds: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The founders/fellows/allies have already been initialized.
|
||||
**/
|
||||
MembersAlreadyInitialized: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The announcement is not found.
|
||||
**/
|
||||
@@ -1787,7 +1791,11 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
};
|
||||
stateTrieMigration: {
|
||||
/**
|
||||
* bad witness data provided.
|
||||
* Bad child root provided.
|
||||
**/
|
||||
BadChildRoot: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Bad witness data provided.
|
||||
**/
|
||||
BadWitness: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -1801,7 +1809,7 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
**/
|
||||
KeyTooLong: AugmentedError<ApiType>;
|
||||
/**
|
||||
* max signed limits not respected.
|
||||
* Max signed limits not respected.
|
||||
**/
|
||||
MaxSignedLimits: AugmentedError<ApiType>;
|
||||
/**
|
||||
@@ -1812,10 +1820,6 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* Signed migration is not allowed because the maximum limit is not set yet.
|
||||
**/
|
||||
SignedMigrationNotAllowed: AugmentedError<ApiType>;
|
||||
/**
|
||||
* upper bound of size is exceeded,
|
||||
**/
|
||||
SizeUpperBoundExceeded: AugmentedError<ApiType>;
|
||||
/**
|
||||
* Generic error
|
||||
**/
|
||||
@@ -2081,6 +2085,12 @@ declare module '@polkadot/api-base/types/errors' {
|
||||
* The provided max supply is less to the amount of items a collection already has.
|
||||
**/
|
||||
MaxSupplyTooSmall: AugmentedError<ApiType>;
|
||||
/**
|
||||
* The `CollectionId` in `NextCollectionId` is not being used.
|
||||
*
|
||||
* This means that you can directly proceed to call `create`.
|
||||
**/
|
||||
NextIdNotUsed: AugmentedError<ApiType>;
|
||||
/**
|
||||
* There is no delegate approved.
|
||||
**/
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { ApiTypes, AugmentedEvent } from '@polkadot/api-base/types';
|
||||
import type { Bytes, Null, Option, Result, U8aFixed, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AccountId32, H256 } from '@polkadot/types/interfaces/runtime';
|
||||
import type { FrameSupportScheduleLookupError, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPostDispatchInfo, NodeRuntimeProxyType, PalletAllianceCid, PalletAllianceUnscrupulousItem, PalletConvictionVotingTally, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletElectionProviderMultiPhaseElectionCompute, PalletImOnlineSr25519AppSr25519Public, PalletMultisigTimepoint, PalletNominationPoolsPoolState, PalletRankedCollectiveTally, PalletRankedCollectiveVoteRecord, PalletStakingExposure, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationCompute, SpFinalityGrandpaAppPublic, SpRuntimeDispatchError, SpRuntimeDispatchErrorWithPostInfo } from '@polkadot/types/lookup';
|
||||
import type { FrameSupportScheduleLookupError, FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, FrameSupportWeightsPostDispatchInfo, KitchensinkRuntimeProxyType, PalletAllianceCid, PalletAllianceUnscrupulousItem, PalletConvictionVotingTally, PalletDemocracyVoteAccountVote, PalletDemocracyVoteThreshold, PalletElectionProviderMultiPhaseElectionCompute, PalletImOnlineSr25519AppSr25519Public, PalletMultisigTimepoint, PalletNominationPoolsPoolState, PalletRankedCollectiveTally, PalletRankedCollectiveVoteRecord, PalletStakingExposure, PalletStakingValidatorPrefs, PalletStateTrieMigrationError, PalletStateTrieMigrationMigrationCompute, SpFinalityGrandpaAppPublic, SpRuntimeDispatchError, SpRuntimeDispatchErrorWithPostInfo } from '@polkadot/types/lookup';
|
||||
|
||||
export type __AugmentedEvent<ApiType extends ApiTypes> = AugmentedEvent<ApiType>;
|
||||
|
||||
@@ -176,6 +176,17 @@ declare module '@polkadot/api-base/types/events' {
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
assetTxPayment: {
|
||||
/**
|
||||
* A transaction fee `actual_fee`, of which `tip` was added to the minimum inclusion fee,
|
||||
* has been paid by `who` in an asset `asset_id`.
|
||||
**/
|
||||
AssetTxFeePaid: AugmentedEvent<ApiType, [who: AccountId32, actualFee: u128, tip: u128, assetId: Option<u32>], { who: AccountId32, actualFee: u128, tip: u128, assetId: Option<u32> }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
[key: string]: AugmentedEvent<ApiType>;
|
||||
};
|
||||
bagsList: {
|
||||
/**
|
||||
* Moved an account from one bag to another.
|
||||
@@ -755,12 +766,12 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* pool.
|
||||
* - `points` is the number of points that are issued as a result of `balance` being
|
||||
* dissolved into the corresponding unbonding pool.
|
||||
*
|
||||
* - `era` is the era in which the balance will be unbonded.
|
||||
* In the absence of slashing, these values will match. In the presence of slashing, the
|
||||
* number of points that are issued in the unbonding pool will be less than the amount
|
||||
* requested to be unbonded.
|
||||
**/
|
||||
Unbonded: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, balance: u128, points: u128], { member: AccountId32, poolId: u32, balance: u128, points: u128 }>;
|
||||
Unbonded: AugmentedEvent<ApiType, [member: AccountId32, poolId: u32, balance: u128, points: u128, era: u32], { member: AccountId32, poolId: u32, balance: u128, points: u128, era: u32 }>;
|
||||
/**
|
||||
* The unbond pool at `era` of pool `pool_id` has been slashed to `balance`.
|
||||
**/
|
||||
@@ -818,11 +829,11 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* Anonymous account has been created by new proxy with given
|
||||
* disambiguation index and proxy type.
|
||||
**/
|
||||
AnonymousCreated: AugmentedEvent<ApiType, [anonymous: AccountId32, who: AccountId32, proxyType: NodeRuntimeProxyType, disambiguationIndex: u16], { anonymous: AccountId32, who: AccountId32, proxyType: NodeRuntimeProxyType, disambiguationIndex: u16 }>;
|
||||
AnonymousCreated: AugmentedEvent<ApiType, [anonymous: AccountId32, who: AccountId32, proxyType: KitchensinkRuntimeProxyType, disambiguationIndex: u16], { anonymous: AccountId32, who: AccountId32, proxyType: KitchensinkRuntimeProxyType, disambiguationIndex: u16 }>;
|
||||
/**
|
||||
* A proxy was added.
|
||||
**/
|
||||
ProxyAdded: AugmentedEvent<ApiType, [delegator: AccountId32, delegatee: AccountId32, proxyType: NodeRuntimeProxyType, delay: u32], { delegator: AccountId32, delegatee: AccountId32, proxyType: NodeRuntimeProxyType, delay: u32 }>;
|
||||
ProxyAdded: AugmentedEvent<ApiType, [delegator: AccountId32, delegatee: AccountId32, proxyType: KitchensinkRuntimeProxyType, delay: u32], { delegator: AccountId32, delegatee: AccountId32, proxyType: KitchensinkRuntimeProxyType, delay: u32 }>;
|
||||
/**
|
||||
* A proxy was executed correctly, with the given.
|
||||
**/
|
||||
@@ -830,7 +841,7 @@ declare module '@polkadot/api-base/types/events' {
|
||||
/**
|
||||
* A proxy was removed.
|
||||
**/
|
||||
ProxyRemoved: AugmentedEvent<ApiType, [delegator: AccountId32, delegatee: AccountId32, proxyType: NodeRuntimeProxyType, delay: u32], { delegator: AccountId32, delegatee: AccountId32, proxyType: NodeRuntimeProxyType, delay: u32 }>;
|
||||
ProxyRemoved: AugmentedEvent<ApiType, [delegator: AccountId32, delegatee: AccountId32, proxyType: KitchensinkRuntimeProxyType, delay: u32], { delegator: AccountId32, delegatee: AccountId32, proxyType: KitchensinkRuntimeProxyType, delay: u32 }>;
|
||||
/**
|
||||
* Generic event
|
||||
**/
|
||||
@@ -1184,7 +1195,7 @@ declare module '@polkadot/api-base/types/events' {
|
||||
/**
|
||||
* Migration got halted due to an error or miss-configuration.
|
||||
**/
|
||||
Halted: AugmentedEvent<ApiType, []>;
|
||||
Halted: AugmentedEvent<ApiType, [error: PalletStateTrieMigrationError], { error: PalletStateTrieMigrationError }>;
|
||||
/**
|
||||
* Given number of `(top, child)` keys were migrated respectively, with the given
|
||||
* `compute`.
|
||||
@@ -1493,6 +1504,10 @@ declare module '@polkadot/api-base/types/events' {
|
||||
* New metadata has been set for an item.
|
||||
**/
|
||||
MetadataSet: AugmentedEvent<ApiType, [collection: u32, item: u32, data: Bytes, isFrozen: bool], { collection: u32, item: u32, data: Bytes, isFrozen: bool }>;
|
||||
/**
|
||||
* Event gets emmited when the `NextCollectionId` gets incremented.
|
||||
**/
|
||||
NextCollectionIdIncremented: AugmentedEvent<ApiType, [nextId: u32], { nextId: u32 }>;
|
||||
/**
|
||||
* The owner changed.
|
||||
**/
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { Data } from '@polkadot/types';
|
||||
import type { BTreeMap, Bytes, Null, Option, U8aFixed, Vec, WrapperKeepOpaque, WrapperOpaque, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AccountId32, Call, H256, Perbill, Percent } from '@polkadot/types/interfaces/runtime';
|
||||
import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, NodeRuntimeSessionKeys, PalletAllianceCid, PalletAllianceMemberRole, PalletAssetsApproval, PalletAssetsAssetAccount, PalletAssetsAssetDetails, PalletAssetsAssetMetadata, PalletAuthorshipUncleEntryItem, PalletBagsListListBag, PalletBagsListListNode, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletBountiesBounty, PalletChildBountiesChildBounty, PalletCollectiveVotes, PalletContractsStorageDeletedContract, PalletContractsStorageRawContractInfo, PalletContractsWasmOwnerInfo, PalletContractsWasmPrefabWasmModule, PalletConvictionVotingVoteVoting, PalletDemocracyPreimageStatus, PalletDemocracyReferendumInfo, PalletDemocracyReleases, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletElectionProviderMultiPhasePhase, PalletElectionProviderMultiPhaseReadySolution, PalletElectionProviderMultiPhaseRoundSnapshot, PalletElectionProviderMultiPhaseSignedSignedSubmission, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenSeatHolder, PalletElectionsPhragmenVoter, PalletGiltActiveGilt, PalletGiltActiveGiltsTotal, PalletGiltGiltBid, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineBoundedOpaqueNetworkState, PalletImOnlineSr25519AppSr25519Public, PalletLotteryLotteryConfig, PalletMultisigMultisig, PalletNominationPoolsBondedPoolInner, PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool, PalletNominationPoolsSubPools, PalletPreimageRequestStatus, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletRankedCollectiveMemberRecord, PalletRankedCollectiveVoteRecord, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletReferendaReferendumInfoConvictionVotingTally, PalletReferendaReferendumInfoRankedCollectiveTally, PalletSchedulerScheduledV3, PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus, PalletStakingActiveEraInfo, PalletStakingEraRewardPoints, PalletStakingExposure, PalletStakingForcing, PalletStakingNominations, PalletStakingReleases, PalletStakingRewardDestination, PalletStakingSlashingSlashingSpans, PalletStakingSlashingSpanRecord, PalletStakingStakingLedger, PalletStakingUnappliedSlash, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTransactionStorageTransactionInfo, PalletTreasuryProposal, PalletUniquesCollectionDetails, PalletUniquesCollectionMetadata, PalletUniquesItemDetails, PalletUniquesItemMetadata, PalletVestingReleases, PalletVestingVestingInfo, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusBabeDigestsPreDigest, SpCoreCryptoKeyTypeId, SpNposElectionsElectionScore, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup';
|
||||
import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, KitchensinkRuntimeSessionKeys, PalletAllianceCid, PalletAllianceMemberRole, PalletAssetsApproval, PalletAssetsAssetAccount, PalletAssetsAssetDetails, PalletAssetsAssetMetadata, PalletAuthorshipUncleEntryItem, PalletBagsListListBag, PalletBagsListListNode, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletBountiesBounty, PalletChildBountiesChildBounty, PalletCollectiveVotes, PalletContractsStorageDeletedContract, PalletContractsStorageRawContractInfo, PalletContractsWasmOwnerInfo, PalletContractsWasmPrefabWasmModule, PalletConvictionVotingVoteVoting, PalletDemocracyPreimageStatus, PalletDemocracyReferendumInfo, PalletDemocracyReleases, PalletDemocracyVoteThreshold, PalletDemocracyVoteVoting, PalletElectionProviderMultiPhasePhase, PalletElectionProviderMultiPhaseReadySolution, PalletElectionProviderMultiPhaseRoundSnapshot, PalletElectionProviderMultiPhaseSignedSignedSubmission, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenSeatHolder, PalletElectionsPhragmenVoter, PalletGiltActiveGilt, PalletGiltActiveGiltsTotal, PalletGiltGiltBid, PalletGrandpaStoredPendingChange, PalletGrandpaStoredState, PalletIdentityRegistrarInfo, PalletIdentityRegistration, PalletImOnlineBoundedOpaqueNetworkState, PalletImOnlineSr25519AppSr25519Public, PalletLotteryLotteryConfig, PalletMultisigMultisig, PalletNominationPoolsBondedPoolInner, PalletNominationPoolsPoolMember, PalletNominationPoolsRewardPool, PalletNominationPoolsSubPools, PalletPreimageRequestStatus, PalletProxyAnnouncement, PalletProxyProxyDefinition, PalletRankedCollectiveMemberRecord, PalletRankedCollectiveVoteRecord, PalletRecoveryActiveRecovery, PalletRecoveryRecoveryConfig, PalletReferendaReferendumInfoConvictionVotingTally, PalletReferendaReferendumInfoRankedCollectiveTally, PalletSchedulerScheduledV3, PalletSocietyBid, PalletSocietyBidKind, PalletSocietyVote, PalletSocietyVouchingStatus, PalletStakingActiveEraInfo, PalletStakingEraRewardPoints, PalletStakingExposure, PalletStakingForcing, PalletStakingNominations, PalletStakingReleases, PalletStakingRewardDestination, PalletStakingSlashingSlashingSpans, PalletStakingSlashingSpanRecord, PalletStakingStakingLedger, PalletStakingUnappliedSlash, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletTipsOpenTip, PalletTransactionPaymentReleases, PalletTransactionStorageTransactionInfo, PalletTreasuryProposal, PalletUniquesCollectionDetails, PalletUniquesCollectionMetadata, PalletUniquesItemDetails, PalletUniquesItemMetadata, PalletVestingReleases, PalletVestingVestingInfo, SpAuthorityDiscoveryAppPublic, SpConsensusBabeAppPublic, SpConsensusBabeBabeEpochConfiguration, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusBabeDigestsPreDigest, SpCoreCryptoKeyTypeId, SpNposElectionsElectionScore, SpRuntimeDigest, SpStakingOffenceOffenceDetails } from '@polkadot/types/lookup';
|
||||
import type { Observable } from '@polkadot/types/types';
|
||||
|
||||
export type __AugmentedQuery<ApiType extends ApiTypes> = AugmentedQuery<ApiType, () => unknown>;
|
||||
@@ -1153,7 +1153,7 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
/**
|
||||
* The next session keys for a validator.
|
||||
**/
|
||||
nextKeys: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<NodeRuntimeSessionKeys>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
nextKeys: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<KitchensinkRuntimeSessionKeys>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
|
||||
/**
|
||||
* True if the underlying economic identities or weighting behind the validators
|
||||
* has changed in the queued validator set.
|
||||
@@ -1163,7 +1163,7 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* The queued keys for the next session. When the next session begins, these keys
|
||||
* will be used to determine the validator's session keys.
|
||||
**/
|
||||
queuedKeys: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId32, NodeRuntimeSessionKeys]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
queuedKeys: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[AccountId32, KitchensinkRuntimeSessionKeys]>>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The current set of validators.
|
||||
**/
|
||||
@@ -1295,10 +1295,6 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* This is basically in sync with the call to [`pallet_session::SessionManager::new_session`].
|
||||
**/
|
||||
currentPlannedSession: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The earliest era for which we have a pending, unapplied slash.
|
||||
**/
|
||||
earliestUnappliedSlash: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* Rewards for the last `HISTORY_DEPTH` eras.
|
||||
* If reward hasn't been set or has been removed then 0 reward is returned.
|
||||
@@ -1783,6 +1779,11 @@ declare module '@polkadot/api-base/types/storage' {
|
||||
* Price of an asset instance.
|
||||
**/
|
||||
itemPriceOf: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<ITuple<[u128, Option<AccountId32>]>>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
|
||||
/**
|
||||
* Stores the `CollectionId` that is going to be used for the next collection.
|
||||
* This gets incremented by 1 whenever a new collection is created.
|
||||
**/
|
||||
nextCollectionId: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
|
||||
/**
|
||||
* The collection, if any, of which an account is willing to take ownership.
|
||||
**/
|
||||
|
||||
@@ -7,7 +7,7 @@ import '@polkadot/api-base/types/calls';
|
||||
|
||||
import type { ApiTypes, AugmentedCall, DecoratedCallBase } from '@polkadot/api-base/types';
|
||||
import type { Bytes, Null, Option, Result, Vec, u32, u64 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { BabeEquivocationProof, BabeGenesisConfiguration, Epoch, OpaqueKeyOwnershipProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { CheckInherentsResult, InherentData } from '@polkadot/types/interfaces/blockbuilder';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
@@ -17,8 +17,9 @@ import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
|
||||
import type { AuthorityList, GrandpaEquivocationProof, SetId } from '@polkadot/types/interfaces/grandpa';
|
||||
import type { OpaqueMetadata } from '@polkadot/types/interfaces/metadata';
|
||||
import type { MmrBatchProof, MmrEncodableOpaqueLeaf, MmrError, MmrLeafIndex, MmrProof } from '@polkadot/types/interfaces/mmr';
|
||||
import type { NpApiError } from '@polkadot/types/interfaces/nompools';
|
||||
import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import type { AccountId, Balance, Block, Hash, Header, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime';
|
||||
import type { AccountId, Balance, Block, Call, Hash, Header, Index, KeyTypeId, Slot } from '@polkadot/types/interfaces/runtime';
|
||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
||||
import type { ApplyExtrinsicResult } from '@polkadot/types/interfaces/system';
|
||||
import type { TransactionSource, TransactionValidity } from '@polkadot/types/interfaces/txqueue';
|
||||
@@ -216,6 +217,17 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0x17a6bc0d0062aeb3/1 */
|
||||
nominationPoolsApi: {
|
||||
/**
|
||||
* Returns the pending rewards for the given member.
|
||||
**/
|
||||
pendingRewards: AugmentedCall<ApiType, (member: AccountId | string | Uint8Array) => Observable<Result<Balance, NpApiError>>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xf78b278be53f454c/2 */
|
||||
offchainWorkerApi: {
|
||||
/**
|
||||
@@ -268,5 +280,20 @@ declare module '@polkadot/api-base/types/calls' {
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
/** 0xf3ff14d5ab527059/1 */
|
||||
transactionPaymentCallApi: {
|
||||
/**
|
||||
* The call fee details
|
||||
**/
|
||||
queryCallFeeDetails: AugmentedCall<ApiType, (call: Call | IMethod | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<FeeDetails>>;
|
||||
/**
|
||||
* The call info
|
||||
**/
|
||||
queryCallInfo: AugmentedCall<ApiType, (call: Call | IMethod | string | Uint8Array, len: u32 | AnyNumber | Uint8Array) => Observable<RuntimeDispatchInfo>>;
|
||||
/**
|
||||
* Generic call
|
||||
**/
|
||||
[key: string]: DecoratedCallBase<ApiType>;
|
||||
};
|
||||
} // AugmentedCalls
|
||||
} // declare module
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { Data } from '@polkadot/types';
|
||||
import type { Bytes, Compact, Option, U8aFixed, Vec, WrapperKeepOpaque, bool, u128, u16, u32, u64, u8 } from '@polkadot/types-codec';
|
||||
import type { AnyNumber, IMethod, ITuple } from '@polkadot/types-codec/types';
|
||||
import type { AccountId32, Call, H256, MultiAddress, Perbill, Percent, Perquintill } from '@polkadot/types/interfaces/runtime';
|
||||
import type { FrameSupportScheduleDispatchTime, FrameSupportScheduleMaybeHashed, NodeRuntimeOriginCaller, NodeRuntimeProxyType, NodeRuntimeSessionKeys, PalletAllianceCid, PalletAllianceUnscrupulousItem, PalletAssetsDestroyWitness, PalletConvictionVotingConviction, PalletConvictionVotingVoteAccountVote, PalletDemocracyConviction, PalletDemocracyVoteAccountVote, PalletElectionProviderMultiPhaseRawSolution, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenRenouncing, PalletIdentityBitFlags, PalletIdentityIdentityInfo, PalletIdentityJudgement, PalletImOnlineHeartbeat, PalletImOnlineSr25519AppSr25519Signature, PalletMultisigTimepoint, PalletNominationPoolsBondExtra, PalletNominationPoolsConfigOpAccountId32, PalletNominationPoolsConfigOpU128, PalletNominationPoolsConfigOpU32, PalletNominationPoolsPoolState, PalletSocietyJudgement, PalletStakingPalletConfigOpPerbill, PalletStakingPalletConfigOpPercent, PalletStakingPalletConfigOpU128, PalletStakingPalletConfigOpU32, PalletStakingRewardDestination, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletStateTrieMigrationProgress, PalletUniquesDestroyWitness, PalletVestingVestingInfo, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusSlotsEquivocationProof, SpFinalityGrandpaEquivocationProof, SpNposElectionsElectionScore, SpNposElectionsSupport, SpRuntimeHeader, SpSessionMembershipProof, SpTransactionStorageProofTransactionStorageProof } from '@polkadot/types/lookup';
|
||||
import type { FrameSupportScheduleDispatchTime, FrameSupportScheduleMaybeHashed, KitchensinkRuntimeOriginCaller, KitchensinkRuntimeProxyType, KitchensinkRuntimeSessionKeys, PalletAllianceCid, PalletAllianceUnscrupulousItem, PalletAssetsDestroyWitness, PalletConvictionVotingConviction, PalletConvictionVotingVoteAccountVote, PalletDemocracyConviction, PalletDemocracyVoteAccountVote, PalletElectionProviderMultiPhaseRawSolution, PalletElectionProviderMultiPhaseSolutionOrSnapshotSize, PalletElectionsPhragmenRenouncing, PalletIdentityBitFlags, PalletIdentityIdentityInfo, PalletIdentityJudgement, PalletImOnlineHeartbeat, PalletImOnlineSr25519AppSr25519Signature, PalletMultisigTimepoint, PalletNominationPoolsBondExtra, PalletNominationPoolsConfigOpAccountId32, PalletNominationPoolsConfigOpU128, PalletNominationPoolsConfigOpU32, PalletNominationPoolsPoolState, PalletSocietyJudgement, PalletStakingPalletConfigOpPerbill, PalletStakingPalletConfigOpPercent, PalletStakingPalletConfigOpU128, PalletStakingPalletConfigOpU32, PalletStakingRewardDestination, PalletStakingValidatorPrefs, PalletStateTrieMigrationMigrationLimits, PalletStateTrieMigrationMigrationTask, PalletStateTrieMigrationProgress, PalletUniquesDestroyWitness, PalletVestingVestingInfo, SpConsensusBabeDigestsNextConfigDescriptor, SpConsensusSlotsEquivocationProof, SpFinalityGrandpaEquivocationProof, SpNposElectionsElectionScore, SpNposElectionsSupport, SpRuntimeHeader, SpSessionMembershipProof, SpTransactionStorageProofTransactionStorageProof } from '@polkadot/types/lookup';
|
||||
|
||||
export type __AugmentedSubmittable = AugmentedSubmittable<() => unknown>;
|
||||
export type __SubmittableExtrinsic<ApiType extends ApiTypes> = SubmittableExtrinsic<ApiType>;
|
||||
@@ -2940,7 +2940,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight is a function of the number of proxies the user has (P).
|
||||
* # </weight>
|
||||
**/
|
||||
addProxy: AugmentedSubmittable<(delegate: AccountId32 | string | Uint8Array, proxyType: NodeRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, NodeRuntimeProxyType, u32]>;
|
||||
addProxy: AugmentedSubmittable<(delegate: AccountId32 | string | Uint8Array, proxyType: KitchensinkRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, KitchensinkRuntimeProxyType, u32]>;
|
||||
/**
|
||||
* Publish the hash of a proxy-call that will be made in the future.
|
||||
*
|
||||
@@ -2990,7 +2990,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* # </weight>
|
||||
* TODO: Might be over counting 1 read
|
||||
**/
|
||||
anonymous: AugmentedSubmittable<(proxyType: NodeRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: u32 | AnyNumber | Uint8Array, index: u16 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeProxyType, u32, u16]>;
|
||||
anonymous: AugmentedSubmittable<(proxyType: KitchensinkRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: u32 | AnyNumber | Uint8Array, index: u16 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [KitchensinkRuntimeProxyType, u32, u16]>;
|
||||
/**
|
||||
* Removes a previously spawned anonymous proxy.
|
||||
*
|
||||
@@ -3013,7 +3013,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight is a function of the number of proxies the user has (P).
|
||||
* # </weight>
|
||||
**/
|
||||
killAnonymous: AugmentedSubmittable<(spawner: AccountId32 | string | Uint8Array, proxyType: NodeRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, index: u16 | AnyNumber | Uint8Array, height: Compact<u32> | AnyNumber | Uint8Array, extIndex: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, NodeRuntimeProxyType, u16, Compact<u32>, Compact<u32>]>;
|
||||
killAnonymous: AugmentedSubmittable<(spawner: AccountId32 | string | Uint8Array, proxyType: KitchensinkRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, index: u16 | AnyNumber | Uint8Array, height: Compact<u32> | AnyNumber | Uint8Array, extIndex: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, KitchensinkRuntimeProxyType, u16, Compact<u32>, Compact<u32>]>;
|
||||
/**
|
||||
* Dispatch the given `call` from an account that the sender is authorised for through
|
||||
* `add_proxy`.
|
||||
@@ -3031,7 +3031,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight is a function of the number of proxies the user has (P).
|
||||
* # </weight>
|
||||
**/
|
||||
proxy: AugmentedSubmittable<(real: AccountId32 | string | Uint8Array, forceProxyType: Option<NodeRuntimeProxyType> | null | Uint8Array | NodeRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, Option<NodeRuntimeProxyType>, Call]>;
|
||||
proxy: AugmentedSubmittable<(real: AccountId32 | string | Uint8Array, forceProxyType: Option<KitchensinkRuntimeProxyType> | null | Uint8Array | KitchensinkRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, Option<KitchensinkRuntimeProxyType>, Call]>;
|
||||
/**
|
||||
* Dispatch the given `call` from an account that the sender is authorized for through
|
||||
* `add_proxy`.
|
||||
@@ -3051,7 +3051,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* - P: the number of proxies the user has.
|
||||
* # </weight>
|
||||
**/
|
||||
proxyAnnounced: AugmentedSubmittable<(delegate: AccountId32 | string | Uint8Array, real: AccountId32 | string | Uint8Array, forceProxyType: Option<NodeRuntimeProxyType> | null | Uint8Array | NodeRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, AccountId32, Option<NodeRuntimeProxyType>, Call]>;
|
||||
proxyAnnounced: AugmentedSubmittable<(delegate: AccountId32 | string | Uint8Array, real: AccountId32 | string | Uint8Array, forceProxyType: Option<KitchensinkRuntimeProxyType> | null | Uint8Array | KitchensinkRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, AccountId32, Option<KitchensinkRuntimeProxyType>, Call]>;
|
||||
/**
|
||||
* Remove the given announcement of a delegate.
|
||||
*
|
||||
@@ -3116,7 +3116,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight is a function of the number of proxies the user has (P).
|
||||
* # </weight>
|
||||
**/
|
||||
removeProxy: AugmentedSubmittable<(delegate: AccountId32 | string | Uint8Array, proxyType: NodeRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, NodeRuntimeProxyType, u32]>;
|
||||
removeProxy: AugmentedSubmittable<(delegate: AccountId32 | string | Uint8Array, proxyType: KitchensinkRuntimeProxyType | 'Any' | 'NonTransfer' | 'Governance' | 'Staking' | number | Uint8Array, delay: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [AccountId32, KitchensinkRuntimeProxyType, u32]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -3264,7 +3264,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Emits `Submitted`.
|
||||
**/
|
||||
submit: AugmentedSubmittable<(proposalOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
submit: AugmentedSubmittable<(proposalOrigin: KitchensinkRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [KitchensinkRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -3466,7 +3466,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Emits `Submitted`.
|
||||
**/
|
||||
submit: AugmentedSubmittable<(proposalOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
submit: AugmentedSubmittable<(proposalOrigin: KitchensinkRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, proposalHash: H256 | string | Uint8Array, enactmentMoment: FrameSupportScheduleDispatchTime | { At: any } | { After: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [KitchensinkRuntimeOriginCaller, H256, FrameSupportScheduleDispatchTime]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -3556,7 +3556,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* - DbWrites per key id: `KeyOwner`
|
||||
* # </weight>
|
||||
**/
|
||||
setKeys: AugmentedSubmittable<(keys: NodeRuntimeSessionKeys | { grandpa?: any; babe?: any; imOnline?: any; authorityDiscovery?: any } | string | Uint8Array, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeSessionKeys, Bytes]>;
|
||||
setKeys: AugmentedSubmittable<(keys: KitchensinkRuntimeSessionKeys | { grandpa?: any; babe?: any; imOnline?: any; authorityDiscovery?: any } | string | Uint8Array, proof: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [KitchensinkRuntimeSessionKeys, Bytes]>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -5084,7 +5084,6 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* `ItemDeposit` funds of sender are reserved.
|
||||
*
|
||||
* Parameters:
|
||||
* - `collection`: The identifier of the new collection. This must not be currently in use.
|
||||
* - `admin`: The admin of this collection. The admin is the initial address of each
|
||||
* member of the collection's admin team.
|
||||
*
|
||||
@@ -5092,7 +5091,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
create: AugmentedSubmittable<(collection: u32 | AnyNumber | Uint8Array, admin: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, MultiAddress]>;
|
||||
create: AugmentedSubmittable<(admin: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
|
||||
/**
|
||||
* Destroy a collection of fungible items.
|
||||
*
|
||||
@@ -5120,7 +5119,6 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Unlike `create`, no funds are reserved.
|
||||
*
|
||||
* - `collection`: The identifier of the new item. This must not be currently in use.
|
||||
* - `owner`: The owner of this collection of items. The owner has full superuser
|
||||
* permissions
|
||||
* over this item, but may later change and configure the permissions using
|
||||
@@ -5130,7 +5128,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
forceCreate: AugmentedSubmittable<(collection: u32 | AnyNumber | Uint8Array, owner: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freeHolding: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, MultiAddress, bool]>;
|
||||
forceCreate: AugmentedSubmittable<(owner: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, freeHolding: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, bool]>;
|
||||
/**
|
||||
* Alter the attributes of a given item.
|
||||
*
|
||||
@@ -5381,6 +5379,20 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
transferOwnership: AugmentedSubmittable<(collection: u32 | AnyNumber | Uint8Array, owner: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, MultiAddress]>;
|
||||
/**
|
||||
* Increments the `CollectionId` stored in `NextCollectionId`.
|
||||
*
|
||||
* This is only callable when the next `CollectionId` is already being
|
||||
* used for some other collection.
|
||||
*
|
||||
* The origin must be Signed and the sender must have sufficient funds
|
||||
* free.
|
||||
*
|
||||
* Emits `NextCollectionIdIncremented` event when successful.
|
||||
*
|
||||
* Weight: `O(1)`
|
||||
**/
|
||||
tryIncrementId: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
|
||||
/**
|
||||
* Generic tx
|
||||
**/
|
||||
@@ -5454,7 +5466,7 @@ declare module '@polkadot/api-base/types/submittable' {
|
||||
* - Weight of derivative `call` execution + T::WeightInfo::dispatch_as().
|
||||
* # </weight>
|
||||
**/
|
||||
dispatchAs: AugmentedSubmittable<(asOrigin: NodeRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [NodeRuntimeOriginCaller, Call]>;
|
||||
dispatchAs: AugmentedSubmittable<(asOrigin: KitchensinkRuntimeOriginCaller | { system: any } | { Void: any } | { Council: any } | { TechnicalCommittee: any } | { AllianceMotion: any } | string | Uint8Array, call: Call | IMethod | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [KitchensinkRuntimeOriginCaller, Call]>;
|
||||
/**
|
||||
* Send a batch of dispatch calls.
|
||||
* Unlike `batch`, it allows errors and won't interrupt.
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/rpc-core": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/rpc-core": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"rxjs": "^7.5.6"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { DecoratedRpc, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@polkadot/api-base/types';
|
||||
import type { DecoratedRpc, QueryableCalls, QueryableConsts, QueryableStorage, QueryableStorageMulti, SubmittableExtrinsics } from '@polkadot/api-base/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Metadata } from '@polkadot/types';
|
||||
import type { Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
@@ -10,6 +10,7 @@ import type { Registry, Signer } from '@polkadot/types/types';
|
||||
|
||||
// A smaller interface of ApiRx, used in derive and in SubmittableExtrinsic
|
||||
export interface ApiInterfaceRx {
|
||||
call: QueryableCalls<'rxjs'>;
|
||||
consts: QueryableConsts<'rxjs'>;
|
||||
extrinsicType: number;
|
||||
genesisHash?: Hash;
|
||||
@@ -18,9 +19,11 @@ export interface ApiInterfaceRx {
|
||||
runtimeMetadata: Metadata;
|
||||
runtimeVersion: RuntimeVersion;
|
||||
query: QueryableStorage<'rxjs'>;
|
||||
queryAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableStorage<'rxjs'>>;
|
||||
queryMulti: QueryableStorageMulti<'rxjs'>;
|
||||
rpc: DecoratedRpc<'rxjs', RpcInterface>;
|
||||
tx: SubmittableExtrinsics<'rxjs'>;
|
||||
signer?: Signer;
|
||||
|
||||
callAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableCalls<'rxjs'>>;
|
||||
queryAt: (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) => Observable<QueryableStorage<'rxjs'>>;
|
||||
}
|
||||
|
||||
@@ -58,10 +58,6 @@ export interface StorageEntryBase<ApiType extends ApiTypes, F extends AnyFunctio
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
keysAt: <K extends AnyTuple = A> (hash: Hash | Uint8Array | string, ...args: DropLast<Parameters<F>>) => PromiseOrObs<ApiType, StorageKey<K>[]>;
|
||||
/**
|
||||
* @deprecated The underlying RPC this been marked unsafe and is generally not exposed
|
||||
*/
|
||||
range: <T extends Codec | any = ReturnCodec<F>>([from, to]: [Hash | Uint8Array | string, Hash | Uint8Array | string | undefined] | [Hash | Uint8Array | string], ...args: Parameters<F>) => PromiseOrObs<ApiType, [Hash, T][]>;
|
||||
/**
|
||||
* @deprecated Use api.at(<blockHash>)
|
||||
*/
|
||||
|
||||
@@ -58,11 +58,6 @@ export interface SubmittableExtrinsic<ApiType extends ApiTypes, R extends ISubmi
|
||||
|
||||
send (statusCb: Callback<R>): SubmittableResultSubscription<ApiType, R>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
sign (account: IKeyringPair, _options?: Partial<SignerOptions>): this;
|
||||
|
||||
signAsync (account: AddressOrPair, _options?: Partial<SignerOptions>): PromiseOrObs<ApiType, this>;
|
||||
|
||||
signAndSend (account: AddressOrPair, options?: Partial<SignerOptions>): SubmittableResultResult<ApiType, R>;
|
||||
|
||||
@@ -20,20 +20,20 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/types-create": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/api": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/types-create": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"@polkadot/util-crypto": "^10.1.4",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "8.13.1",
|
||||
"@polkadot/keyring": "^10.0.2"
|
||||
"@polkadot/api-augment": "9.2.2",
|
||||
"@polkadot/keyring": "^10.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,11 @@ import { v0ToV1 } from './toV1';
|
||||
import { v1ToV2 } from './toV2';
|
||||
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;
|
||||
|
||||
@@ -26,10 +30,6 @@ export const v2ToLatest = createConverter(v3ToLatest, v2ToV3);
|
||||
export const v1ToLatest = createConverter(v2ToLatest, v1ToV2);
|
||||
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][] = [
|
||||
['V3', v3ToLatest],
|
||||
['V2', v2ToLatest],
|
||||
|
||||
@@ -23,7 +23,7 @@ interface ArgsEntry <T extends WithArgs> extends NamedEntry {
|
||||
args: GetArgsType<T>['args'][0][];
|
||||
}
|
||||
|
||||
const ARG_TYPES = {
|
||||
const ARG_TYPES = <const> {
|
||||
ContractConstructorSpec: 'ContractMessageParamSpecV2',
|
||||
ContractEventSpec: 'ContractEventParamSpecV2',
|
||||
ContractMessageSpec: 'ContractMessageParamSpecV2'
|
||||
|
||||
@@ -26,10 +26,10 @@ export abstract class Base<ApiType extends ApiTypes> {
|
||||
|
||||
if (!api || !api.isConnected || !api.tx) {
|
||||
throw new Error('Your API has not been initialized correctly and is not connected to a chain');
|
||||
} else if (!api.tx.contracts || !Object.keys(api.tx.contracts).length) {
|
||||
throw new Error('You need to connect to a chain with a runtime that supports contracts');
|
||||
} else if (!isFunction(api.tx.contracts.instantiateWithCode)) {
|
||||
throw new Error('You need to connect to a chain with a runtime with a V3 contracts module. The runtime does not expose api.tx.contracts.instantiateWithCode');
|
||||
} else if (!api.tx.contracts || !isFunction(api.tx.contracts.instantiateWithCode) || api.tx.contracts.instantiateWithCode.meta.args.length !== 6) {
|
||||
throw new Error('The runtime does not expose api.tx.contracts.instantiateWithCode with storageDepositLimit');
|
||||
} else if (!api.call.contractsApi || !isFunction(api.call.contractsApi.call)) {
|
||||
throw new Error('Your runtime does not expose the api.call.contractsApi.call runtime interfaces');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,20 +57,16 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
}
|
||||
|
||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, storageDepositLimit = null, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.instantiate.meta.args.length === 6;
|
||||
const encParams = this.abi.findConstructor(constructorOrId).toU8a(params);
|
||||
const encSalt = encodeSalt(salt);
|
||||
const tx = hasStorageDeposit
|
||||
? this.api.tx.contracts.instantiate(value, gasLimit, storageDepositLimit, this.codeHash, encParams, encSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style without storage deposit
|
||||
: this.api.tx.contracts.instantiate(value, gasLimit, this.codeHash, encParams, encSalt);
|
||||
|
||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
return this.api.tx.contracts
|
||||
.instantiate(value, gasLimit, storageDepositLimit, this.codeHash, encParams, encSalt)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new BlueprintSubmittableResult(result, applyOnEvent(result, ['Instantiated'], ([record]: EventRecord[]) =>
|
||||
new Contract<ApiType>(this.api, this.abi, record.event.data[1] as AccountId, this._decorateMethod)
|
||||
))
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -64,27 +64,23 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
}
|
||||
|
||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, storageDepositLimit = null, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.instantiateWithCode.meta.args.length === 6;
|
||||
const encCode = compactAddLength(this.code);
|
||||
const encParams = this.abi.findConstructor(constructorOrId).toU8a(params);
|
||||
const encSalt = encodeSalt(salt);
|
||||
const tx = hasStorageDeposit
|
||||
? this.api.tx.contracts.instantiateWithCode(value, gasLimit, storageDepositLimit, encCode, encParams, encSalt)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style without storage deposit
|
||||
: this.api.tx.contracts.instantiateWithCode(value, gasLimit, encCode, encParams, encSalt);
|
||||
|
||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
|
||||
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
|
||||
this.api.events.contracts.Instantiated.is(event)
|
||||
? [blueprint, new Contract<ApiType>(this.api, this.abi, (event as unknown as { data: [Codec, AccountId] }).data[1], this._decorateMethod)]
|
||||
: this.api.events.contracts.CodeStored.is(event)
|
||||
? [new Blueprint<ApiType>(this.api, this.abi, (event as unknown as { data: [AccountId] }).data[0], this._decorateMethod), contract]
|
||||
: [blueprint, contract],
|
||||
[])
|
||||
) || []))
|
||||
);
|
||||
return this.api.tx.contracts
|
||||
.instantiateWithCode(value, gasLimit, storageDepositLimit, encCode, encParams, encSalt)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
new CodeSubmittableResult(result, ...(applyOnEvent(result, ['CodeStored', 'Instantiated'], (records: EventRecord[]) =>
|
||||
records.reduce<[Blueprint<ApiType>?, Contract<ApiType>?]>(([blueprint, contract], { event }) =>
|
||||
this.api.events.contracts.Instantiated.is(event)
|
||||
? [blueprint, new Contract<ApiType>(this.api, this.abi, (event as unknown as { data: [Codec, AccountId] }).data[1], this._decorateMethod)]
|
||||
: this.api.events.contracts.CodeStored.is(event)
|
||||
? [new Blueprint<ApiType>(this.api, this.abi, (event as unknown as { data: [AccountId] }).data[0], this._decorateMethod), contract]
|
||||
: [blueprint, contract],
|
||||
[])
|
||||
) || []))
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,10 @@ import { map } from 'rxjs';
|
||||
|
||||
import { SubmittableResult } from '@polkadot/api';
|
||||
import { ApiBase } from '@polkadot/api/base';
|
||||
import { BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isFunction, isUndefined, logger } from '@polkadot/util';
|
||||
import { BN, BN_HUNDRED, BN_ONE, BN_ZERO, bnToBn, isUndefined, logger } from '@polkadot/util';
|
||||
|
||||
import { Abi } from '../Abi';
|
||||
import { applyOnEvent, extractOptions, isOptions } from '../util';
|
||||
import { applyOnEvent } from '../util';
|
||||
import { Base } from './Base';
|
||||
import { withMeta } from './util';
|
||||
|
||||
@@ -26,23 +26,18 @@ export interface ContractConstructor<ApiType extends ApiTypes> {
|
||||
|
||||
// As per Rust, 5 * GAS_PER_SEC
|
||||
const MAX_CALL_GAS = new BN(5_000_000_000_000).isub(BN_ONE);
|
||||
const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is most probably due to a runtime configuration.';
|
||||
|
||||
const l = logger('Contract');
|
||||
|
||||
function createQuery <ApiType extends ApiTypes> (meta: AbiMessage, fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: unknown[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||
return withMeta(meta, (origin: string | AccountId | Uint8Array, options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
isOptions(options)
|
||||
? fn(origin, options, params)
|
||||
: fn(origin, ...extractOptions<ContractOptions>(options, params))
|
||||
return withMeta(meta, (origin: string | AccountId | Uint8Array, options: ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||
fn(origin, options, params)
|
||||
);
|
||||
}
|
||||
|
||||
function createTx <ApiType extends ApiTypes> (meta: AbiMessage, fn: (options: ContractOptions, params: unknown[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||
return withMeta(meta, (options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions<ContractOptions>(options, params))
|
||||
return withMeta(meta, (options: ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType> =>
|
||||
fn(options, params)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -82,15 +77,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
});
|
||||
}
|
||||
|
||||
public get hasRpcContractsCall (): boolean {
|
||||
return isFunction(this.api.rx.rpc.contracts?.call);
|
||||
}
|
||||
|
||||
public get query (): MapMessageQuery<ApiType> {
|
||||
if (!this.hasRpcContractsCall) {
|
||||
throw new Error(ERROR_NO_CALL);
|
||||
}
|
||||
|
||||
return this.#query;
|
||||
}
|
||||
|
||||
@@ -112,64 +99,52 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
||||
};
|
||||
|
||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, storageDepositLimit = null, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.call.meta.args.length === 5;
|
||||
const gas = this.#getGas(gasLimit);
|
||||
const encParams = this.abi.findMessage(messageOrId).toU8a(params);
|
||||
const tx = hasStorageDeposit
|
||||
? this.api.tx.contracts.call(this.address, value, gas, storageDepositLimit, encParams)
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore old style without storage deposit
|
||||
: this.api.tx.contracts.call(this.address, value, gas, encParams);
|
||||
|
||||
return tx.withResultTransform((result: ISubmittableResult) =>
|
||||
// ContractEmitted is the current generation, ContractExecution is the previous generation
|
||||
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
|
||||
records
|
||||
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
||||
try {
|
||||
return this.abi.decodeEvent(data as Bytes);
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode contract event: ${(error as Error).message}`);
|
||||
return this.api.tx.contracts
|
||||
.call(this.address, value, gas, storageDepositLimit, encParams)
|
||||
.withResultTransform((result: ISubmittableResult) =>
|
||||
// ContractEmitted is the current generation, ContractExecution is the previous generation
|
||||
new ContractSubmittableResult(result, applyOnEvent(result, ['ContractEmitted', 'ContractExecution'], (records: EventRecord[]) =>
|
||||
records
|
||||
.map(({ event: { data: [, data] } }): DecodedEvent | null => {
|
||||
try {
|
||||
return this.abi.decodeEvent(data as Bytes);
|
||||
} catch (error) {
|
||||
l.error(`Unable to decode contract event: ${(error as Error).message}`);
|
||||
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter((decoded): decoded is DecodedEvent => !!decoded)
|
||||
))
|
||||
);
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter((decoded): decoded is DecodedEvent => !!decoded)
|
||||
))
|
||||
);
|
||||
};
|
||||
|
||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, storageDepositLimit = null, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
|
||||
if (!this.hasRpcContractsCall) {
|
||||
throw new Error(ERROR_NO_CALL);
|
||||
}
|
||||
|
||||
const message = this.abi.findMessage(messageOrId);
|
||||
|
||||
return {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
send: this._decorateMethod((origin: string | AccountId | Uint8Array) => {
|
||||
const hasStorageDeposit = this.api.tx.contracts.call.meta.args.length === 5;
|
||||
const inputData = message.toU8a(params);
|
||||
const rpc = hasStorageDeposit
|
||||
? this.api.rx.rpc.contracts.call({ dest: this.address, gasLimit: this.#getGas(gasLimit, true), inputData, origin, storageDepositLimit, value })
|
||||
: this.api.rx.rpc.contracts.call({ dest: this.address, gasLimit: this.#getGas(gasLimit, true), inputData, origin, value });
|
||||
|
||||
const mapFn = ({ debugMessage, gasConsumed, gasRequired, result, storageDeposit }: ContractExecResult): ContractCallOutcome => ({
|
||||
debugMessage,
|
||||
gasConsumed,
|
||||
gasRequired: gasRequired && !gasRequired.isZero()
|
||||
? gasRequired
|
||||
: gasConsumed,
|
||||
output: result.isOk && message.returnType
|
||||
? this.abi.registry.createTypeUnsafe(message.returnType.lookupName || message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
|
||||
: null,
|
||||
result,
|
||||
storageDeposit
|
||||
});
|
||||
|
||||
return rpc.pipe(map(mapFn));
|
||||
})
|
||||
send: this._decorateMethod((origin: string | AccountId | Uint8Array) =>
|
||||
this.api.rx.call.contractsApi
|
||||
.call<ContractExecResult>(origin, this.address, value, this.#getGas(gasLimit, true), storageDepositLimit, message.toU8a(params))
|
||||
.pipe(
|
||||
map(({ debugMessage, gasConsumed, gasRequired, result, storageDeposit }): ContractCallOutcome => ({
|
||||
debugMessage,
|
||||
gasConsumed,
|
||||
gasRequired: gasRequired && !gasRequired.isZero()
|
||||
? gasRequired
|
||||
: gasConsumed,
|
||||
output: result.isOk && message.returnType
|
||||
? this.abi.registry.createTypeUnsafe(message.returnType.lookupName || message.returnType.type, [result.asOk.data.toU8a(true)], { isPedantic: true })
|
||||
: null,
|
||||
result,
|
||||
storageDeposit
|
||||
}))
|
||||
)
|
||||
)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -6,14 +6,25 @@ import { TypeRegistry } from '@polkadot/types';
|
||||
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
const instantiateWithCode = (): never => {
|
||||
throw new Error('mock');
|
||||
};
|
||||
|
||||
instantiateWithCode.meta = { args: new Array(6) };
|
||||
|
||||
export const mockApi = {
|
||||
call: {
|
||||
contractsApi: {
|
||||
call: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
}
|
||||
},
|
||||
isConnected: true,
|
||||
registry,
|
||||
tx: {
|
||||
contracts: {
|
||||
instantiateWithCode: (): never => {
|
||||
throw new Error('mock');
|
||||
}
|
||||
instantiateWithCode
|
||||
}
|
||||
}
|
||||
} as unknown as ApiBase<'promise'>;
|
||||
|
||||
@@ -5,7 +5,6 @@ import type { Observable } from 'rxjs';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
||||
|
||||
export interface MessageMeta {
|
||||
@@ -14,26 +13,18 @@ export interface MessageMeta {
|
||||
|
||||
export interface BlueprintDeploy<ApiType extends ApiTypes> extends MessageMeta {
|
||||
(options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
// @deprecated Use options form (to be dropped in a major update)
|
||||
(value: bigint | string | number | BN, gasLimit: bigint | string | number | BN, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractQuery<ApiType extends ApiTypes> extends MessageMeta {
|
||||
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
// @deprecated Use options form (to be dropped in a major update)
|
||||
(origin: AccountId | string | Uint8Array, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||
}
|
||||
|
||||
export interface ContractTx<ApiType extends ApiTypes> extends MessageMeta {
|
||||
(options: ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
// @deprecated Use options form (to be dropped in a major update)
|
||||
(value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||
}
|
||||
|
||||
export interface ContractGeneric<O, T> {
|
||||
(messageOrId: AbiMessage | string | number, options: O, ...params: unknown[]): T;
|
||||
// @deprecated Use options form (to be dropped in a major update)
|
||||
(messageOrId: AbiMessage | string | number, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): T;
|
||||
}
|
||||
|
||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||
import type { ApiTypes } from '@polkadot/api/types';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { AbiConstructor, AbiMessage, BlueprintOptions } from '../types';
|
||||
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||
|
||||
@@ -12,8 +11,6 @@ import { Bytes } from '@polkadot/types';
|
||||
import { compactAddLength, u8aToU8a } from '@polkadot/util';
|
||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { extractOptions, isOptions } from '../util';
|
||||
|
||||
export const EMPTY_SALT = new Uint8Array();
|
||||
|
||||
export function withMeta <T extends { meta: AbiMessage }> (meta: AbiMessage, creator: Omit<T, 'meta'>): T {
|
||||
@@ -23,18 +20,14 @@ export function withMeta <T extends { meta: AbiMessage }> (meta: AbiMessage, cre
|
||||
}
|
||||
|
||||
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (meta: AbiMessage, fn: (options: BlueprintOptions, params: unknown[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
||||
return withMeta(meta, (options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType, R> =>
|
||||
isOptions(options)
|
||||
? fn(options, params)
|
||||
: fn(...extractOptions<BlueprintOptions>(options, params))
|
||||
return withMeta(meta, (options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType, R> =>
|
||||
fn(options, params)
|
||||
);
|
||||
}
|
||||
|
||||
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: unknown[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||
return (constructorOrId: AbiConstructor | string | number, options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): T =>
|
||||
isOptions(options)
|
||||
? fn(constructorOrId, options, params)
|
||||
: fn(constructorOrId, ...extractOptions<BlueprintOptions>(options, params));
|
||||
return (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, ...params: unknown[]): T =>
|
||||
fn(constructorOrId, options, params);
|
||||
}
|
||||
|
||||
export function encodeSalt (salt: Uint8Array | string | null = randomAsU8a()): Uint8Array {
|
||||
|
||||
@@ -14,12 +14,8 @@ import abiIncrementer from './test/contracts/ink/v0/incrementer.json' assert { t
|
||||
async function checkBlueprint (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
const blueprint = new BlueprintPromise(api, abiIncrementer as Record<string, unknown>, '0x1234');
|
||||
|
||||
// new style
|
||||
await blueprint.tx.new({ gasLimit: 456, salt: '0x1234', value: 123 }, 42).signAndSend(pairs.bob);
|
||||
await blueprint.tx.new({ gasLimit: 456, value: 123 }, 42).signAndSend(pairs.bob);
|
||||
|
||||
// old style
|
||||
await blueprint.tx.new(123, 456, 42).signAndSend(pairs.bob);
|
||||
}
|
||||
|
||||
async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
@@ -27,11 +23,9 @@ async function checkContract (api: ApiPromise, pairs: TestKeyringMap): Promise<v
|
||||
|
||||
// queries
|
||||
await contract.query.get(pairs.alice.address, {});
|
||||
await contract.query.get(pairs.alice.address, 0, 0);
|
||||
|
||||
// execute
|
||||
await contract.tx.inc({ gasLimit: 1234 }, 123).signAndSend(pairs.eve);
|
||||
await contract.tx.inc(123, 456, 69).signAndSend(pairs.eve);
|
||||
}
|
||||
|
||||
async function main (): Promise<void> {
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
[
|
||||
{
|
||||
"info": "Plain",
|
||||
"lookupIndex": 0,
|
||||
"type": "u8",
|
||||
"docs": [],
|
||||
"namespace": ""
|
||||
},
|
||||
{
|
||||
"info": "Plain",
|
||||
"lookupIndex": 1,
|
||||
"type": "Text",
|
||||
"docs": [],
|
||||
"namespace": ""
|
||||
},
|
||||
{
|
||||
"info": "VecFixed",
|
||||
"lookupIndex": 2,
|
||||
"type": "[u8;32]",
|
||||
"docs": [],
|
||||
"namespace": "",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": "Plain",
|
||||
"lookupIndex": 0,
|
||||
"type": "u8",
|
||||
"docs": [],
|
||||
"namespace": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"info": "Struct",
|
||||
"lookupIndex": 3,
|
||||
"type": "{\"inner\":\"[u8;32]\"}",
|
||||
"docs": [],
|
||||
"namespace": "",
|
||||
"sub": [
|
||||
{
|
||||
"docs": [],
|
||||
"name": "inner",
|
||||
"info": "VecFixed",
|
||||
"lookupIndex": 2,
|
||||
"type": "[u8;32]",
|
||||
"namespace": "",
|
||||
"length": 32,
|
||||
"sub": {
|
||||
"info": "Plain",
|
||||
"lookupIndex": 0,
|
||||
"type": "u8",
|
||||
"docs": [],
|
||||
"namespace": ""
|
||||
},
|
||||
"typeName": "FixedArray32"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"info": "Plain",
|
||||
"lookupIndex": 4,
|
||||
"type": "u128",
|
||||
"docs": [],
|
||||
"namespace": ""
|
||||
},
|
||||
{
|
||||
"info": "Plain",
|
||||
"lookupIndex": 5,
|
||||
"type": "bool",
|
||||
"docs": [],
|
||||
"namespace": ""
|
||||
}
|
||||
]
|
||||
@@ -3,5 +3,6 @@
|
||||
|
||||
import { createVersionedExport } from '../util';
|
||||
import * as v0 from './v0';
|
||||
import * as v3 from './v3';
|
||||
|
||||
export default createVersionedExport({ v0 });
|
||||
export default createVersionedExport({ v0, v3 });
|
||||
|
||||
@@ -0,0 +1,550 @@
|
||||
{
|
||||
"source": {
|
||||
"hash": "",
|
||||
"language": "Ask! 0.4.0",
|
||||
"compiler": "asc 0.19.23"
|
||||
},
|
||||
"contract": {
|
||||
"name": "",
|
||||
"version": "",
|
||||
"authors": []
|
||||
},
|
||||
"V3": {
|
||||
"spec": {
|
||||
"constructors": [
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 1,
|
||||
"displayName": [
|
||||
"string"
|
||||
]
|
||||
},
|
||||
"label": "name"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 1,
|
||||
"displayName": [
|
||||
"string"
|
||||
]
|
||||
},
|
||||
"label": "symbol"
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"label": "default",
|
||||
"payable": false,
|
||||
"selector": "0xed4b9d1b"
|
||||
}
|
||||
],
|
||||
"messages": [
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "to"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "amount"
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"label": "mint",
|
||||
"selector": "0xcfdd9aa2"
|
||||
},
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "from"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "amount"
|
||||
}
|
||||
],
|
||||
"docs": [],
|
||||
"label": "burn",
|
||||
"selector": "0xb1efc17b"
|
||||
},
|
||||
{
|
||||
"mutates": false,
|
||||
"payable": false,
|
||||
"args": [],
|
||||
"returnType": {
|
||||
"type": 1,
|
||||
"displayName": [
|
||||
"string"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "name",
|
||||
"selector": "0x3adaf70d"
|
||||
},
|
||||
{
|
||||
"mutates": false,
|
||||
"payable": false,
|
||||
"args": [],
|
||||
"returnType": {
|
||||
"type": 1,
|
||||
"displayName": [
|
||||
"string"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "symbol",
|
||||
"selector": "0x9bd1933e"
|
||||
},
|
||||
{
|
||||
"mutates": false,
|
||||
"payable": false,
|
||||
"args": [],
|
||||
"returnType": {
|
||||
"type": 0,
|
||||
"displayName": [
|
||||
"u8"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "decimal",
|
||||
"selector": "0xcc3fec6d"
|
||||
},
|
||||
{
|
||||
"mutates": false,
|
||||
"payable": false,
|
||||
"args": [],
|
||||
"returnType": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "totalSupply",
|
||||
"selector": "0xcae60595"
|
||||
},
|
||||
{
|
||||
"mutates": false,
|
||||
"payable": false,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "account"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "balanceOf",
|
||||
"selector": "0xf48def67"
|
||||
},
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "recipient"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "amount"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 5,
|
||||
"displayName": [
|
||||
"bool"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "transfer",
|
||||
"selector": "0x84a15da1"
|
||||
},
|
||||
{
|
||||
"mutates": false,
|
||||
"payable": false,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "owner"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "spender"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "allowance",
|
||||
"selector": "0x6a00165e"
|
||||
},
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "spender"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "amount"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 5,
|
||||
"displayName": [
|
||||
"bool"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "approve",
|
||||
"selector": "0x681266a0"
|
||||
},
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "sender"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "recipient"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "amount"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 5,
|
||||
"displayName": [
|
||||
"bool"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "transferFrom",
|
||||
"selector": "0x02a6e0d5"
|
||||
},
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "spender"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "addedValue"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 5,
|
||||
"displayName": [
|
||||
"bool"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "increaseAllowance",
|
||||
"selector": "0xcb005356"
|
||||
},
|
||||
{
|
||||
"mutates": true,
|
||||
"payable": true,
|
||||
"args": [
|
||||
{
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"label": "spender"
|
||||
},
|
||||
{
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"label": "subtractedValue"
|
||||
}
|
||||
],
|
||||
"returnType": {
|
||||
"type": 5,
|
||||
"displayName": [
|
||||
"bool"
|
||||
]
|
||||
},
|
||||
"docs": [],
|
||||
"label": "decreaseAllowance",
|
||||
"selector": "0xe19fabb4"
|
||||
}
|
||||
],
|
||||
"events": [
|
||||
{
|
||||
"id": 1,
|
||||
"label": "Transfer",
|
||||
"args": [
|
||||
{
|
||||
"label": "from",
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "to",
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "value",
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"label": "Approval",
|
||||
"args": [
|
||||
{
|
||||
"label": "owner",
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "spender",
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"type": 3,
|
||||
"displayName": [
|
||||
"AccountId"
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "value",
|
||||
"indexed": false,
|
||||
"type": {
|
||||
"type": 4,
|
||||
"displayName": [
|
||||
"u128"
|
||||
]
|
||||
},
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"docs": [
|
||||
""
|
||||
]
|
||||
},
|
||||
"types": [
|
||||
{
|
||||
"id": 0,
|
||||
"type": {
|
||||
"def": {
|
||||
"primitive": "u8"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"type": {
|
||||
"def": {
|
||||
"primitive": "str"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"type": {
|
||||
"def": {
|
||||
"array": {
|
||||
"len": 32,
|
||||
"type": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"type": {
|
||||
"def": {
|
||||
"composite": {
|
||||
"fields": [
|
||||
{
|
||||
"name": "inner",
|
||||
"type": 2,
|
||||
"typeName": "FixedArray32<u8>"
|
||||
}
|
||||
]
|
||||
},
|
||||
"path": []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"type": {
|
||||
"def": {
|
||||
"primitive": "u128"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"type": {
|
||||
"def": {
|
||||
"primitive": "bool"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/api-contract authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as ask } from './ask.json' assert { type: 'json' };
|
||||
@@ -3,15 +3,9 @@
|
||||
|
||||
import type { SubmittableResult } from '@polkadot/api';
|
||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||
import type { BN } from '@polkadot/util';
|
||||
import type { BlueprintOptions, ContractOptions } from './types';
|
||||
|
||||
import { isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
|
||||
type ContractEvents = 'CodeStored' | 'ContractEmitted' | 'ContractExecution' | 'Instantiated';
|
||||
|
||||
type TOptions = BlueprintOptions | ContractOptions;
|
||||
|
||||
export function applyOnEvent <T> (result: SubmittableResult, types: ContractEvents[], fn: (records: EventRecord[]) => T): T | undefined {
|
||||
if (result.isInBlock || result.isFinalized) {
|
||||
const records = result.filterRecords('contracts', types);
|
||||
@@ -23,13 +17,3 @@ export function applyOnEvent <T> (result: SubmittableResult, types: ContractEven
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function isOptions <T> (options: bigint | string | number | BN | T): options is T {
|
||||
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
|
||||
}
|
||||
|
||||
export function extractOptions <T extends TOptions> (value: bigint | string | number | BN, params: unknown[]): [T, unknown[]] {
|
||||
const gasLimit = params.shift() as BN;
|
||||
|
||||
return [{ gasLimit, value } as T, params];
|
||||
}
|
||||
|
||||
@@ -20,25 +20,25 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api": "8.13.1",
|
||||
"@polkadot/api-augment": "8.13.1",
|
||||
"@polkadot/api-base": "8.13.1",
|
||||
"@polkadot/rpc-core": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/api": "9.2.2",
|
||||
"@polkadot/api-augment": "9.2.2",
|
||||
"@polkadot/api-base": "9.2.2",
|
||||
"@polkadot/rpc-core": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"@polkadot/util-crypto": "^10.1.4",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api": "8.13.1",
|
||||
"@polkadot/api-augment": "8.13.1",
|
||||
"@polkadot/rpc-augment": "8.13.1",
|
||||
"@polkadot/rpc-provider": "8.13.1",
|
||||
"@polkadot/types-support": "8.13.1"
|
||||
"@polkadot/api": "9.2.2",
|
||||
"@polkadot/api-augment": "9.2.2",
|
||||
"@polkadot/rpc-augment": "9.2.2",
|
||||
"@polkadot/rpc-provider": "9.2.2",
|
||||
"@polkadot/types-support": "9.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2017-2022 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { hasProposals as collectiveHasProposals, members as collectiveMembers, prime as collectivePrime, proposal as collectiveProposal, proposalCount as collectiveProposalCount, proposalHashes as collectiveProposalHashes, proposals as collectiveProposals } from '../collective';
|
||||
|
||||
export const members = collectiveMembers('allianceMotion');
|
||||
|
||||
export const hasProposals = collectiveHasProposals('allianceMotion');
|
||||
export const proposal = collectiveProposal('allianceMotion');
|
||||
export const proposalCount = collectiveProposalCount('allianceMotion');
|
||||
export const proposalHashes = collectiveProposalHashes('allianceMotion');
|
||||
export const proposals = collectiveProposals('allianceMotion');
|
||||
|
||||
export const prime = collectivePrime('allianceMotion');
|
||||
@@ -10,7 +10,7 @@ import type { Bag } from './types';
|
||||
|
||||
import { map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { BN_ZERO, bnToBn } from '@polkadot/util';
|
||||
import { BN_ZERO, bnToBn, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -21,20 +21,17 @@ function orderBags (ids: BN[], bags: Option<PalletBagsListListBag>[]): Bag[] {
|
||||
id,
|
||||
key: id.toString()
|
||||
}))
|
||||
.sort((a, b) => b.id.cmp(a.id))
|
||||
.map((base, index): Bag => ({
|
||||
...base,
|
||||
bagLower: BN_ZERO,
|
||||
bagUpper: base.id,
|
||||
index
|
||||
}));
|
||||
.sort((a, b) => b.id.cmp(a.id));
|
||||
const max = sorted.length - 1;
|
||||
|
||||
return sorted.map((entry, index) =>
|
||||
index === max
|
||||
? entry
|
||||
// We could probably use a .add(BN_ONE) here
|
||||
: { ...entry, bagLower: sorted[index + 1].bagUpper }
|
||||
return sorted.map((entry, index): Bag =>
|
||||
objectSpread(entry, {
|
||||
bagLower: index === max
|
||||
? BN_ZERO
|
||||
: sorted[index + 1].id,
|
||||
bagUpper: entry.id,
|
||||
index
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,14 @@ import type { Bag, BagExpanded } from './types';
|
||||
|
||||
import { map, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function expand (instanceId: string, api: DeriveApi): (bag: Bag) => Observable<BagExpanded> {
|
||||
return memo(instanceId, (bag: Bag): Observable<BagExpanded> =>
|
||||
api.derive.bagsList.listNodes(bag.bag).pipe(
|
||||
map((nodes) => ({ ...bag, nodes }))
|
||||
map((nodes) => objectSpread({ nodes }, bag))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveApi, DeriveBalancesAccount, DeriveBalancesAccountData } from
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -40,12 +40,11 @@ function getBalance (api: DeriveApi, [freeBalance, reservedBalance, frozenFee, f
|
||||
}
|
||||
|
||||
function calcBalances (api: DeriveApi, [accountId, [accountNonce, [primary, ...additional]]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||
return {
|
||||
return objectSpread({
|
||||
accountId,
|
||||
accountNonce,
|
||||
additional: additional.map((b) => getBalance(api, b)),
|
||||
...getBalance(api, primary)
|
||||
};
|
||||
additional: additional.map((b) => getBalance(api, b))
|
||||
}, getBalance(api, primary));
|
||||
}
|
||||
|
||||
// old
|
||||
@@ -150,7 +149,8 @@ function querySystemAccount (api: DeriveApi, accountId: AccountId): Observable<R
|
||||
* ```
|
||||
*/
|
||||
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> =>
|
||||
api.derive.accounts.accountId(address).pipe(
|
||||
@@ -158,7 +158,7 @@ export function account (instanceId: string, api: DeriveApi): (address: AccountI
|
||||
(accountId
|
||||
? combineLatest([
|
||||
of(accountId),
|
||||
balanceInstances
|
||||
nonDefaultBalances
|
||||
? queryBalancesAccount(api, accountId, balanceInstances)
|
||||
: isFunction(api.query.system?.account)
|
||||
? querySystemAccount(api, accountId)
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveApi, DeriveBalancesAccount, DeriveBalancesAccountData, Deriv
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { BN, BN_ZERO, bnMax, bnMin, isFunction } from '@polkadot/util';
|
||||
import { BN, BN_ZERO, bnMax, bnMin, isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -57,13 +57,12 @@ function calcLocked (api: DeriveApi, bestNumber: BlockNumber, locks: (PalletBala
|
||||
function calcShared (api: DeriveApi, bestNumber: BlockNumber, data: DeriveBalancesAccountData, locks: (PalletBalancesBalanceLock | BalanceLockTo212)[]): DeriveBalancesAllAccountData {
|
||||
const { allLocked, lockedBalance, lockedBreakdown, vestingLocked } = calcLocked(api, bestNumber, locks);
|
||||
|
||||
return {
|
||||
...data,
|
||||
return objectSpread({}, data, {
|
||||
availableBalance: api.registry.createType('Balance', allLocked ? 0 : bnMax(new BN(0), data.freeBalance.sub(lockedBalance))),
|
||||
lockedBalance,
|
||||
lockedBreakdown,
|
||||
vestingLocked
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function calcVesting (bestNumber: BlockNumber, shared: DeriveBalancesAllAccountData, _vesting: PalletVestingVestingInfo[] | null): DeriveBalancesAllVesting {
|
||||
@@ -102,16 +101,14 @@ function calcVesting (bestNumber: BlockNumber, shared: DeriveBalancesAllAccountD
|
||||
function calcBalances (api: DeriveApi, [data, [vesting, allLocks, namedReserves], bestNumber]: Result): DeriveBalancesAll {
|
||||
const shared = calcShared(api, bestNumber, data, allLocks[0]);
|
||||
|
||||
return {
|
||||
...shared,
|
||||
...calcVesting(bestNumber, shared, vesting),
|
||||
return objectSpread(shared, calcVesting(bestNumber, shared, vesting), {
|
||||
accountId: data.accountId,
|
||||
accountNonce: data.accountNonce,
|
||||
additional: allLocks
|
||||
.filter((_, index) => index !== 0)
|
||||
.slice(1)
|
||||
.map((l, index) => calcShared(api, bestNumber, data.additional[index], l)),
|
||||
namedReserves
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// old
|
||||
@@ -211,7 +208,7 @@ function queryCurrent (api: DeriveApi, accountId: AccountId | string, balanceIns
|
||||
* ```
|
||||
*/
|
||||
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> =>
|
||||
combineLatest([
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
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 { DeriveApi } from './types';
|
||||
|
||||
@@ -22,6 +22,10 @@ export { lazyDeriveSection };
|
||||
|
||||
// Enable derive only if some of these modules are available
|
||||
const checks: Record<string, Avail> = {
|
||||
allianceMotion: {
|
||||
instances: ['allianceMotion'],
|
||||
methods: []
|
||||
},
|
||||
bagsList: {
|
||||
instances: ['voterList', 'bagsList'],
|
||||
methods: [],
|
||||
@@ -84,7 +88,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) || [];
|
||||
}
|
||||
|
||||
@@ -97,7 +101,7 @@ function injectFunctions (instanceId: string, api: DeriveApi, derives: DeriveCus
|
||||
const result: Record<string, Record<string, AnyFunction>> = {};
|
||||
const names = Object.keys(derives);
|
||||
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 filterInstances = (q: string) => getModuleInstances(api, specName, q).some(filterKeys);
|
||||
|
||||
@@ -12,7 +12,7 @@ import { isFunction } from '@polkadot/util';
|
||||
import { memo } from '../util';
|
||||
|
||||
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
|
||||
? instances[0]
|
||||
: section;
|
||||
|
||||
@@ -58,7 +58,7 @@ export function hasProposals (section: Collective): (instanceId: string, api: De
|
||||
export function proposals (section: Collective): (instanceId: string, api: DeriveApi) => () => Observable<DeriveCollectiveProposal[]> {
|
||||
return withSection(section, (query, api) =>
|
||||
(): Observable<DeriveCollectiveProposal[]> =>
|
||||
api.derive[section].proposalHashes().pipe(
|
||||
api.derive[section as 'council'].proposalHashes().pipe(
|
||||
switchMap((all) => _proposalsFrom(api, query, all))
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2017-2022 @polkadot/api-derive authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export type Collective = 'council' | 'membership' | 'technicalCommittee';
|
||||
export type Collective = 'allianceMotion' | 'council' | 'membership' | 'technicalCommittee';
|
||||
|
||||
@@ -7,6 +7,8 @@ import type { DeriveApi, DeriveOwnContributions } from '../types';
|
||||
|
||||
import { combineLatest, EMPTY, map, of, startWith, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { extractContributed } from './util';
|
||||
|
||||
@@ -21,10 +23,8 @@ function _getValues (api: DeriveApi, childKey: string, keys: string[]): Observab
|
||||
? api.registry.createType('Balance', o.unwrap())
|
||||
: api.registry.createType('Balance')
|
||||
)
|
||||
.reduce((all: DeriveOwnContributions, b, index): DeriveOwnContributions => ({
|
||||
...all,
|
||||
[keys[index]]: b
|
||||
}), {})
|
||||
.reduce((all: DeriveOwnContributions, b, index): DeriveOwnContributions =>
|
||||
objectSpread(all, { [keys[index]]: b }), {})
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -51,10 +51,9 @@ function _contributions (api: DeriveApi, paraId: string | number | BN, childKey:
|
||||
_getValues(api, childKey, keys),
|
||||
_watchOwnChanges(api, paraId, childKey, keys)
|
||||
]).pipe(
|
||||
map(([all, latest]) => ({
|
||||
...all,
|
||||
...latest
|
||||
}))
|
||||
map(([all, latest]) =>
|
||||
objectSpread({}, all, latest)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { DeriveApi, DeriveDispatch, DeriveProposalImage } from '../types';
|
||||
import { catchError, combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { Enum } from '@polkadot/types';
|
||||
import { isFunction, stringToHex } from '@polkadot/util';
|
||||
import { isFunction, objectSpread, stringToHex } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -107,7 +107,7 @@ function queryScheduler (api: DeriveApi): Observable<DeriveDispatch[]> {
|
||||
]);
|
||||
}),
|
||||
map(([infos, images]): DeriveDispatch[] =>
|
||||
infos.map((info, index) => ({ ...info, image: images[index] }))
|
||||
infos.map((info, index) => objectSpread({ image: images[index] }, info))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { DeriveApi, DeriveProposal, DeriveProposalImage } from '../types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
@@ -33,17 +33,17 @@ function parse ([proposals, images, optDepositors]: Result): DeriveProposal[] {
|
||||
.map(([index, imageHash, proposer], proposalIndex): DeriveProposal => {
|
||||
const depositors = optDepositors[proposalIndex].unwrap();
|
||||
|
||||
return {
|
||||
...(
|
||||
isNewDepositors(depositors)
|
||||
? { balance: depositors[1], seconds: depositors[0] }
|
||||
: { balance: depositors[0], seconds: depositors[1] }
|
||||
),
|
||||
image: images[proposalIndex],
|
||||
imageHash,
|
||||
index,
|
||||
proposer
|
||||
};
|
||||
return objectSpread(
|
||||
{
|
||||
image: images[proposalIndex],
|
||||
imageHash,
|
||||
index,
|
||||
proposer
|
||||
},
|
||||
isNewDepositors(depositors)
|
||||
? { balance: depositors[1], seconds: depositors[0] }
|
||||
: { balance: depositors[0], seconds: depositors[1] }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -56,9 +56,11 @@ export function proposals (instanceId: string, api: DeriveApi): () => Observable
|
||||
? combineLatest([
|
||||
of(proposals),
|
||||
api.derive.democracy.preimages(
|
||||
proposals.map(([, hash]) => hash)),
|
||||
proposals.map(([, hash]) => hash)
|
||||
),
|
||||
api.query.democracy.depositOf.multi(
|
||||
proposals.map(([index]) => index))
|
||||
proposals.map(([index]) => index)
|
||||
)
|
||||
])
|
||||
: of<Result>([[], [], []])
|
||||
),
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { DeriveApi, DeriveReferendumExt } from '../types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
export function referendums (instanceId: string, api: DeriveApi): () => Observable<DeriveReferendumExt[]> {
|
||||
@@ -20,10 +22,9 @@ export function referendums (instanceId: string, api: DeriveApi): () => Observab
|
||||
: of([[], []])
|
||||
),
|
||||
map(([referendums, votes]) =>
|
||||
referendums.map((referendum, index): DeriveReferendumExt => ({
|
||||
...referendum,
|
||||
...votes[index]
|
||||
}))
|
||||
referendums.map((referendum, index): DeriveReferendumExt =>
|
||||
objectSpread({}, referendum, votes[index])
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { DeriveApi, DeriveBalancesAccount, DeriveReferendum, DeriveReferend
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { isFunction } from '@polkadot/util';
|
||||
import { isFunction, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { calcVotes, getStatus } from './util';
|
||||
@@ -57,11 +57,12 @@ function extractVotes (mapped: [AccountId, PalletDemocracyVoteVoting][], referen
|
||||
// FIXME We are ignoring split votes
|
||||
votes.reduce((result: DeriveReferendumVote[], [, vote]): DeriveReferendumVote[] => {
|
||||
if (vote.isStandard) {
|
||||
result.push({
|
||||
accountId,
|
||||
isDelegating: false,
|
||||
...vote.asStandard
|
||||
});
|
||||
result.push(
|
||||
objectSpread({
|
||||
accountId,
|
||||
isDelegating: false
|
||||
}, vote.asStandard)
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { PalletDemocracyReferendumInfo, PalletDemocracyReferendumStatus, Pa
|
||||
import type { Option } from '@polkadot/types-codec';
|
||||
import type { DeriveReferendum, DeriveReferendumVote, DeriveReferendumVotes, DeriveReferendumVoteState } from '../types';
|
||||
|
||||
import { BN, bnSqrt } from '@polkadot/util';
|
||||
import { BN, bnSqrt, objectSpread } from '@polkadot/util';
|
||||
|
||||
interface ApproxState {
|
||||
votedAye: BN;
|
||||
@@ -119,11 +119,10 @@ export function calcVotes (sqrtElectorate: BN, referendum: DeriveReferendum, vot
|
||||
? calcVotesCurrent(referendum.status.tally, votes)
|
||||
: calcVotesPrev(votes);
|
||||
|
||||
return {
|
||||
...state,
|
||||
return objectSpread({}, state, {
|
||||
isPassing: calcPassing(referendum.status.threshold, sqrtElectorate, state),
|
||||
votes
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export function getStatus (info: Option<PalletDemocracyReferendumInfo | ReferendumInfoTo239>): PalletDemocracyReferendumStatus | ReferendumInfoTo239 | null {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import type { AnyFunction } from '@polkadot/types/types';
|
||||
|
||||
import * as accounts from './accounts';
|
||||
import * as alliance from './alliance';
|
||||
import * as bagsList from './bagsList';
|
||||
import * as balances from './balances';
|
||||
import * as bounties from './bounties';
|
||||
@@ -23,7 +24,7 @@ import * as technicalCommittee from './technicalCommittee';
|
||||
import * as treasury from './treasury';
|
||||
import * as tx from './tx';
|
||||
|
||||
export const derive = { accounts, bagsList, balances, bounties, chain, contracts, council, crowdloan, democracy, elections, imOnline, membership, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
export const derive = { accounts, alliance, bagsList, balances, bounties, chain, contracts, council, crowdloan, democracy, elections, imOnline, membership, parachains, session, society, staking, technicalCommittee, treasury, tx };
|
||||
|
||||
type DeriveSection<Section> = {
|
||||
[M in keyof Section]: Section[M] extends AnyFunction
|
||||
|
||||
@@ -11,6 +11,8 @@ import type { DeriveElectionsInfo } from './types';
|
||||
|
||||
import { combineLatest, map, of } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
// SeatHolder is current tuple is 2.x-era Substrate
|
||||
@@ -55,7 +57,7 @@ function getConstants (api: DeriveApi, elections: string | null): Partial<Derive
|
||||
}
|
||||
|
||||
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
|
||||
? 'phragmenElection'
|
||||
: api.query.electionsPhragmen
|
||||
@@ -107,15 +109,16 @@ export function info (instanceId: string, api: DeriveApi): () => Observable<Deri
|
||||
? queryAll(api, council, elections)
|
||||
: queryCouncil(api, council)
|
||||
).pipe(
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo => ({
|
||||
...getConstants(api, elections),
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates: candidates.map(getCandidate),
|
||||
members: members.length
|
||||
? members.map(getAccountTuple).sort(sortAccounts)
|
||||
: councilMembers.map((a): [AccountId32, Balance] => [a, api.registry.createType('Balance')]),
|
||||
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts)
|
||||
}))
|
||||
map(([councilMembers, candidates, members, runnersUp]): DeriveElectionsInfo =>
|
||||
objectSpread({}, getConstants(api, elections), {
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates: candidates.map(getCandidate),
|
||||
members: members.length
|
||||
? members.map(getAccountTuple).sort(sortAccounts)
|
||||
: councilMembers.map((a): [AccountId32, Balance] => [a, api.registry.createType('Balance')]),
|
||||
runnersUp: runnersUp.map(getAccountTuple).sort(sortAccounts)
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { Active, DidUpdate, Heads, ParaInfoResult, PendingSwap, RelayDispat
|
||||
|
||||
import { map, of } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { didUpdateToBool } from './util';
|
||||
|
||||
@@ -28,20 +30,18 @@ function parseActive (id: ParaId, active: Active): DeriveParachainActive | null
|
||||
if (found && found[1].isSome) {
|
||||
const [collatorId, retriable] = found[1].unwrap();
|
||||
|
||||
return {
|
||||
collatorId,
|
||||
...(
|
||||
retriable.isWithRetries
|
||||
? {
|
||||
isRetriable: true,
|
||||
retries: retriable.asWithRetries.toNumber()
|
||||
}
|
||||
: {
|
||||
isRetriable: false,
|
||||
retries: 0
|
||||
}
|
||||
)
|
||||
};
|
||||
return objectSpread<DeriveParachainActive>(
|
||||
{ collatorId },
|
||||
retriable.isWithRetries
|
||||
? {
|
||||
isRetriable: true,
|
||||
retries: retriable.asWithRetries.toNumber()
|
||||
}
|
||||
: {
|
||||
isRetriable: false,
|
||||
retries: 0
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -65,7 +65,7 @@ function parse (id: ParaId, [active, retryQueue, selectedThreads, didUpdate, inf
|
||||
didUpdate: didUpdateToBool(didUpdate, id),
|
||||
heads,
|
||||
id,
|
||||
info: { id, ...info.unwrap() } as DeriveParachainInfo,
|
||||
info: objectSpread<DeriveParachainInfo>({ id }, info.unwrap()),
|
||||
pendingSwapId: pendingSwap.unwrapOr(null),
|
||||
relayDispatchQueue,
|
||||
retryCollators: parseCollators(id, retryQueue),
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { DidUpdate, ParaInfoResult, PendingSwap, RelayDispatchQueueSize } f
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
import { didUpdateToBool } from './util';
|
||||
|
||||
@@ -23,7 +25,7 @@ function parse ([ids, didUpdate, infos, pendingSwaps, relayDispatchQueueSizes]:
|
||||
return ids.map((id, index): DeriveParachain => ({
|
||||
didUpdate: didUpdateToBool(didUpdate, id),
|
||||
id,
|
||||
info: { id, ...infos[index].unwrapOr(null) } as DeriveParachainInfo,
|
||||
info: objectSpread<DeriveParachainInfo>({ id }, infos[index].unwrapOr(null)),
|
||||
pendingSwapId: pendingSwaps[index].unwrapOr(null),
|
||||
relayDispatchQueueSize: relayDispatchQueueSizes[index][0].toNumber()
|
||||
}));
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { DeriveApi, DeriveSessionInfo } from '../types';
|
||||
|
||||
import { map } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -18,13 +20,12 @@ export function info (instanceId: string, api: DeriveApi): () => Observable<Deri
|
||||
const sessionLength = api.consts?.babe?.epochDuration || api.registry.createType('u64', 1);
|
||||
const sessionsPerEra = api.consts?.staking?.sessionsPerEra || api.registry.createType('SessionIndex', 1);
|
||||
|
||||
return {
|
||||
...indexes,
|
||||
return objectSpread({
|
||||
eraLength: api.registry.createType('BlockNumber', sessionsPerEra.mul(sessionLength)),
|
||||
isEpoch: !!api.query.babe,
|
||||
sessionLength,
|
||||
sessionsPerEra
|
||||
};
|
||||
}, indexes);
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
@@ -8,6 +8,8 @@ import type { DeriveApi, DeriveSessionInfo, DeriveSessionProgress } from '../typ
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
type ResultSlotsNoSession = [u64, u64, u64];
|
||||
@@ -28,20 +30,20 @@ function createDerive (api: DeriveApi, info: DeriveSessionInfo, [currentSlot, ep
|
||||
const sessionProgress = currentSlot.sub(epochStartSlot);
|
||||
const eraProgress = info.currentIndex.sub(activeEraStartSessionIndex).imul(info.sessionLength).iadd(sessionProgress);
|
||||
|
||||
return {
|
||||
...info,
|
||||
return objectSpread({
|
||||
eraProgress: api.registry.createType('BlockNumber', eraProgress),
|
||||
sessionProgress: api.registry.createType('BlockNumber', sessionProgress)
|
||||
};
|
||||
}, info);
|
||||
}
|
||||
|
||||
function queryAura (api: DeriveApi): Observable<DeriveSessionProgress> {
|
||||
return api.derive.session.info().pipe(
|
||||
map((info): DeriveSessionProgress => ({
|
||||
...info,
|
||||
eraProgress: api.registry.createType('BlockNumber'),
|
||||
sessionProgress: api.registry.createType('BlockNumber')
|
||||
}))
|
||||
map((info): DeriveSessionProgress =>
|
||||
objectSpread({
|
||||
eraProgress: api.registry.createType('BlockNumber'),
|
||||
sessionProgress: api.registry.createType('BlockNumber')
|
||||
}, info)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import type { StakingQueryFlags } from './types';
|
||||
|
||||
import { combineLatest, map, switchMap } from 'rxjs';
|
||||
|
||||
import { BN, BN_ZERO } from '@polkadot/util';
|
||||
import { BN, BN_ZERO, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { firstMemo, memo } from '../util';
|
||||
|
||||
@@ -54,12 +54,10 @@ function redeemableSum (api: DeriveApi, stakingLedger: PalletStakingStakingLedge
|
||||
}
|
||||
|
||||
function parseResult (api: DeriveApi, sessionInfo: DeriveSessionInfo, keys: DeriveStakingKeys, query: DeriveStakingQuery): DeriveStakingAccount {
|
||||
return {
|
||||
...keys,
|
||||
...query,
|
||||
return objectSpread({}, keys, query, {
|
||||
redeemable: redeemableSum(api, query.stakingLedger, sessionInfo),
|
||||
unlocking: calculateUnlocking(api, query.stakingLedger, sessionInfo)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { Option } from '@polkadot/types';
|
||||
import type { AccountId } from '@polkadot/types/interfaces';
|
||||
import type { NodeRuntimeSessionKeys } from '@polkadot/types/lookup';
|
||||
import type { KitchensinkRuntimeSessionKeys } from '@polkadot/types/lookup';
|
||||
import type { DeriveApi } from '../types';
|
||||
import type { DeriveStakingKeys } from './types';
|
||||
|
||||
@@ -12,7 +12,7 @@ import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { firstMemo, memo } from '../util';
|
||||
|
||||
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, NodeRuntimeSessionKeys | AccountId[]][], nextKeys: Option<NodeRuntimeSessionKeys>): DeriveStakingKeys {
|
||||
function extractsIds (stashId: Uint8Array | string, queuedKeys: [AccountId, KitchensinkRuntimeSessionKeys | AccountId[]][], nextKeys: Option<KitchensinkRuntimeSessionKeys>): DeriveStakingKeys {
|
||||
const sessionIds = (queuedKeys.find(([currentId]) => currentId.eq(stashId)) || [undefined, [] as AccountId[]])[1];
|
||||
const nextSessionIds = nextKeys.unwrapOr([] as AccountId[]);
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { DeriveApi, DeriveStakingOverview } from '../types';
|
||||
|
||||
import { combineLatest, map } from 'rxjs';
|
||||
|
||||
import { objectSpread } from '@polkadot/util';
|
||||
|
||||
import { memo } from '../util';
|
||||
|
||||
/**
|
||||
@@ -17,10 +19,11 @@ export function overview (instanceId: string, api: DeriveApi): () => Observable<
|
||||
api.derive.session.indexes(),
|
||||
api.derive.staking.validators()
|
||||
]).pipe(
|
||||
map(([indexes, { nextElected, validators }]): DeriveStakingOverview => ({
|
||||
...indexes,
|
||||
nextElected,
|
||||
validators
|
||||
}))
|
||||
map(([indexes, { nextElected, validators }]): DeriveStakingOverview =>
|
||||
objectSpread({}, indexes, {
|
||||
nextElected,
|
||||
validators
|
||||
})
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import type { DeriveStakingQuery } from './types';
|
||||
|
||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { BN_BILLION, BN_ZERO } from '@polkadot/util';
|
||||
import { BN_BILLION, BN_ZERO, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { firstMemo, memo } from '../util';
|
||||
|
||||
@@ -125,10 +125,11 @@ function filterRewards (eras: EraIndex[], valInfo: [string, DeriveStakingQuery][
|
||||
return true;
|
||||
})
|
||||
.filter(({ validators }) => Object.keys(validators).length !== 0)
|
||||
.map((reward) => ({
|
||||
...reward,
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
}));
|
||||
.map((reward) =>
|
||||
objectSpread({}, reward, {
|
||||
nominators: reward.nominating.filter((n) => reward.validators[n.validatorId])
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
export function _stakerRewardsEras (instanceId: string, api: DeriveApi): (eras: EraIndex[], withActive?: boolean) => Observable<ErasResult> {
|
||||
|
||||
+18
-18
@@ -20,29 +20,29 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api-augment": "8.13.1",
|
||||
"@polkadot/api-base": "8.13.1",
|
||||
"@polkadot/api-derive": "8.13.1",
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/rpc-augment": "8.13.1",
|
||||
"@polkadot/rpc-core": "8.13.1",
|
||||
"@polkadot/rpc-provider": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-augment": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/types-create": "8.13.1",
|
||||
"@polkadot/types-known": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/api-augment": "9.2.2",
|
||||
"@polkadot/api-base": "9.2.2",
|
||||
"@polkadot/api-derive": "9.2.2",
|
||||
"@polkadot/keyring": "^10.1.4",
|
||||
"@polkadot/rpc-augment": "9.2.2",
|
||||
"@polkadot/rpc-core": "9.2.2",
|
||||
"@polkadot/rpc-provider": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-augment": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/types-create": "9.2.2",
|
||||
"@polkadot/types-known": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"@polkadot/util-crypto": "^10.1.4",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/api-augment": "8.13.1",
|
||||
"@polkadot/types-support": "8.13.1"
|
||||
"@polkadot/api-augment": "9.2.2",
|
||||
"@polkadot/types-support": "9.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { AugmentedCall, DeriveCustom, QueryableCalls } from '@polkadot/api-base/types';
|
||||
import type { RpcInterface } from '@polkadot/rpc-core/types';
|
||||
import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { StorageKey, Text, u64 } from '@polkadot/types';
|
||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||
@@ -19,7 +19,7 @@ import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray
|
||||
import { getAvailableDerives } from '@polkadot/api-derive';
|
||||
import { memo, RpcCore } from '@polkadot/rpc-core';
|
||||
import { WsProvider } from '@polkadot/rpc-provider';
|
||||
import { expandMetadata, Metadata, typeDefinitions, TypeRegistry, unwrapStorageType } from '@polkadot/types';
|
||||
import { expandMetadata, Metadata, typeDefinitions, TypeRegistry } from '@polkadot/types';
|
||||
import { getSpecRuntime } from '@polkadot/types-known';
|
||||
import { arrayChunk, arrayFlatten, assertReturn, BN, compactStripLength, lazyMethod, lazyMethods, logger, nextTick, objectSpread, stringCamelCase, stringUpperFirst, u8aConcatStrict, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsHex } from '@polkadot/util-crypto';
|
||||
@@ -40,6 +40,7 @@ interface MetaDecoration {
|
||||
}
|
||||
|
||||
interface FullDecoration<ApiType extends ApiTypes> {
|
||||
createdAt?: Uint8Array;
|
||||
decoratedApi: ApiDecoration<ApiType>;
|
||||
decoratedMeta: DecoratedMeta;
|
||||
}
|
||||
@@ -62,6 +63,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
#registry: Registry;
|
||||
|
||||
readonly #runtimeLog: Record<string, boolean> = {};
|
||||
|
||||
#storageGetQ: [Observable<Codec[]>, [StorageEntry, unknown[]][]][] = [];
|
||||
|
||||
#storageSubQ: [Observable<Codec[]>, [StorageEntry, unknown[]][]][] = [];
|
||||
@@ -108,6 +111,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
protected _runtimeVersion?: RuntimeVersion;
|
||||
|
||||
protected _rx: ApiInterfaceRx = {
|
||||
call: {} as QueryableCalls<'rxjs'>,
|
||||
consts: {} as QueryableConsts<'rxjs'>,
|
||||
query: {} as QueryableStorage<'rxjs'>,
|
||||
tx: {} as SubmittableExtrinsics<'rxjs'>
|
||||
@@ -156,6 +160,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
this.#instanceId = `${++instanceCounter}`;
|
||||
this.#registry = options.source?.registry || options.registry || new TypeRegistry();
|
||||
this._rx.callAt = (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) =>
|
||||
from(this.at(blockHash, knownVersion)).pipe(map((a) => a.rx.call));
|
||||
this._rx.queryAt = (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion) =>
|
||||
from(this.at(blockHash, knownVersion)).pipe(map((a) => a.rx.query));
|
||||
this._rx.registry = this.#registry;
|
||||
@@ -220,6 +226,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
query: {},
|
||||
registry,
|
||||
rx: {
|
||||
call: {},
|
||||
query: {}
|
||||
},
|
||||
tx: createSubmittable(this._type, this._rx, this._decorateMethod, registry, blockHash)
|
||||
@@ -236,8 +243,9 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
const runtime = this._decorateCalls(registry, this._decorateMethod, blockHash);
|
||||
const runtimeRx = this._decorateCalls<'rxjs'>(registry, this._rxDecorateMethod, blockHash);
|
||||
const storage = this._decorateStorage(registry.decoratedMeta, this._decorateMethod, blockHash);
|
||||
const storageRx = this._decorateStorage(registry.decoratedMeta, this._rxDecorateMethod, blockHash);
|
||||
const storageRx = this._decorateStorage<'rxjs'>(registry.decoratedMeta, this._rxDecorateMethod, blockHash);
|
||||
|
||||
augmentObject('consts', registry.decoratedMeta.consts, decoratedApi.consts, fromEmpty);
|
||||
augmentObject('errors', registry.decoratedMeta.errors, decoratedApi.errors, fromEmpty);
|
||||
@@ -245,6 +253,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
augmentObject('query', storage, decoratedApi.query, fromEmpty);
|
||||
augmentObject('query', storageRx, decoratedApi.rx.query, fromEmpty);
|
||||
augmentObject('call', runtime, decoratedApi.call, fromEmpty);
|
||||
augmentObject('call', runtimeRx, decoratedApi.rx.call, fromEmpty);
|
||||
|
||||
decoratedApi.findCall = (callIndex: Uint8Array | string): CallFunction =>
|
||||
findCall(registry.registry, callIndex);
|
||||
@@ -256,6 +265,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decoratedApi.runtimeVersion = registry.runtimeVersion;
|
||||
|
||||
return {
|
||||
createdAt: blockHash,
|
||||
decoratedApi,
|
||||
decoratedMeta: registry.decoratedMeta
|
||||
};
|
||||
@@ -274,6 +284,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
this._errors = decoratedApi.errors;
|
||||
this._events = decoratedApi.events;
|
||||
this._query = decoratedApi.query;
|
||||
|
||||
this._rx.call = decoratedApi.rx.call;
|
||||
this._rx.query = decoratedApi.rx.query;
|
||||
|
||||
const tx = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
|
||||
@@ -297,7 +309,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
* backwards compatible endpoint for metadata injection, may be removed in the future (However, it is still useful for testing injection)
|
||||
*/
|
||||
public injectMetadata (metadata: Metadata, fromEmpty?: boolean, registry?: Registry): void {
|
||||
this._injectMetadata({ metadata, registry: registry || this.#registry, runtimeVersion: this.#registry.createType('RuntimeVersionPartial') }, fromEmpty);
|
||||
this._injectMetadata({ counter: 0, metadata, registry: registry || this.#registry, runtimeVersion: this.#registry.createType('RuntimeVersionPartial') }, fromEmpty);
|
||||
}
|
||||
|
||||
private _decorateFunctionMeta (input: MetaDecoration, output: MetaDecoration): MetaDecoration {
|
||||
@@ -379,7 +391,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
const filterKey = (k: string) => !allKeys.includes(k);
|
||||
const unknown = exposed.filter(filterKey);
|
||||
|
||||
if (unknown.length) {
|
||||
if (unknown.length && !this._options.noInitWarn) {
|
||||
l.warn(`RPC methods not decorated: ${unknown.join(', ')}`);
|
||||
}
|
||||
|
||||
@@ -488,12 +500,16 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
}
|
||||
|
||||
// pre-metadata decoration
|
||||
protected _decorateCalls<ApiType extends ApiTypes> ({ registry, runtimeVersion: { apis, specName } }: VersionedRegistry<ApiType>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType> {
|
||||
protected _decorateCalls<ApiType extends ApiTypes> ({ registry, runtimeVersion: { apis, specName, specVersion } }: VersionedRegistry<any>, decorateMethod: DecorateMethod<ApiType>, blockHash?: Uint8Array | string | null): QueryableCalls<ApiType> {
|
||||
const result = {} as QueryableCalls<ApiType>;
|
||||
const named: Record<string, Record<string, DefinitionCallNamed>> = {};
|
||||
const hashes: Record<HexString, boolean> = {};
|
||||
const sections = this._getRuntimeDefs(registry, specName, this._runtimeChain);
|
||||
const older: string[] = [];
|
||||
const implName = `${specName.toString()}/${specVersion.toString()}`;
|
||||
const hasLogged = this.#runtimeLog[implName] || false;
|
||||
|
||||
this.#runtimeLog[implName] = true;
|
||||
|
||||
for (let i = 0; i < sections.length; i++) {
|
||||
const [_section, secs] = sections[i];
|
||||
@@ -534,12 +550,14 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
.filter(([a]) => !hashes[a])
|
||||
.map(([a, v]) => `${this._runtimeMap[a] || a}/${v}`);
|
||||
|
||||
if (older.length) {
|
||||
l.warn(`Not decorating runtime apis without matching versions: ${older.join(', ')}`);
|
||||
}
|
||||
if (!this._options.noInitWarn && !hasLogged) {
|
||||
if (older.length) {
|
||||
l.warn(`${implName}: Not decorating runtime apis without matching versions: ${older.join(', ')}`);
|
||||
}
|
||||
|
||||
if (notFound.length) {
|
||||
l.warn(`Not decorating unknown runtime apis: ${notFound.join(', ')}`);
|
||||
if (notFound.length) {
|
||||
l.warn(`${implName}: Not decorating unknown runtime apis: ${notFound.join(', ')}`);
|
||||
}
|
||||
}
|
||||
|
||||
const stateCall = blockHash
|
||||
@@ -626,7 +644,9 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
|
||||
const lazySection = (section: 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);
|
||||
@@ -701,9 +721,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
decorated.keyPrefix = (...args: unknown[]): string =>
|
||||
u8aToHex(creator.keyPrefix(...args));
|
||||
|
||||
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: unknown[]): Observable<[Hash, Codec][]> =>
|
||||
this._decorateStorageRange(decorated, args, range));
|
||||
|
||||
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
|
||||
this._rpcCore.state.getStorageSize(getArgs(args)));
|
||||
|
||||
@@ -877,19 +894,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
||||
});
|
||||
}
|
||||
|
||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: unknown[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
||||
|
||||
return this._rpcCore.state
|
||||
.queryStorage<[Option<Raw>]>([decorated.key(...args)], ...range)
|
||||
.pipe(map((result: [Hash, [Option<Raw>]][]): [Hash, Codec][] =>
|
||||
result.map(([blockHash, [value]]) => [
|
||||
blockHash,
|
||||
this.createType<Codec>(outputType, value.isSome ? value.unwrap().toHex() : undefined)
|
||||
])
|
||||
));
|
||||
}
|
||||
|
||||
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
||||
private _retrieveMulti (keys: [StorageEntry, unknown[]][], blockHash?: Uint8Array): Observable<Codec[]> {
|
||||
if (!keys.length) {
|
||||
|
||||
@@ -194,8 +194,8 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> im
|
||||
/**
|
||||
* @description The underlying Rx API interface
|
||||
*/
|
||||
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'> {
|
||||
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'>);
|
||||
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query' | 'call'> {
|
||||
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query' | 'call'>);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
import { Decorate } from './Decorate';
|
||||
|
||||
const KEEPALIVE_INTERVAL = 10000;
|
||||
const WITH_VERSION_SHORTCUT = false;
|
||||
|
||||
const l = logger('api/init');
|
||||
|
||||
@@ -29,6 +30,8 @@ function textToString (t: Text): string {
|
||||
}
|
||||
|
||||
export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
#atLast: [string, ApiDecoration<ApiType>] | null = null;
|
||||
|
||||
#healthTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
#registries: VersionedRegistry<ApiType>[] = [];
|
||||
@@ -70,7 +73,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
this._rpcCore.provider.on('disconnected', () => this.#onProviderDisconnect());
|
||||
this._rpcCore.provider.on('error', (e: Error) => this.#onProviderError(e));
|
||||
this._rpcCore.provider.on('connected', () => this.#onProviderConnect());
|
||||
} else {
|
||||
} else if (!this._options.noInitWarn) {
|
||||
l.warn('Api will be available in a limited mode since the provider does not support subscriptions');
|
||||
}
|
||||
|
||||
@@ -113,11 +116,16 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
*/
|
||||
public async at (blockHash: Uint8Array | string, knownVersion?: RuntimeVersion): Promise<ApiDecoration<ApiType>> {
|
||||
const u8aHash = u8aToU8a(blockHash);
|
||||
const u8aHex = u8aToHex(u8aHash);
|
||||
const registry = await this.getBlockRegistry(u8aHash, knownVersion);
|
||||
|
||||
// always create a new decoration - since we are pointing to a specific hash, this
|
||||
// means that all queries needs to use that hash (not a previous one already existing)
|
||||
return this._createDecorated(registry, true, null, u8aHash).decoratedApi;
|
||||
if (!this.#atLast || this.#atLast[0] !== u8aHex) {
|
||||
// always create a new decoration - since we are pointing to a specific hash, this
|
||||
// means that all queries needs to use that hash (not a previous one already existing)
|
||||
this.#atLast = [u8aHex, this._createDecorated(registry, true, null, u8aHash).decoratedApi];
|
||||
}
|
||||
|
||||
return this.#atLast[1];
|
||||
}
|
||||
|
||||
private async _createBlockRegistry (blockHash: Uint8Array, header: HeaderPartial, version: RuntimeVersionPartial): Promise<VersionedRegistry<ApiType>> {
|
||||
@@ -129,7 +137,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
this._initRegistry(registry, this._runtimeChain as Text, version, metadata);
|
||||
|
||||
// add our new registry
|
||||
const result = { lastBlockHash: blockHash, metadata, registry, runtimeVersion: version };
|
||||
const result = { counter: 0, lastBlockHash: blockHash, metadata, registry, runtimeVersion: version };
|
||||
|
||||
this.#registries.push(result);
|
||||
|
||||
@@ -168,6 +176,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
);
|
||||
|
||||
if (existingViaVersion) {
|
||||
existingViaVersion.counter++;
|
||||
existingViaVersion.lastBlockHash = blockHash;
|
||||
|
||||
return existingViaVersion;
|
||||
@@ -198,8 +207,13 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
// get the runtime version, either on-chain or via an known upgrade history
|
||||
const [firstVersion, lastVersion] = getUpgradeVersion(this._genesisHash, header.number);
|
||||
const version = this.registry.createType('RuntimeVersionPartial',
|
||||
(firstVersion && (lastVersion || firstVersion.specVersion.eq(this._runtimeVersion.specVersion)))
|
||||
? { specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
|
||||
WITH_VERSION_SHORTCUT && (
|
||||
firstVersion && (
|
||||
lastVersion ||
|
||||
firstVersion.specVersion.eq(this._runtimeVersion.specVersion)
|
||||
)
|
||||
)
|
||||
? { apis: firstVersion.apis, specName: this._runtimeVersion.specName, specVersion: firstVersion.specVersion }
|
||||
: await firstValueFrom(this._rpcCore.state.getRuntimeVersion.raw(header.parentHash))
|
||||
);
|
||||
|
||||
@@ -337,7 +351,7 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
||||
|
||||
// setup the initial registry, when we have none
|
||||
if (!this.#registries.length) {
|
||||
this.#registries.push({ isDefault: true, metadata, registry: this.registry, runtimeVersion });
|
||||
this.#registries.push({ counter: 0, isDefault: true, metadata, registry: this.registry, runtimeVersion });
|
||||
}
|
||||
|
||||
// get unique types & validate
|
||||
|
||||
@@ -8,6 +8,7 @@ import type { Registry } from '@polkadot/types/types';
|
||||
import type { ApiDecoration, ApiTypes } from '../types';
|
||||
|
||||
export interface VersionedRegistry<ApiType extends ApiTypes> {
|
||||
counter: number;
|
||||
decoratedApi?: ApiDecoration<ApiType>;
|
||||
decoratedMeta?: DecoratedMeta;
|
||||
isDefault?: boolean;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import '@polkadot/rpc-augment';
|
||||
|
||||
export { Keyring } from '@polkadot/keyring';
|
||||
export { WsProvider, HttpProvider } from '@polkadot/rpc-provider';
|
||||
export { HttpProvider, ScProvider, WsProvider } from '@polkadot/rpc-provider';
|
||||
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { SubmittableResult } from './submittable';
|
||||
|
||||
@@ -125,7 +125,7 @@ async function query (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
console.log('query types:', bar, bal, bal2, override, oldBal, multia, multib);
|
||||
}
|
||||
|
||||
async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||
async function queryExtra (api: ApiPromise): Promise<void> {
|
||||
// events destructing
|
||||
await api.query.system.events((records): void => {
|
||||
records.forEach(({ event, phase }): void => {
|
||||
@@ -155,14 +155,6 @@ async function queryExtra (api: ApiPromise, pairs: TestKeyringMap): Promise<void
|
||||
await api.query.assets.account.entries(123);
|
||||
await api.query.assets.blah.keys();
|
||||
|
||||
// check range
|
||||
await api.query.balances.freeBalance.range<Balance>(['0x1234'], pairs.bob.address);
|
||||
|
||||
// check range types
|
||||
const entries = await api.query.system.events.range(['0x12345', '0x7890']);
|
||||
|
||||
console.log(`Received ${entries.length} entries, ${entries.map(([hash, events]) => `${hash.toHex()}: ${events.length} events`).join(', ')}`);
|
||||
|
||||
// is
|
||||
const key = {} as StorageKey;
|
||||
|
||||
@@ -313,7 +305,7 @@ async function main (): Promise<void> {
|
||||
errors(api),
|
||||
events(api),
|
||||
query(api, pairs),
|
||||
queryExtra(api, pairs),
|
||||
queryExtra(api),
|
||||
queryMulti(api, pairs),
|
||||
rpc(api),
|
||||
types(api),
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import type { Address, ApplyExtrinsicResult, Call, Extrinsic, ExtrinsicEra, ExtrinsicStatus, Hash, Header, Index, RuntimeDispatchInfo, SignerPayload } from '@polkadot/types/interfaces';
|
||||
import type { Callback, Codec, Constructor, IKeyringPair, ISubmittableResult, SignatureOptions } from '@polkadot/types/types';
|
||||
import type { Callback, Codec, Constructor, ISubmittableResult, SignatureOptions } from '@polkadot/types/types';
|
||||
import type { Registry } from '@polkadot/types-codec/types';
|
||||
import type { ApiInterfaceRx, ApiTypes, PromiseOrObs, SignerResult } from '../types';
|
||||
import type { AddressOrPair, SignerOptions, SubmittableDryRunResult, SubmittableExtrinsic, SubmittablePaymentResult, SubmittableResultResult, SubmittableResultSubscription } from './types';
|
||||
@@ -102,6 +102,10 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
|
||||
|
||||
// dry run an extrinsic
|
||||
public dryRun (account: AddressOrPair, optionsOrHash?: Partial<SignerOptions> | Uint8Array | string): SubmittableDryRunResult<ApiType> {
|
||||
if (!api.rpc.system || !api.rpc.system.dryRun) {
|
||||
throw new Error('The system.dryRun RPC call is not available in your environment');
|
||||
}
|
||||
|
||||
if (blockHash || isString(optionsOrHash) || isU8a(optionsOrHash)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return decorateMethod(
|
||||
@@ -120,11 +124,21 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
|
||||
|
||||
// calculate the payment info for this transaction (if signed and submitted)
|
||||
public paymentInfo (account: AddressOrPair, optionsOrHash?: Partial<SignerOptions> | Uint8Array | string): SubmittablePaymentResult<ApiType> {
|
||||
if (!api.call.transactionPaymentApi || !api.call.transactionPaymentApi.queryInfo) {
|
||||
throw new Error('The transactionPaymentApi.queryInfo runtime call is not available in your environment');
|
||||
}
|
||||
|
||||
if (blockHash || isString(optionsOrHash) || isU8a(optionsOrHash)) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
||||
return decorateMethod(
|
||||
(): Observable<RuntimeDispatchInfo> =>
|
||||
api.rpc.payment.queryInfo(this.toHex(), blockHash || optionsOrHash as string)
|
||||
api.callAt(blockHash || optionsOrHash as string).pipe(
|
||||
switchMap((callAt): Observable<RuntimeDispatchInfo> => {
|
||||
const u8a = this.toU8a();
|
||||
|
||||
return callAt.transactionPaymentApi.queryInfo(u8a, u8a.length);
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -140,12 +154,11 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
|
||||
// setup our options (same way as in signAndSend)
|
||||
const eraOptions = makeEraOptions(api, this.registry, allOptions, signingInfo);
|
||||
const signOptions = makeSignOptions(api, eraOptions, {});
|
||||
const u8a = this.isSigned
|
||||
? api.tx(this).signFake(address, signOptions).toU8a()
|
||||
: this.signFake(address, signOptions).toU8a();
|
||||
|
||||
return api.rpc.payment.queryInfo(
|
||||
this.isSigned
|
||||
? api.tx(this).signFake(address, signOptions).toHex()
|
||||
: this.signFake(address, signOptions).toHex()
|
||||
);
|
||||
return api.call.transactionPaymentApi.queryInfo(u8a, u8a.length);
|
||||
})
|
||||
)
|
||||
)();
|
||||
@@ -170,17 +183,7 @@ export function createClass <ApiType extends ApiTypes> ({ api, apiType, blockHas
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Sign a transaction, returning the this to allow chaining, i.e. .sign(...).send(). When options, e.g. nonce/blockHash are not specified, it will be inferred. To retrieve eg. nonce use `signAsync` (the preferred interface, this is provided for backwards compatibility)
|
||||
* @deprecated
|
||||
*/
|
||||
public override sign (account: IKeyringPair, partialOptions?: Partial<SignerOptions>): this {
|
||||
super.sign(account, makeSignOptions(api, optionsOrNonce(partialOptions), {}));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Signs a transaction, returning `this` to allow chaining. E.g.: `sign(...).send()`. Like `.signAndSend` this will retrieve the nonce and blockHash to send the tx with.
|
||||
* @description Signs a transaction, returning `this` to allow chaining. E.g.: `signAsync(...).send()`. Like `.signAndSend` this will retrieve the nonce and blockHash to send the tx with.
|
||||
*/
|
||||
public signAsync (account: AddressOrPair, partialOptions?: Partial<SignerOptions>): PromiseOrObs<ApiType, this> {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { Signer, SignerResult } from '@polkadot/api/types';
|
||||
import type { KeyringPair } from '@polkadot/keyring/types';
|
||||
import type { Registry, SignerPayloadJSON, SignerPayloadRaw } from '@polkadot/types/types';
|
||||
|
||||
import { hexToU8a, u8aToHex } from '@polkadot/util';
|
||||
import { hexToU8a, objectSpread, u8aToHex } from '@polkadot/util';
|
||||
|
||||
let id = 0;
|
||||
|
||||
@@ -31,10 +31,7 @@ export class SingleAccountSigner implements Signer {
|
||||
setTimeout((): void => {
|
||||
const signed = this.#registry.createType('ExtrinsicPayload', payload, { version: payload.version }).sign(this.#keyringPair);
|
||||
|
||||
resolve({
|
||||
id: ++id,
|
||||
...signed
|
||||
});
|
||||
resolve(objectSpread({ id: ++id }, signed));
|
||||
}, this.#signDelay);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ export interface ApiOptions extends RegisteredTypes {
|
||||
* if genesis hash and runtime spec version matches, then use metadata, else fetch it from chain
|
||||
*/
|
||||
metadata?: Record<string, HexString>;
|
||||
/**
|
||||
* @description Don't display any warnings on initialization (missing RPC methods & runtime calls)
|
||||
*/
|
||||
noInitWarn?: boolean;
|
||||
/**
|
||||
* @description Transport Provider from rpc-provider. If not specified, it will default to
|
||||
* connecting to a WsProvider connecting localhost with the default port, i.e. `ws://127.0.0.1:9944`
|
||||
@@ -104,6 +108,7 @@ export interface ApiDecoration<ApiType extends ApiTypes> {
|
||||
registry: Registry;
|
||||
runtimeVersion: RuntimeVersionPartial;
|
||||
rx: {
|
||||
call: QueryableCalls<'rxjs'>;
|
||||
query: QueryableStorage<'rxjs'>;
|
||||
};
|
||||
tx: (extrinsic: Call | Extrinsic | Uint8Array | string) => SubmittableExtrinsic<ApiType>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Copyright 2017-2022 @polkadot/api authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { lazyMethod, logger, objectClear } from '@polkadot/util';
|
||||
import { lazyMethods, logger, objectClear } from '@polkadot/util';
|
||||
|
||||
type Sections <T> = Record<string, Methods<T>>;
|
||||
|
||||
@@ -58,11 +58,13 @@ function findMethodExcludes <T> (src: Sections<T>, dst: Sections<T>): string[] {
|
||||
const srcMethods = Object.keys(src[section]);
|
||||
const dstMethods = Object.keys(dst[section]);
|
||||
|
||||
excludes.push(
|
||||
...dstMethods
|
||||
.filter((m) => !srcMethods.includes(m))
|
||||
.map((m) => `${section}.${m}`)
|
||||
);
|
||||
for (let d = 0; d < dstMethods.length; d++) {
|
||||
const method = dstMethods[d];
|
||||
|
||||
if (!srcMethods.includes(method)) {
|
||||
excludes.push(`${section}.${method}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return excludes;
|
||||
@@ -75,22 +77,6 @@ function extractMethods <T> (src: Sections<T>, dst: Sections<T>): StringsStrings
|
||||
];
|
||||
}
|
||||
|
||||
function lazySection <T> (src: Methods<T>, dst: Methods<T>): void {
|
||||
const creator = (m: string) => src[m];
|
||||
const methods = Object.keys(src);
|
||||
|
||||
for (let i = 0; i < methods.length; i++) {
|
||||
const method = methods[i];
|
||||
|
||||
// We use hasOwnproperty here to only check for the existence of the key,
|
||||
// instead of reading dst[section][method] which will evaluate when already
|
||||
// set as a lazy value previously
|
||||
if (!Object.prototype.hasOwnProperty.call(dst, method)) {
|
||||
lazyMethod(dst, method, creator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Takes a decorated api section (e.g. api.tx) and augment it with the details. It does not override what is
|
||||
* already available, but rather just adds new missing items into the result object.
|
||||
@@ -111,6 +97,7 @@ export function augmentObject <T> (prefix: string | null, src: Sections<T>, dst:
|
||||
|
||||
for (let i = 0; i < sections.length; i++) {
|
||||
const section = sections[i];
|
||||
const methods = src[section];
|
||||
|
||||
// We don't set here with a lazy interface, we decorate based
|
||||
// on the top-level structure (this bypasses adding lazy onto lazy)
|
||||
@@ -118,7 +105,7 @@ export function augmentObject <T> (prefix: string | null, src: Sections<T>, dst:
|
||||
dst[section] = {};
|
||||
}
|
||||
|
||||
lazySection(src[section], dst[section]);
|
||||
lazyMethods(dst[section], Object.keys(methods), (m: string) => methods[m]);
|
||||
}
|
||||
|
||||
return dst;
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/rpc-core": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/rpc-core": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -20,18 +20,18 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/rpc-augment": "8.13.1",
|
||||
"@polkadot/rpc-provider": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/rpc-augment": "9.2.2",
|
||||
"@polkadot/rpc-provider": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"rxjs": "^7.5.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/rpc-augment": "8.13.1"
|
||||
"@polkadot/keyring": "^10.1.4",
|
||||
"@polkadot/rpc-augment": "9.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -20,21 +20,21 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/keyring": "^10.0.2",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-support": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/x-fetch": "^10.0.2",
|
||||
"@polkadot/x-global": "^10.0.2",
|
||||
"@polkadot/x-ws": "^10.0.2",
|
||||
"@substrate/connect": "0.7.8",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/keyring": "^10.1.4",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-support": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"@polkadot/util-crypto": "^10.1.4",
|
||||
"@polkadot/x-fetch": "^10.1.4",
|
||||
"@polkadot/x-global": "^10.1.4",
|
||||
"@polkadot/x-ws": "^10.1.4",
|
||||
"@substrate/connect": "0.7.10",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"mock-socket": "^9.1.5",
|
||||
"nock": "^13.2.8"
|
||||
"nock": "^13.2.9"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,4 @@
|
||||
export { HttpProvider } from './http';
|
||||
export { packageInfo } from './packageInfo';
|
||||
export { WsProvider } from './ws';
|
||||
|
||||
// ESM-only, only export top-level when we have dual versions
|
||||
// export { ScProvider } from './substrate-connect';
|
||||
export { ScProvider } from './substrate-connect';
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, Pro
|
||||
import { Chain, createScClient, ScClient, WellKnownChain } from '@substrate/connect';
|
||||
import EventEmitter from 'eventemitter3';
|
||||
|
||||
import { isError } from '@polkadot/util';
|
||||
import { isError, objectSpread } from '@polkadot/util';
|
||||
|
||||
import { RpcCoder } from '../coder';
|
||||
import { healthChecker } from './Health';
|
||||
@@ -36,20 +36,19 @@ const wellKnownChains = new Set(Object.values(WellKnownChain));
|
||||
const scClients = new WeakMap<ScProvider, ScClient>();
|
||||
|
||||
export { WellKnownChain };
|
||||
|
||||
export class ScProvider implements ProviderInterface {
|
||||
readonly #coder: RpcCoder = new RpcCoder();
|
||||
readonly #spec: string | WellKnownChain;
|
||||
readonly #sharedSandbox?: ScProvider;
|
||||
readonly #subscriptions: Map<
|
||||
string,
|
||||
[ResponseCallback, { unsubscribeMethod: string; id: string | number }]
|
||||
> = new Map();
|
||||
|
||||
readonly #subscriptions: Map<string, [ResponseCallback, { unsubscribeMethod: string; id: string | number }]> = new Map();
|
||||
readonly #requests: Map<number, ResponseCallback> = new Map();
|
||||
readonly #eventemitter: EventEmitter = new EventEmitter();
|
||||
#chain: Promise<Chain> | null = null;
|
||||
#isChainReady = false;
|
||||
|
||||
static WellKnownChain = WellKnownChain;
|
||||
|
||||
public constructor (spec: string | WellKnownChain, sharedSandbox?: ScProvider) {
|
||||
this.#spec = spec;
|
||||
this.#sharedSandbox = sharedSandbox;
|
||||
@@ -215,15 +214,14 @@ export class ScProvider implements ProviderInterface {
|
||||
this.#eventemitter.emit(isReady ? 'connected' : 'disconnected');
|
||||
});
|
||||
|
||||
return {
|
||||
...chain,
|
||||
return objectSpread({}, chain, {
|
||||
remove: () => {
|
||||
hc.stop();
|
||||
chain.remove();
|
||||
cleanup();
|
||||
},
|
||||
sendJsonRpc: hc.sendJsonRpc.bind(hc)
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
try {
|
||||
@@ -252,10 +250,7 @@ export class ScProvider implements ProviderInterface {
|
||||
this.#eventemitter.emit('disconnected');
|
||||
}
|
||||
|
||||
public on (
|
||||
type: ProviderInterfaceEmitted,
|
||||
sub: ProviderInterfaceEmitCb
|
||||
): () => void {
|
||||
public on (type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void {
|
||||
// It's possible. Although, quite unlikely, that by the time that polkadot
|
||||
// subscribes to the `connected` event, the Provider is already connected.
|
||||
// In that case, we must emit to let the consumer know that we are connected.
|
||||
@@ -305,12 +300,7 @@ export class ScProvider implements ProviderInterface {
|
||||
}
|
||||
}
|
||||
|
||||
public async subscribe (
|
||||
type: string,
|
||||
method: string,
|
||||
params: any[],
|
||||
callback: ProviderInterfaceCallback
|
||||
): Promise<number | string> {
|
||||
public async subscribe (type: string, method: string, params: any[], callback: ProviderInterfaceCallback): Promise<number | string> {
|
||||
if (!subscriptionUnsubscriptionMethods.has(method)) {
|
||||
throw new Error(`Unsupported subscribe method: ${method}`);
|
||||
}
|
||||
@@ -337,11 +327,7 @@ export class ScProvider implements ProviderInterface {
|
||||
return id;
|
||||
}
|
||||
|
||||
public unsubscribe (
|
||||
type: string,
|
||||
method: string,
|
||||
id: number | string
|
||||
): Promise<boolean> {
|
||||
public unsubscribe (type: string, method: string, id: number | string): Promise<boolean> {
|
||||
if (!this.isConnected) {
|
||||
throw new Error('Provider is not connected');
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"polkadot-types-chain-info": "./scripts/polkadot-types-chain-info.cjs",
|
||||
@@ -30,27 +30,27 @@
|
||||
"polkadot-types-internal-metadata": "./scripts/polkadot-types-internal-metadata.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/register": "^7.18.6",
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/api": "8.13.1",
|
||||
"@polkadot/api-augment": "8.13.1",
|
||||
"@polkadot/rpc-augment": "8.13.1",
|
||||
"@polkadot/rpc-provider": "8.13.1",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-augment": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/types-create": "8.13.1",
|
||||
"@polkadot/types-support": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/util-crypto": "^10.0.2",
|
||||
"@polkadot/x-ws": "^10.0.2",
|
||||
"@babel/core": "^7.18.10",
|
||||
"@babel/register": "^7.18.9",
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/api": "9.2.2",
|
||||
"@polkadot/api-augment": "9.2.2",
|
||||
"@polkadot/rpc-augment": "9.2.2",
|
||||
"@polkadot/rpc-provider": "9.2.2",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-augment": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/types-create": "9.2.2",
|
||||
"@polkadot/types-support": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"@polkadot/util-crypto": "^10.1.4",
|
||||
"@polkadot/x-ws": "^10.1.4",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.5",
|
||||
"@types/yargs": "^17.0.10"
|
||||
"@types/yargs": "^17.0.11"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,12 +105,12 @@ function tsNull (registry: Registry, definitions: Record<string, ModuleTypes>, {
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err', def: TypeDef, imports: TypeImports): string {
|
||||
const { info, lookupName, type } = def;
|
||||
const asGetter = type === 'Null'
|
||||
? ''
|
||||
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, lookupName || (info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports, false) : type), imports);
|
||||
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
: createGetter(definitions, `as${getter}`, lookupName || (info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports, false) : type), imports);
|
||||
const isGetter = createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||
|
||||
switch (info) {
|
||||
case TypeDefInfo.Option:
|
||||
@@ -137,8 +137,6 @@ function tsResult (registry: Registry, definitions: Record<string, ModuleTypes>,
|
||||
const [okDef, errorDef] = (def.sub as TypeDef[]);
|
||||
const inner = [
|
||||
tsResultGetter(registry, definitions, def.name, 'Err', errorDef, imports),
|
||||
// @deprecated, use Err
|
||||
tsResultGetter(registry, definitions, def.name, 'Error', errorDef, imports),
|
||||
tsResultGetter(registry, definitions, def.name, 'Ok', okDef, imports)
|
||||
].join('');
|
||||
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-codec": "8.13.1",
|
||||
"@polkadot/util": "^10.0.2"
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-codec": "9.2.2",
|
||||
"@polkadot/util": "^10.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,4 +3,4 @@
|
||||
|
||||
// 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: '9.2.2' };
|
||||
|
||||
@@ -15,7 +15,7 @@ import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
|
||||
import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeGenesisConfiguration, BabeGenesisConfigurationV1, BabeWeight, Epoch, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, OpaqueKeyOwnershipProof, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
|
||||
import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
|
||||
import type { BeefyAuthoritySet, BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefyPayloadId, BeefySignedCommitment, MmrRootHash, ValidatorSet, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
|
||||
import type { BenchmarkConfig, BenchmarkList, BenchmarkMetadata, BenchmarkParameter } from '@polkadot/types/interfaces/benchmark';
|
||||
import type { BenchmarkBatch, BenchmarkConfig, BenchmarkList, BenchmarkMetadata, BenchmarkParameter, BenchmarkResult } from '@polkadot/types/interfaces/benchmark';
|
||||
import type { CheckInherentsResult, InherentData, InherentIdentifier } from '@polkadot/types/interfaces/blockbuilder';
|
||||
import type { BridgeMessageId, BridgedBlockHash, BridgedBlockNumber, BridgedHeader, CallOrigin, ChainId, DeliveredMessages, DispatchFeePayment, InboundLaneData, InboundRelayer, InitializationData, LaneId, MessageData, MessageKey, MessageNonce, MessagesDeliveryProofOf, MessagesProofOf, OperatingMode, OutboundLaneData, OutboundMessageFee, OutboundPayload, Parameter, RelayerId, UnrewardedRelayer, UnrewardedRelayersState } from '@polkadot/types/interfaces/bridges';
|
||||
import type { BlockHash } from '@polkadot/types/interfaces/chain';
|
||||
@@ -155,10 +155,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
BeefyPayload: BeefyPayload;
|
||||
BeefyPayloadId: BeefyPayloadId;
|
||||
BeefySignedCommitment: BeefySignedCommitment;
|
||||
BenchmarkBatch: BenchmarkBatch;
|
||||
BenchmarkConfig: BenchmarkConfig;
|
||||
BenchmarkList: BenchmarkList;
|
||||
BenchmarkMetadata: BenchmarkMetadata;
|
||||
BenchmarkParameter: BenchmarkParameter;
|
||||
BenchmarkResult: BenchmarkResult;
|
||||
Bid: Bid;
|
||||
Bidder: Bidder;
|
||||
BidKind: BidKind;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -20,17 +20,17 @@
|
||||
"./detectPackage.cjs"
|
||||
],
|
||||
"type": "module",
|
||||
"version": "8.13.1",
|
||||
"version": "9.2.2",
|
||||
"main": "index.js",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.18.6",
|
||||
"@polkadot/util": "^10.0.2",
|
||||
"@polkadot/x-bigint": "^10.0.2"
|
||||
"@babel/runtime": "^7.18.9",
|
||||
"@polkadot/util": "^10.1.4",
|
||||
"@polkadot/x-bigint": "^10.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/types": "8.13.1",
|
||||
"@polkadot/types-augment": "8.13.1",
|
||||
"@polkadot/types-support": "8.13.1",
|
||||
"@polkadot/util-crypto": "^10.0.2"
|
||||
"@polkadot/types": "9.2.2",
|
||||
"@polkadot/types-augment": "9.2.2",
|
||||
"@polkadot/types-support": "9.2.2",
|
||||
"@polkadot/util-crypto": "^10.1.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,19 @@ export abstract class AbstractArray<T extends Codec> extends Array<T> implements
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -83,6 +83,13 @@ export abstract class AbstractBase<T extends Codec> implements Codec {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -207,6 +207,15 @@ export abstract class AbstractInt extends BN implements INumber {
|
||||
: 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
|
||||
*/
|
||||
|
||||
@@ -171,6 +171,13 @@ export class Compact<T extends INumber> implements ICompact<T> {
|
||||
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
|
||||
*/
|
||||
|
||||
@@ -72,6 +72,10 @@ export class DoNotConstruct implements Codec {
|
||||
throw this.#neverError;
|
||||
}
|
||||
|
||||
toPrimitive (): AnyJson {
|
||||
throw this.#neverError;
|
||||
}
|
||||
|
||||
toRawType (): string {
|
||||
throw this.#neverError;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user