Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ecd00a4e6 | ||
|
|
6239818c26 | ||
|
|
6af22f41c7 | ||
|
|
77c3a701d0 | ||
|
|
46b17a466c | ||
|
|
e592c6c878 | ||
|
|
ef37586dfc | ||
|
|
5856ce24cc | ||
|
|
8b79056bf9 | ||
|
|
70e0f19ade | ||
|
|
cf1e242c17 | ||
|
|
68856e9692 | ||
|
|
e0626c3dad | ||
|
|
277ea92fda | ||
|
|
aec6694028 | ||
|
|
533abb76f7 | ||
|
|
7660bab86b | ||
|
|
f7c1b6e81b | ||
|
|
b6e9b29570 | ||
|
|
519d9c8fa9 | ||
|
|
ad905db53b | ||
|
|
0a0aa742b4 | ||
|
|
dfbb06a4d6 | ||
|
|
82e71fd51e | ||
|
|
a8b88af97a | ||
|
|
eee36537de | ||
|
|
20a75eafb6 | ||
|
|
00d3a1174b | ||
|
|
e293c7c1cf | ||
|
|
3c8cd499c4 | ||
|
|
cb3816df78 | ||
|
|
fcfcbb2d97 | ||
|
|
321b80ed63 | ||
|
|
73eaa9fe17 | ||
|
|
4d8910f3da | ||
|
|
e6806ed7f9 | ||
|
|
218abf9568 | ||
|
|
a1df864681 | ||
|
|
45640edcff | ||
|
|
53655019b5 | ||
|
|
a1f8bedb6d | ||
|
|
9d1af1eaeb | ||
|
|
38bfd26511 | ||
|
|
1beaf9f208 | ||
|
|
29c29978dd | ||
|
|
a8d1dd0637 | ||
|
|
74571dcd26 | ||
|
|
54b4c2620a | ||
|
|
da05828e74 | ||
|
|
fa935156e1 | ||
|
|
19510c1ede | ||
|
|
97b5c699b1 | ||
|
|
d2befda86e | ||
|
|
740348b48f | ||
|
|
9e2a5cf532 | ||
|
|
6df466d9ea | ||
|
|
e2a2ac2842 | ||
|
|
5adc846e45 | ||
|
|
75aa310837 | ||
|
|
ce0523eb1c | ||
|
|
eb0370bb66 | ||
|
|
5eb491dc67 | ||
|
|
b50294ab0f | ||
|
|
e1cb62d2d2 | ||
|
|
8ed0ef2295 | ||
|
|
956e173323 | ||
|
|
b8a37ba438 | ||
|
|
e7669c2b00 | ||
|
|
6c309a503d | ||
|
|
3cf67c975a | ||
|
|
077914364c | ||
|
|
56e4cbdb27 | ||
|
|
60bfdae734 | ||
|
|
1cf4d6b9b8 | ||
|
|
40cd9ff51f | ||
|
|
c7e6e40030 | ||
|
|
97d0bcbfd4 | ||
|
|
6ca84425d1 | ||
|
|
8481647d2c | ||
|
|
658dda66a4 | ||
|
|
87f18efe72 | ||
|
|
bcdfcce89c | ||
|
|
9418f1de56 | ||
|
|
37c8b8e592 | ||
|
|
4f8db79a40 | ||
|
|
54cf086a89 | ||
|
|
37ddcaa32d | ||
|
|
6a2baf8352 | ||
|
|
ecca91dffd | ||
|
|
42576d74ac | ||
|
|
26a6f20dbf | ||
|
|
c3ee8393b2 | ||
|
|
b6f0b9f262 | ||
|
|
991dc48020 | ||
|
|
e4a82f9a1d | ||
|
|
c8b6012553 | ||
|
|
d0fe862605 | ||
|
|
61a0198695 | ||
|
|
345a97dc9f | ||
|
|
f821ab8ecd | ||
|
|
f9e2bf332d | ||
|
|
ad69430980 | ||
|
|
d25743016c | ||
|
|
ee0a46adc4 | ||
|
|
f516abfc3f | ||
|
|
1a96ca5c0e | ||
|
|
8c73cd7d6e | ||
|
|
36232c0289 | ||
|
|
50d4e0397f | ||
|
|
539a8c4cb5 | ||
|
|
b849976b3b | ||
|
|
2395401a2b | ||
|
|
0e1bbd5cac | ||
|
|
e9489d41cb | ||
|
|
63483b9db7 | ||
|
|
b26c7f9f0a | ||
|
|
a165c9375c | ||
|
|
28631f7180 | ||
|
|
6489251b47 | ||
|
|
66884febea | ||
|
|
8058dc350f | ||
|
|
63096cc238 | ||
|
|
05600c0cd0 | ||
|
|
eed5e23e65 | ||
|
|
cdf5b15673 | ||
|
|
1922676bd7 | ||
|
|
b6c427e985 | ||
|
|
0327aedf8e | ||
|
|
d7035cebb1 | ||
|
|
8b492021af | ||
|
|
6a01fc7c8c | ||
|
|
bbc30ec9dc |
+3
-2
@@ -1,5 +1,6 @@
|
||||
24
|
||||
25
|
||||
1.4.2
|
||||
1.6.2
|
||||
1.11.2
|
||||
1.12.21.17.2
|
||||
1.12.2
|
||||
1.17.2
|
||||
|
||||
+86
File diff suppressed because one or more lines are too long
Vendored
-56
File diff suppressed because one or more lines are too long
+1
-1
@@ -8,4 +8,4 @@ plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-rc.js
|
||||
yarnPath: .yarn/releases/yarn-2.1.1.js
|
||||
|
||||
+87
-3
@@ -1,8 +1,92 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.22.1 Jun 29, 2020
|
||||
## 1.30.1 Aug 24, 2020
|
||||
|
||||
- **Important** Substrate changed the tip structure, only older chains supply `OpenTip: 'OpenTipTo225'` if using tips
|
||||
Upgrade priority: Low, unless using the `proposeParachain` module.
|
||||
|
||||
- Adjust balance retrievals to check for `system.account` for new/old determination
|
||||
- Add types for the new `proposeParachain` module (as per Rococo)
|
||||
- Adjust `Address` <-> `LookupSource` definitions (no external impact, both in existence)
|
||||
- Add Ethereum-compatible `Ethereum{AccountId, LookupSource}` types, underlying `H160`
|
||||
- Allow for configurable hashers via `registry.setHasher(...)` (defaults to `blake2AsU8a`)
|
||||
- `@polkadot/util` 3.3
|
||||
|
||||
## 1.29.1 Aug 17, 2020
|
||||
|
||||
Upgrade priority: Low, unless on bleeding-edge chain with new compact `CompactAssignments`.
|
||||
|
||||
- **Important** The Substrate `CompactAssignments` type has changed for better space utilization. On older chains, supply `CompactAssignments: 'CompactAssignmentsTo257'`
|
||||
- Clean tx cookbook param expansion (Thanks to https://github.com/swswsw)
|
||||
- Add additional `Fixed{I,U}{64,128}` and `{I,U}32F32` types
|
||||
- Add `desiredRunnersUp` to council derives
|
||||
- Cleanup indices/AccountId combination derive lookups
|
||||
- `@polkadot/util` 3.2
|
||||
|
||||
## 1.28.1 Aug 10, 2020
|
||||
|
||||
Upgrade priority: Low, unless using Centrifuge or parachains
|
||||
|
||||
- Update Centrifuge types to latest (Thanks to https://github.com/mikiquantum)
|
||||
- Add cookbook entry for viewing block extrinsics
|
||||
- Support types for time-delay proxies
|
||||
- Update types for parachains
|
||||
- `@polkadot/util` 3.1
|
||||
- `@polkadot/wasm-crypto` 1.3
|
||||
|
||||
## 1.27.1 Aug 3, 2020
|
||||
|
||||
Upgrade priority: Low, unless using the Rococo chain
|
||||
|
||||
- Remove outdated example poc-3 RPC reference (Thanks to https://github.com/swswsw)
|
||||
- Raw/Bytes `toHuman` detects ASCII sequence for text output
|
||||
- Add know types for the Rococo chain
|
||||
|
||||
## 1.26.1 Jul 27, 2020
|
||||
|
||||
Upgrade priority: Low
|
||||
|
||||
- Update docs for the new `system.accountNextIndex` (Thanks to https://github.com/shawntabrizi)
|
||||
- Update contracts call parameter typing (Thanks to https://github.com/kwingram25)
|
||||
- Adjust votingBalance to only return `freeBalance` (only council voting is free + reserved)
|
||||
- Additional checks for referenced Vec sub-type deconstruction in typegen
|
||||
- Allow for API `typesBundle` option to inject a group of chain versions types
|
||||
- Update metadata static tests for latest Substrate
|
||||
- `@polkadot/util` 3.0
|
||||
|
||||
## 1.25.1 Jul 20, 2020
|
||||
|
||||
Upgrade priority: Medium, especially if using contracts.
|
||||
|
||||
- **Important** Contract RPC result updated on Substrate, on older chains supply `ContractExecResult: 'ContractExecResultTo255'`
|
||||
- Support for custom HTTP headers in providers (Thanks to https://github.com/brad-larson)
|
||||
- Update known types for Centrifuge (Thanks to https://github.com/philipstanislaus)
|
||||
- Update API users with Registrar #1 (Thanks to https://github.com/chevdor)
|
||||
- Raw/Bytes `toHuman()` displays utf-8 as available
|
||||
- Add fallback for `setImmediate` when not polyfilled
|
||||
- Update `NetworkState` reputation type for `system_networkState` RPC
|
||||
- Update session progress calcs for Aura (cater for negative)
|
||||
- Fix class prototype for (basically-deprecated) Linkage type
|
||||
- Add Polkadot types for `purchase` pallet
|
||||
|
||||
## 1.24.1 Jul 13, 2020
|
||||
|
||||
- Added `isAscii` & `isUtf8` getters to `Bytes` & `Raw` types
|
||||
- Added `toUtf8()` helper to `Bytes` & `Raw` types
|
||||
- `@polkadot/util` 2.18
|
||||
|
||||
## 1.23.1 Jul 6, 2020
|
||||
|
||||
- Small README typo fix (Thanks to https://github.com/woss)
|
||||
- Add latest Substrate master types
|
||||
- Adjust `<Codec>.toRawType()` to use registry name as available
|
||||
- Update `ProxyType` for Kusama, Polkadot & Westend with `IdentityJudgement`
|
||||
- Validate number format (signed/unsigned) for number types
|
||||
- Remove core codec dependencies on Base class (with proper TS encapsulation)
|
||||
- `@polkadot/util` 2.17
|
||||
|
||||
## 1.22.1 Jun 30, 2020
|
||||
|
||||
- **Important** Substrate changed the treasury tip structure, on older chains supply `OpenTip: 'OpenTipTo225'`
|
||||
- Allow for `[u8; 33]` in U8aFixed (Thanks to https://github.com/akru)
|
||||
- Improve derive accountId -> accountIndex lookups (optimize entries queries)
|
||||
- Vesting balance calculations via `derive.balances.all` has been updated for locks
|
||||
@@ -15,7 +99,7 @@
|
||||
- Add support for `CheckMortality` signed extension (old `CheckEra` is now an alias)
|
||||
- Promise API will default to using `getStorage` on non-subscription calls, reducing RPC overhead
|
||||
- Optimize derive BN allocations, using in-place operators as applicable
|
||||
- Add new substrate types for Babe EquivocationProof
|
||||
- Add new Substrate types for Babe `EquivocationProof`
|
||||
- Adjust `Releases` enum to use a shared instance
|
||||
|
||||
## 1.20.1 Jun 22, 2020
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
# @polkadot/api
|
||||
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/Subtrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
|
||||
This library provides a clean wrapper around all the methods exposed by a Polkadot/Substrate network client and defines all the types exposed by a node. For complete documentation around the classes, interfaces and their use, visit the [documentation portal](https://polkadot.js.org/api/).
|
||||
|
||||
If you are an existing user, please be sure to track the [CHANGELOG](CHANGELOG.md) and [UPGRADING](UPGRADING.md) guides when changing versions.
|
||||
|
||||
|
||||
@@ -42,3 +42,20 @@ const header = await api.derive.chain.getHeader();
|
||||
|
||||
console.log(`#${header.number}: ${header.author}`);
|
||||
```
|
||||
|
||||
## How do I view block extrinsic information?
|
||||
|
||||
The transactions are included in a signed block as part of the extrinsics - some of these will be unsigned and generated by the block author and some of these may be submitted from external sources and be signed. (Some palettes do use unsigned transactions, so signed/unsigned is not an indication of origin). To retrieve the block and display the transaction information, we can do the following -
|
||||
|
||||
```js
|
||||
// no blockHash is specified, so we retrieve the latest
|
||||
const signedBlock = await this.api.rpc.chain.getBlock();
|
||||
|
||||
// the information for each of the contained extrinsics
|
||||
signedBlock.block.extrinsics.forEach((ex, index) => {
|
||||
// the extrinsics are decoded by the API
|
||||
console.log(index, ex.toHuman());
|
||||
});
|
||||
```
|
||||
|
||||
In the above `.toHuman()` is used to format into a human-readable representation. You can inspect/extract specific fields from the decoded extrinsic as required, for instance `ex.method.section` would return the pallete that executed this transaction.
|
||||
|
||||
+6
-6
@@ -16,9 +16,9 @@ const info = await api.tx.balances
|
||||
|
||||
// log relevant info, partialFee is Balance, estimated for current
|
||||
console.log(`
|
||||
class=${class.toString()},
|
||||
weight=${weight.toString()},
|
||||
partialFee=${partialFee.toHuman()}
|
||||
class=${info.class.toString()},
|
||||
weight=${info.weight.toString()},
|
||||
partialFee=${info.partialFee.toHuman()}
|
||||
`);
|
||||
```
|
||||
|
||||
@@ -97,12 +97,12 @@ api.tx.utility
|
||||
|
||||
## How do I take the pending tx pool into account in my nonce?
|
||||
|
||||
The `system.account` query will always contain the current state, i.e. it will reflect the nonce for the last known block. As such when sending multiple transactions in quick succession (see batching above), there may be transactions in the pool that has the same nonce that `signAndSend` would apply - this call doesn't do any magic, it simply reads the state for the nonce. Since we can specify options to the `signandSend` operation, we can override the nonce, either by manually incrementing it o querying it via `nextNonce`.
|
||||
The `system.account` query will always contain the current state, i.e. it will reflect the nonce for the last known block. As such when sending multiple transactions in quick succession (see batching above), there may be transactions in the pool that has the same nonce that `signAndSend` would apply - this call doesn't do any magic, it simply reads the state for the nonce. Since we can specify options to the `signAndSend` operation, we can override the nonce, either by manually incrementing it or querying it via `rpc.system.accountNextIndex`.
|
||||
|
||||
```js
|
||||
for (let i = 0; i < 10; i++) {
|
||||
// retrieve the nextNonce, taking txs in the pool into account
|
||||
const nonce = await api.rpc.account.nextNonce(sender);
|
||||
// retrieve sender's next index/nonce, taking txs in the pool into account
|
||||
const nonce = await api.rpc.system.accountNextIndex(sender);
|
||||
|
||||
// send, just retrieving the hash, not waiting on status
|
||||
const txhash = await api.tx.balances
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||
|
||||
...
|
||||
// Construct
|
||||
const wsProvider = new WsProvider('wss://poc-3.polkadot.io');
|
||||
const wsProvider = new WsProvider('wss://rpc.polkadot.io');
|
||||
const api = await ApiPromise.create({ provider: wsProvider });
|
||||
|
||||
// Do something
|
||||
|
||||
+1
-1
@@ -9,5 +9,5 @@
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "1.22.1"
|
||||
"version": "1.30.1"
|
||||
}
|
||||
|
||||
+8
-8
@@ -24,15 +24,15 @@
|
||||
"test:watch": "polkadot-dev-run-test --watch"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.10.3",
|
||||
"@babel/register": "^7.10.3",
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/dev": "^0.55.14",
|
||||
"@polkadot/ts": "^0.3.26",
|
||||
"@babel/core": "^7.11.4",
|
||||
"@babel/register": "^7.10.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/dev": "^0.55.39",
|
||||
"@polkadot/ts": "^0.3.39",
|
||||
"@polkadot/typegen": "workspace:packages/typegen",
|
||||
"@types/jest": "^26.0.3",
|
||||
"@vuepress/plugin-search": "^1.5.2",
|
||||
"@types/jest": "^26.0.10",
|
||||
"@vuepress/plugin-search": "^1.5.4",
|
||||
"copyfiles": "^2.3.0"
|
||||
},
|
||||
"version": "1.22.1"
|
||||
"version": "1.30.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-contract",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,12 +26,12 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/api": "1.22.1",
|
||||
"@polkadot/rpc-core": "1.22.1",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"rxjs": "^6.5.5"
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.30.1",
|
||||
"@polkadot/rpc-core": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"rxjs": "^6.6.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { ApiTypes, DecorateMethod, ObsInnerType } from '@polkadot/api/types';
|
||||
import { AccountId, Address, ContractExecResult } from '@polkadot/types/interfaces';
|
||||
import { Codec, IKeyringPair } from '@polkadot/types/types';
|
||||
import { Codec, CodecArg, IKeyringPair } from '@polkadot/types/types';
|
||||
import { ApiObject, ContractABIMessage, ContractABIPre, ContractCallOutcome } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
@@ -38,9 +38,9 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
this.address = this.registry.createType('Address', address);
|
||||
}
|
||||
|
||||
public call (as: 'rpc', message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, 'rpc'>;
|
||||
public call (as: 'tx', message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, 'tx'>;
|
||||
public call<CallType extends ContractCallTypes> (as: CallType, message: string, value: BN | number, gasLimit: BN | number, ...params: any[]): ContractCall<ApiType, CallType> {
|
||||
public call (as: 'rpc', message: string, value: BN | number, gasLimit: BN | number, ...params: CodecArg[]): ContractCall<ApiType, 'rpc'>;
|
||||
public call (as: 'tx', message: string, value: BN | number, gasLimit: BN | number, ...params: CodecArg[]): ContractCall<ApiType, 'tx'>;
|
||||
public call<CallType extends ContractCallTypes> (as: CallType, message: string, value: BN | number, gasLimit: BN | number, ...params: CodecArg[]): ContractCall<ApiType, CallType> {
|
||||
const { def, fn } = this.getMessage(message);
|
||||
|
||||
return {
|
||||
@@ -67,7 +67,7 @@ export default class Contract<ApiType extends ApiTypes> extends BaseWithTxAndRpc
|
||||
};
|
||||
}
|
||||
|
||||
private _createOutcome (result: ContractExecResult, origin: AccountId, message: ContractABIMessage, params: any[]): ContractCallOutcome {
|
||||
private _createOutcome (result: ContractExecResult, origin: AccountId, message: ContractABIMessage, params: CodecArg[]): ContractCallOutcome {
|
||||
let output: Codec | null = null;
|
||||
|
||||
if (result.isSuccess) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api-derive",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -27,18 +27,18 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/api": "1.22.1",
|
||||
"@polkadot/rpc-core": "1.22.1",
|
||||
"@polkadot/rpc-provider": "1.22.1",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@polkadot/util-crypto": "^2.16.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.30.1",
|
||||
"@polkadot/rpc-core": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.5"
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.16.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ function retrieve (api: ApiInterfaceRx, address: Address | AccountId | AccountIn
|
||||
|
||||
const accountIndex = api.registry.createType('AccountIndex', decoded);
|
||||
|
||||
return api.derive.accounts.indexToId(accountIndex).pipe(
|
||||
return api.derive.accounts.indexToId(accountIndex.toString()).pipe(
|
||||
map((accountId): AccountIdAndIndex => [accountId, accountIndex])
|
||||
);
|
||||
} catch (error) {
|
||||
|
||||
@@ -23,7 +23,7 @@ function calcBalances (api: ApiInterfaceRx, [accountId, [freeBalance, reservedBa
|
||||
frozenFee,
|
||||
frozenMisc,
|
||||
reservedBalance,
|
||||
votingBalance: api.registry.createType('Balance', freeBalance.add(reservedBalance))
|
||||
votingBalance: api.registry.createType('Balance', freeBalance.toBn())
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ export function all (api: ApiInterfaceRx): (address: AccountIndex | AccountId |
|
||||
? combineLatest([
|
||||
of(account),
|
||||
api.derive.chain.bestNumber(),
|
||||
isFunction(api.query.balances.account)
|
||||
isFunction(api.query.system.account) || isFunction(api.query.balances.account)
|
||||
? queryCurrent(api, account.accountId)
|
||||
: queryOld(api, account.accountId)
|
||||
])
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
|
||||
import { AccountId, Balance, BlockNumber } from '@polkadot/types/interfaces';
|
||||
import { ITuple } from '@polkadot/types/types';
|
||||
import { DeriveElectionsInfo } from './types';
|
||||
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ApiInterfaceRx } from '@polkadot/api/types';
|
||||
import { Vec, u32 } from '@polkadot/types';
|
||||
|
||||
import { DeriveElectionsInfo } from '../types';
|
||||
import { memo } from '../util';
|
||||
|
||||
function sortAccounts ([, balanceA]: ITuple<[AccountId, Balance]>, [, balanceB]: ITuple<[AccountId, Balance]>): number {
|
||||
@@ -30,6 +30,7 @@ function queryElections (api: ApiInterfaceRx): Observable<DeriveElectionsInfo> {
|
||||
candidacyBond: api.consts[section].candidacyBond as Balance,
|
||||
candidateCount: api.registry.createType('u32', candidates.length),
|
||||
candidates,
|
||||
desiredRunnersUp: api.consts[section].desiredRunnersUp as u32,
|
||||
desiredSeats: api.consts[section].desiredMembers as u32,
|
||||
members: members.length
|
||||
? members.sort(sortAccounts)
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2017-2020 @polkadot/api-derive authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AccountId, Balance, BlockNumber, SetIndex, VoteIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import { u32 } from '@polkadot/types';
|
||||
|
||||
export interface DeriveElectionsInfo {
|
||||
candidates: AccountId[];
|
||||
candidateCount: u32;
|
||||
candidacyBond?: Balance;
|
||||
desiredRunnersUp: u32;
|
||||
desiredSeats: u32;
|
||||
members: [AccountId, Balance][];
|
||||
nextVoterSet?: SetIndex;
|
||||
runnersUp: [AccountId, Balance][];
|
||||
termDuration: BlockNumber;
|
||||
voteCount?: VoteIndex;
|
||||
voterCount?: SetIndex;
|
||||
votingBond?: Balance;
|
||||
}
|
||||
@@ -30,14 +30,11 @@ function createDerive (api: ApiInterfaceRx, info: DeriveSessionInfo, [currentSlo
|
||||
|
||||
function queryAura (api: ApiInterfaceRx): Observable<DeriveSessionProgress> {
|
||||
return api.derive.session.info().pipe(
|
||||
map((info): DeriveSessionProgress =>
|
||||
createDerive(api, info, [
|
||||
api.registry.createType('u64', 1),
|
||||
api.registry.createType('u64', 1),
|
||||
api.registry.createType('u64', 1),
|
||||
api.registry.createType('SessionIndex', 1)
|
||||
])
|
||||
)
|
||||
map((info): DeriveSessionProgress => ({
|
||||
...info,
|
||||
eraProgress: api.registry.createType('BlockNumber'),
|
||||
sessionProgress: api.registry.createType('BlockNumber')
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VoteIndex, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
import { AccountId, Balance, BalanceLock, BalanceLockTo212, BalanceOf, Bid, BidKind, BlockNumber, Hash, Index, Proposal, ProposalIndex, SetIndex, SocietyVote, StrikeCount, TreasuryProposal, Votes, VouchingStatus } from '@polkadot/types/interfaces';
|
||||
|
||||
import { u32 } from '@polkadot/types';
|
||||
|
||||
export * from './accounts/types';
|
||||
export * from './council/types';
|
||||
export * from './democracy/types';
|
||||
export * from './elections/types';
|
||||
export * from './parachains/types';
|
||||
export * from './session/types';
|
||||
export * from './staking/types';
|
||||
@@ -59,20 +60,6 @@ export interface DeriveCollectiveProposal {
|
||||
|
||||
export type DeriveCollectiveProposals = DeriveCollectiveProposal[];
|
||||
|
||||
export interface DeriveElectionsInfo {
|
||||
candidates: AccountId[];
|
||||
candidateCount: u32;
|
||||
candidacyBond?: Balance;
|
||||
desiredSeats: u32;
|
||||
members: [AccountId, Balance][];
|
||||
nextVoterSet?: SetIndex;
|
||||
runnersUp: [AccountId, Balance][];
|
||||
termDuration: BlockNumber;
|
||||
voteCount?: VoteIndex;
|
||||
voterCount?: SetIndex;
|
||||
votingBond?: Balance;
|
||||
}
|
||||
|
||||
export interface DeriveFees {
|
||||
creationFee: Balance;
|
||||
existentialDeposit: Balance;
|
||||
|
||||
@@ -97,7 +97,7 @@ Some of the users of the API (let us know if you are missing from the list), inc
|
||||
- [Polkawallet.io](https://polkawallet.io) and [Polkawallet (Github)](https://github.com/polkawallet-io/polkawallet-RN/) A mobile wallet for the Polkadot network to manage funds and make transactions, available on both Androind and iOS
|
||||
- [PolkaStats.io](https://polkastats.io), [PolkaStats frontend GitHub repository](https://github.com/Colm3na/polkastats-v2) and [PolkaStats backend GitHub repository](https://github.com/Colm3na/polkastats-backend-v2) Polkadot network statistics (currently Kusama and Alexander). Shows network information and staking details from validators and intentions.
|
||||
- [Polkadot API Server (GitHub)](https://github.com/SimplyVC/polkadot_api_server) A lightweight server for querying Polkadot nodes from any language, built primarily as a backend for [PANIC for Polkadot (GitHub)](https://github.com/SimplyVC/panic_polkadot/), a validator monitoring and alerting tool.
|
||||
|
||||
- [Identity Registrar #1 from Chevdor on Westend, Kusama and Polkadot](https://www.chevdor.com/tags/registrar/)
|
||||
## Classes
|
||||
|
||||
[Classes](SUMMARY.md)
|
||||
|
||||
+15
-15
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/api",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,21 +26,21 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/api-derive": "1.22.1",
|
||||
"@polkadot/keyring": "^2.16.1",
|
||||
"@polkadot/metadata": "1.22.1",
|
||||
"@polkadot/rpc-core": "1.22.1",
|
||||
"@polkadot/rpc-provider": "1.22.1",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/types-known": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@polkadot/util-crypto": "^2.16.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"eventemitter3": "^4.0.4",
|
||||
"rxjs": "^6.5.5"
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api-derive": "1.30.1",
|
||||
"@polkadot/keyring": "^3.3.1",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/rpc-core": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/types-known": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.5",
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.16.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ import { SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfa
|
||||
import { RegistrarInfo, Registration } from '@polkadot/types/interfaces/identity';
|
||||
import { AuthIndex } from '@polkadot/types/interfaces/imOnline';
|
||||
import { DeferredOffenceOf, Kind, OffenceDetails, OpaqueTimeSlot, ReportIdOf } from '@polkadot/types/interfaces/offences';
|
||||
import { ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, Perbill, ProxyType, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import { AccountId, AccountIndex, Balance, BalanceOf, BlockNumber, ExtrinsicsWeight, Hash, KeyTypeId, Moment, OpaqueCall, Perbill, Releases, ValidatorId } from '@polkadot/types/interfaces/runtime';
|
||||
import { Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import { Keys, SessionIndex } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
@@ -392,7 +393,7 @@ declare module '@polkadot/api/types/storage' {
|
||||
};
|
||||
multisig: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
calls: AugmentedQuery<ApiType, (arg: U8aFixed | string | Uint8Array) => Observable<Option<ITuple<[Bytes, AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
calls: AugmentedQuery<ApiType, (arg: U8aFixed | string | Uint8Array) => Observable<Option<ITuple<[OpaqueCall, AccountId, BalanceOf]>>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* The set of open multisig operations.
|
||||
**/
|
||||
@@ -470,6 +471,12 @@ declare module '@polkadot/api/types/storage' {
|
||||
* Lookup from identity to the block number and index of the task.
|
||||
**/
|
||||
lookup: AugmentedQuery<ApiType, (arg: Bytes | string | Uint8Array) => Observable<Option<TaskAddress>>> & QueryableStorageEntry<ApiType>;
|
||||
/**
|
||||
* Storage version of the pallet.
|
||||
*
|
||||
* New networks start with last version.
|
||||
**/
|
||||
storageVersion: AugmentedQuery<ApiType, () => Observable<Releases>> & QueryableStorageEntry<ApiType>;
|
||||
};
|
||||
session: {
|
||||
[index: string]: QueryableStorageEntry<ApiType>;
|
||||
|
||||
+144
-49
@@ -4,6 +4,7 @@
|
||||
import { AnyNumber, ITuple } from '@polkadot/types/types';
|
||||
import { Compact, Option, U8aFixed, Vec } from '@polkadot/types/codec';
|
||||
import { Bytes, Data, bool, u16, u32, u64 } from '@polkadot/types/primitive';
|
||||
import { BabeEquivocationProof } from '@polkadot/types/interfaces/babe';
|
||||
import { MemberCount, ProposalIndex } from '@polkadot/types/interfaces/collective';
|
||||
import { CodeHash, Gas, Schedule } from '@polkadot/types/interfaces/contracts';
|
||||
import { AccountVote, Conviction, PropIndex, Proposal, ReferendumIndex } from '@polkadot/types/interfaces/democracy';
|
||||
@@ -12,7 +13,8 @@ import { Extrinsic, Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { GrandpaEquivocationProof, KeyOwnerProof } from '@polkadot/types/interfaces/grandpa';
|
||||
import { IdentityFields, IdentityInfo, IdentityJudgement, RegistrarIndex } from '@polkadot/types/interfaces/identity';
|
||||
import { Heartbeat } from '@polkadot/types/interfaces/imOnline';
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, Perbill, Percent, ProxyType, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import { ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import { AccountId, AccountIndex, Address, Balance, BalanceOf, BlockNumber, Call, ChangesTrieConfiguration, Hash, Header, KeyValue, LookupSource, Moment, OpaqueCall, Perbill, Percent, Weight } from '@polkadot/types/interfaces/runtime';
|
||||
import { Period, Priority } from '@polkadot/types/interfaces/scheduler';
|
||||
import { Keys } from '@polkadot/types/interfaces/session';
|
||||
import { SocietyJudgement } from '@polkadot/types/interfaces/society';
|
||||
@@ -31,6 +33,27 @@ declare module '@polkadot/api/types/submittable' {
|
||||
**/
|
||||
setUncles: AugmentedSubmittable<(newUncles: Vec<Header> | (Header | { parentHash?: any; number?: any; stateRoot?: any; extrinsicsRoot?: any; digest?: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
babe: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Report authority equivocation/misbehavior. This method will verify
|
||||
* the equivocation proof and validate the given key ownership proof
|
||||
* against the extracted offender. If both are valid, the offence will
|
||||
* be reported.
|
||||
**/
|
||||
reportEquivocation: AugmentedSubmittable<(equivocationProof: BabeEquivocationProof | { offender?: any; slotNumber?: any; firstHeader?: any; secondHeader?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Report authority equivocation/misbehavior. This method will verify
|
||||
* the equivocation proof and validate the given key ownership proof
|
||||
* against the extracted offender. If both are valid, the offence will
|
||||
* be reported.
|
||||
* This extrinsic must be called unsigned and it is expected that only
|
||||
* block authors will call it (validated in `ValidateUnsigned`), as such
|
||||
* if the block author is defined it will be defined as the equivocation
|
||||
* reporter.
|
||||
**/
|
||||
reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: BabeEquivocationProof | { offender?: any; slotNumber?: any; firstHeader?: any; secondHeader?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
balances: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
@@ -41,7 +64,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* not assumed to be in the overlay.
|
||||
* # </weight>
|
||||
**/
|
||||
forceTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
forceTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Set the balances of a given account.
|
||||
*
|
||||
@@ -62,7 +85,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DB Weight: 1 Read, 1 Write to `who`
|
||||
* # </weight>
|
||||
**/
|
||||
setBalance: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
setBalance: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, newFree: Compact<Balance> | AnyNumber | Uint8Array, newReserved: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Transfer some liquid free balance to another account.
|
||||
*
|
||||
@@ -92,7 +115,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Origin account is already in memory, so no DB operations for them.
|
||||
* # </weight>
|
||||
**/
|
||||
transfer: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
transfer: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Same as the [`transfer`] call, but with a check that the transfer will not kill the
|
||||
* origin account.
|
||||
@@ -106,7 +129,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
|
||||
* #</weight>
|
||||
**/
|
||||
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
transferKeepAlive: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<Balance> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
contracts: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
@@ -119,7 +142,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* * If no account exists and the call value is not less than `existential_deposit`,
|
||||
* a regular account will be created and any value will be transferred.
|
||||
**/
|
||||
call: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
call: AugmentedSubmittable<(dest: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, gasLimit: Compact<Gas> | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Allows block producers to claim a small reward for evicting a contract. If a block producer
|
||||
* fails to do so, a regular users will be allowed to claim the reward.
|
||||
@@ -717,7 +740,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Else, since this is a root call and will go into phragmen, we assume full block for now.
|
||||
* # </weight>
|
||||
**/
|
||||
removeMember: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
removeMember: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, hasReplacement: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove `origin` as a voter. This removes the lock and returns the bond.
|
||||
*
|
||||
@@ -868,24 +891,42 @@ declare module '@polkadot/api/types/submittable' {
|
||||
};
|
||||
grandpa: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Note that the current authority set of the GRANDPA finality gadget has
|
||||
* stalled. This will trigger a forced authority set change at the beginning
|
||||
* of the next session, to be enacted `delay` blocks after that. The delay
|
||||
* should be high enough to safely assume that the block signalling the
|
||||
* forced change will not be re-orged (e.g. 1000 blocks). The GRANDPA voters
|
||||
* will start the new authority set using the given finalized block as base.
|
||||
* Only callable by root.
|
||||
**/
|
||||
noteStalled: AugmentedSubmittable<(delay: BlockNumber | AnyNumber | Uint8Array, bestFinalizedBlockNumber: BlockNumber | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Report voter equivocation/misbehavior. This method will verify the
|
||||
* equivocation proof and validate the given key ownership proof
|
||||
* against the extracted offender. If both are valid, the offence
|
||||
* will be reported.
|
||||
**/
|
||||
reportEquivocation: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Report voter equivocation/misbehavior. This method will verify the
|
||||
* equivocation proof and validate the given key ownership proof
|
||||
* against the extracted offender. If both are valid, the offence
|
||||
* will be reported.
|
||||
*
|
||||
* Since the weight of the extrinsic is 0, in order to avoid DoS by
|
||||
* submission of invalid equivocation reports, a mandatory pre-validation of
|
||||
* the extrinsic is implemented in a `SignedExtension`.
|
||||
* This extrinsic must be called unsigned and it is expected that only
|
||||
* block authors will call it (validated in `ValidateUnsigned`), as such
|
||||
* if the block author is defined it will be defined as the equivocation
|
||||
* reporter.
|
||||
**/
|
||||
reportEquivocation: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
reportEquivocationUnsigned: AugmentedSubmittable<(equivocationProof: GrandpaEquivocationProof | { setId?: any; equivocation?: any } | string | Uint8Array, keyOwnerProof: KeyOwnerProof | { session?: any; trieNodes?: any; validatorCount?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
identity: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
/**
|
||||
* Add a registrar to the system.
|
||||
*
|
||||
* The dispatch origin for this call must be `RegistrarOrigin` or `Root`.
|
||||
* The dispatch origin for this call must be `T::RegistrarOrigin`.
|
||||
*
|
||||
* - `account`: the account of the registrar.
|
||||
*
|
||||
@@ -898,6 +939,16 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
addRegistrar: AugmentedSubmittable<(account: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Add the given account to the sender's subs.
|
||||
*
|
||||
* Payment: Balance reserved by a previous `set_subs` call for one sub will be repatriated
|
||||
* to the sender.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* sub identity of `sub`.
|
||||
**/
|
||||
addSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Cancel a previous request.
|
||||
*
|
||||
@@ -946,7 +997,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* `Slash`. Verification request deposits are not returned; they should be cancelled
|
||||
* manually using `cancel_request`.
|
||||
*
|
||||
* The dispatch origin for this call must be _Root_ or match `T::ForceOrigin`.
|
||||
* The dispatch origin for this call must match `T::ForceOrigin`.
|
||||
*
|
||||
* - `target`: the account whose identity the judgement is upon. This must be an account
|
||||
* with a registered identity.
|
||||
@@ -960,7 +1011,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One event.
|
||||
* # </weight>
|
||||
**/
|
||||
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
killIdentity: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Provide a judgement for an account's identity.
|
||||
*
|
||||
@@ -982,7 +1033,37 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One event.
|
||||
* # </weight>
|
||||
**/
|
||||
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
provideJudgement: AugmentedSubmittable<(regIndex: Compact<RegistrarIndex> | AnyNumber | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, judgement: IdentityJudgement | { Unknown: any } | { FeePaid: any } | { Reasonable: any } | { KnownGood: any } | { OutOfDate: any } | { LowQuality: any } | { Erroneous: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove the sender as a sub-account.
|
||||
*
|
||||
* Payment: Balance reserved by a previous `set_subs` call for one sub will be repatriated
|
||||
* to the sender (*not* the original depositor).
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* super-identity.
|
||||
*
|
||||
* NOTE: This should not normally be used, but is provided in the case that the non-
|
||||
* controller of an account is maliciously registered as a sub-account.
|
||||
**/
|
||||
quitSub: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove the given account from the sender's subs.
|
||||
*
|
||||
* Payment: Balance reserved by a previous `set_subs` call for one sub will be repatriated
|
||||
* to the sender.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* sub identity of `sub`.
|
||||
**/
|
||||
removeSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Alter the associated name of the given sub-account.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_ and the sender must have a registered
|
||||
* sub identity of `sub`.
|
||||
**/
|
||||
renameSub: AugmentedSubmittable<(sub: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, data: Data | { None: any } | { Raw: any } | { BlakeTwo256: any } | { Sha256: any } | { Keccak256: any } | { ShaThree256: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Request a judgement from a registrar.
|
||||
*
|
||||
@@ -1334,7 +1415,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Plus Call Weight
|
||||
* # </weight>
|
||||
**/
|
||||
asMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], maybeTimepoint: Option<Timepoint> | null | object | string | Uint8Array, call: Bytes | string | Uint8Array, storeCall: bool | boolean | Uint8Array, maxWeight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
asMulti: AugmentedSubmittable<(threshold: u16 | AnyNumber | Uint8Array, otherSignatories: Vec<AccountId> | (AccountId | string | Uint8Array)[], maybeTimepoint: Option<Timepoint> | null | object | string | Uint8Array, call: OpaqueCall | string | Uint8Array, storeCall: bool | boolean | Uint8Array, maxWeight: Weight | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Immediately dispatch a multi-signature call using a single approval from the caller.
|
||||
*
|
||||
@@ -1748,6 +1829,14 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
schedule: AugmentedSubmittable<(when: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Anonymously schedule a task after a delay.
|
||||
*
|
||||
* # <weight>
|
||||
* Same as [`schedule`].
|
||||
* # </weight>
|
||||
**/
|
||||
scheduleAfter: AugmentedSubmittable<(after: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Schedule a named task.
|
||||
*
|
||||
@@ -1761,6 +1850,14 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* # </weight>
|
||||
**/
|
||||
scheduleNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array, when: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Schedule a named task after a delay.
|
||||
*
|
||||
* # <weight>
|
||||
* Same as [`schedule_named`].
|
||||
* # </weight>
|
||||
**/
|
||||
scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: BlockNumber | AnyNumber | Uint8Array, maybePeriodic: Option<Period> | null | object | string | Uint8Array, priority: Priority | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
session: {
|
||||
[index: string]: SubmittableExtrinsicFunction<ApiType>;
|
||||
@@ -2068,7 +2165,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Total Complexity: O(M + logM + C)
|
||||
* # </weight>
|
||||
**/
|
||||
vote: AugmentedSubmittable<(candidate: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
vote: AugmentedSubmittable<(candidate: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, approve: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* As a member, vouch for someone to join society by placing a bid on their behalf.
|
||||
*
|
||||
@@ -2143,7 +2240,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Bonded, Payee, [Origin Account], Locks, Ledger
|
||||
* # </weight>
|
||||
**/
|
||||
bond: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | 'Staked'|'Stash'|'Controller' | number | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
bond: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, value: Compact<BalanceOf> | AnyNumber | Uint8Array, payee: RewardDestination | 'Staked'|'Stash'|'Controller' | number | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Add some extra amount that have appeared in the stash `free_balance` into the balance up
|
||||
* for staking.
|
||||
@@ -2172,7 +2269,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
/**
|
||||
* Cancel enactment of a deferred slash.
|
||||
*
|
||||
* Can be called by either the root origin or the `T::SlashCancelOrigin`.
|
||||
* Can be called by the `T::SlashCancelOrigin`.
|
||||
*
|
||||
* Parameters: era and indices of the slashes for that era to kill.
|
||||
*
|
||||
@@ -2288,7 +2385,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Writes: Validators, Nominators
|
||||
* # </weight>
|
||||
**/
|
||||
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | Address | AccountId | AccountIndex | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
nominate: AugmentedSubmittable<(targets: Vec<LookupSource> | (LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Pay out all the stakers behind a single validator for a single era.
|
||||
*
|
||||
@@ -2306,7 +2403,9 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Contains a limited number of reads and writes.
|
||||
* -----------
|
||||
* N is the Number of payouts for the validator (including the validator)
|
||||
* Base Weight: 110 + 54.2 * N µs (Median Slopes)
|
||||
* Base Weight:
|
||||
* - Reward Destination Staked: 110 + 54.2 * N µs (Median Slopes)
|
||||
* - Reward Destination Controller (Creating): 120 + 41.95 * N µs (Median Slopes)
|
||||
* DB Weight:
|
||||
* - Read: EraElectionStatus, CurrentEra, HistoryDepth, ErasValidatorReward,
|
||||
* ErasStakersClipped, ErasRewardPoints, ErasValidatorPrefs (8 items)
|
||||
@@ -2381,7 +2480,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Write: Bonded, Ledger New Controller, Ledger Old Controller
|
||||
* # </weight>
|
||||
**/
|
||||
setController: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
setController: AugmentedSubmittable<(controller: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Set `HistoryDepth` value. This function will delete any history information
|
||||
* when `HistoryDepth` is reduced.
|
||||
@@ -2612,7 +2711,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - One DB change.
|
||||
* # </weight>
|
||||
**/
|
||||
setKey: AugmentedSubmittable<(updated: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
setKey: AugmentedSubmittable<(updated: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||
*
|
||||
@@ -2639,7 +2738,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Weight of derivative `call` execution + 10,000.
|
||||
* # </weight>
|
||||
**/
|
||||
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
sudoAs: AugmentedSubmittable<(who: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Authenticates the sudo key and dispatches a function call with `Root` origin.
|
||||
* This function does not check the weight of the call, and instead allows the
|
||||
@@ -2908,7 +3007,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
/**
|
||||
* Add a member `who` to the set.
|
||||
*
|
||||
* May only be called from `AddOrigin` or root.
|
||||
* May only be called from `T::AddOrigin`.
|
||||
**/
|
||||
addMember: AugmentedSubmittable<(who: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
@@ -2921,29 +3020,33 @@ declare module '@polkadot/api/types/submittable' {
|
||||
changeKey: AugmentedSubmittable<(updated: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove the prime member if it exists.
|
||||
*
|
||||
* May only be called from `T::PrimeOrigin`.
|
||||
**/
|
||||
clearPrime: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Remove a member `who` from the set.
|
||||
*
|
||||
* May only be called from `RemoveOrigin` or root.
|
||||
* May only be called from `T::RemoveOrigin`.
|
||||
**/
|
||||
removeMember: AugmentedSubmittable<(who: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Change the membership to a new set, disregarding the existing membership. Be nice and
|
||||
* pass `members` pre-sorted.
|
||||
*
|
||||
* May only be called from `ResetOrigin` or root.
|
||||
* May only be called from `T::ResetOrigin`.
|
||||
**/
|
||||
resetMembers: AugmentedSubmittable<(members: Vec<AccountId> | (AccountId | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Set the prime member. Must be a current member.
|
||||
*
|
||||
* May only be called from `T::PrimeOrigin`.
|
||||
**/
|
||||
setPrime: AugmentedSubmittable<(who: AccountId | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Swap out one member `remove` for another `add`.
|
||||
*
|
||||
* May only be called from `SwapOrigin` or root.
|
||||
* May only be called from `T::SwapOrigin`.
|
||||
*
|
||||
* Prime membership is *not* passed from `remove` to `add`, if extant.
|
||||
**/
|
||||
@@ -2979,6 +3082,8 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
|
||||
* and the original deposit will be returned.
|
||||
*
|
||||
* May only be called from `T::ApproveOrigin`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: O(1).
|
||||
* - DbReads: `Proposals`, `Approvals`
|
||||
@@ -3017,10 +3122,12 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - DbWrites: `ProposalCount`, `Proposals`, `origin account`
|
||||
* # </weight>
|
||||
**/
|
||||
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
proposeSpend: AugmentedSubmittable<(value: Compact<BalanceOf> | AnyNumber | Uint8Array, beneficiary: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Reject a proposed spend. The original deposit will be slashed.
|
||||
*
|
||||
* May only be called from `T::RejectOrigin`.
|
||||
*
|
||||
* # <weight>
|
||||
* - Complexity: O(1)
|
||||
* - DbReads: `Proposals`, `rejected proposer account`
|
||||
@@ -3136,7 +3243,10 @@ declare module '@polkadot/api/types/submittable' {
|
||||
*
|
||||
* NOTE: If you need to ensure that any account-based filtering is not honored (i.e.
|
||||
* because you expect `proxy` to have been used prior in the call stack and you do not want
|
||||
* the call restrictions to apply to any sub-accounts), then use `as_sub` instead.
|
||||
* the call restrictions to apply to any sub-accounts), then use `as_multi_threshold_1`
|
||||
* in the Multisig pallet instead.
|
||||
*
|
||||
* NOTE: Prior to version *12, this was called `as_limited_sub`.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
@@ -3145,22 +3255,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Plus the weight of the `call`
|
||||
* # </weight>
|
||||
**/
|
||||
asLimitedSub: AugmentedSubmittable<(index: u16 | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Send a call through an indexed pseudonym of the sender.
|
||||
*
|
||||
* NOTE: If you need to ensure that any account-based filtering is honored (i.e. because
|
||||
* you expect `proxy` to have been used prior in the call stack and you want it to apply to
|
||||
* any sub-accounts), then use `as_limited_sub` instead.
|
||||
*
|
||||
* The dispatch origin for this call must be _Signed_.
|
||||
*
|
||||
* # <weight>
|
||||
* - Base weight: 2.861 µs
|
||||
* - Plus the weight of the `call`
|
||||
* # </weight>
|
||||
**/
|
||||
asSub: AugmentedSubmittable<(index: u16 | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
asDerivative: AugmentedSubmittable<(index: u16 | AnyNumber | Uint8Array, call: Call | { callIndex?: any; args?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Send a batch of dispatch calls.
|
||||
*
|
||||
@@ -3208,7 +3303,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
forceVestedTransfer: AugmentedSubmittable<(source: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Unlock any vested funds of the sender account.
|
||||
*
|
||||
@@ -3250,7 +3345,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Using 50 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
vestOther: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
/**
|
||||
* Create a vested transfer.
|
||||
*
|
||||
@@ -3271,7 +3366,7 @@ declare module '@polkadot/api/types/submittable' {
|
||||
* - Using 100 µs fixed. Assuming less than 50 locks on any user, else we may want factor in number of locks.
|
||||
* # </weight>
|
||||
**/
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
vestedTransfer: AugmentedSubmittable<(target: LookupSource | Address | AccountId | AccountIndex | LookupSource | string | Uint8Array, schedule: VestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Observable, Subscription, of } from 'rxjs';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
import { Metadata, Text } from '@polkadot/types';
|
||||
import { LATEST_EXTRINSIC_VERSION } from '@polkadot/types/extrinsic/Extrinsic';
|
||||
import { getMetadataTypes, getSpecTypes } from '@polkadot/types-known';
|
||||
import { getMetadataTypes, getSpecAlias, getSpecTypes } from '@polkadot/types-known';
|
||||
import { logger } from '@polkadot/util';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -35,6 +35,7 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this.registry.setKnownTypes({
|
||||
types: options.types,
|
||||
typesAlias: options.typesAlias,
|
||||
typesBundle: options.typesBundle,
|
||||
typesChain: options.typesChain,
|
||||
typesSpec: options.typesSpec
|
||||
});
|
||||
@@ -147,6 +148,33 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
private _adjustBundleTypes (chain: Text, specName: Text): void {
|
||||
// adjust known type aliases
|
||||
this.registry.knownTypes.typesAlias = getSpecAlias(this.registry, chain, specName);
|
||||
|
||||
// FIXME For the first round, we are not adjusting the user-injected RPCs
|
||||
// inject any user-level RPCs now that we have the chain/spec
|
||||
// this._rpcCore.addUserInterfaces(getSpecRpc(this.registry, chain, specName));
|
||||
|
||||
// const extraRpc = this._decorateRpc(this._rpcCore, this._decorateMethod);
|
||||
|
||||
// // FIXME this is a mess
|
||||
// Object.entries(extraRpc).forEach(([section, value]): void => {
|
||||
// if (this._rpc) {
|
||||
// if (!this._rpc[section as 'author']) {
|
||||
// this._rpc[section as 'author'] = {} as DecoratedRpcSection<ApiType, RpcInterface['author']>;
|
||||
// }
|
||||
|
||||
// Object.entries(value).forEach(([name, method]): void => {
|
||||
// if (this._rpc && !this._rpc[section as 'author'][name as 'hasKey']) {
|
||||
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
// this._rpc[section as 'author'][name as 'hasKey'] = method;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
private async _metaFromChain (optMetadata: Record<string, string>): Promise<Metadata> {
|
||||
const [runtimeVersion, chain, chainProps] = await Promise.all([
|
||||
this._rpcCore.state.getRuntimeVersion().toPromise(),
|
||||
@@ -159,6 +187,11 @@ export default abstract class Init<ApiType extends ApiTypes> extends Decorate<Ap
|
||||
this._runtimeVersion = runtimeVersion;
|
||||
this._rx.runtimeVersion = runtimeVersion;
|
||||
|
||||
// adjust types based on bundled info
|
||||
if (this.registry.knownTypes.typesBundle) {
|
||||
this._adjustBundleTypes(chain, runtimeVersion.specName);
|
||||
}
|
||||
|
||||
// do the setup for the specific chain
|
||||
this.registry.setChainProperties(chainProps);
|
||||
this.registerTypes(getSpecTypes(this.registry, chain, runtimeVersion.specName, runtimeVersion.specVersion));
|
||||
|
||||
@@ -69,7 +69,9 @@ function decorateCall<Method extends DecorateFn<ObsInnerType<ReturnType<Method>>
|
||||
catchError((error) => tracker.reject(error))
|
||||
).subscribe((result): void => {
|
||||
tracker.resolve(result);
|
||||
setImmediate(() => subscription.unsubscribe());
|
||||
typeof setImmediate === 'undefined'
|
||||
? setTimeout(() => subscription.unsubscribe(), 0)
|
||||
: setImmediate(() => subscription.unsubscribe());
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -87,7 +89,9 @@ function decorateSubscribe<Method extends DecorateFn<ObsInnerType<ReturnType<Met
|
||||
).subscribe((result): void => {
|
||||
// We use setImmediate here to ensure that the Promise above (tracker) has resolved, before returning
|
||||
// the first result. By putting is back in the queue, the promise above is guarded for first execution
|
||||
setImmediate(() => resultCb(result) as void);
|
||||
typeof setImmediate === 'undefined'
|
||||
? setTimeout(() => resultCb(result) as void, 0)
|
||||
: setImmediate(() => resultCb(result) as void);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/metadata",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Helpers to extract information from runtime metadata",
|
||||
"main": "index.js",
|
||||
"publishConfig": {
|
||||
@@ -26,14 +26,14 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-metadata#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/types-known": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@polkadot/util-crypto": "^2.16.1",
|
||||
"bn.js": "^5.1.2"
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/types-known": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.16.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-core",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,15 +26,15 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/metadata": "1.22.1",
|
||||
"@polkadot/rpc-provider": "1.22.1",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.5"
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.16.1"
|
||||
"@polkadot/keyring": "^3.3.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,12 @@ export default class Rpc implements RpcInterface {
|
||||
this.registry = registry;
|
||||
this.provider = provider;
|
||||
|
||||
this._createInterfaces(userRpc);
|
||||
const sectionNames = Object.keys(jsonrpc);
|
||||
|
||||
// these are the base keys (i.e. part of jsonrpc)
|
||||
this.sections.push(...sectionNames);
|
||||
|
||||
this.addUserInterfaces(userRpc);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,27 +131,37 @@ export default class Rpc implements RpcInterface {
|
||||
this.provider.disconnect();
|
||||
}
|
||||
|
||||
private _createInterfaces<Section extends keyof RpcInterface> (userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
|
||||
const sectionNames = Object.keys(jsonrpc);
|
||||
|
||||
// these are the base keys (i.e. part of jsonrpc)
|
||||
this.sections.push(...sectionNames);
|
||||
|
||||
public addUserInterfaces<Section extends keyof RpcInterface> (userRpc: Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>>): void {
|
||||
// add any extra user-defined sections
|
||||
this.sections.push(...Object.keys(userRpc).filter((key): boolean => !this.sections.includes(key)));
|
||||
this.sections.push(...Object.keys(userRpc).filter((key) => !this.sections.includes(key)));
|
||||
|
||||
// decorate the sections with base and user methods
|
||||
this.sections.forEach((sectionName): void => {
|
||||
(this as Record<string, unknown>)[sectionName as Section] = {
|
||||
...this._createInterface(sectionName, jsonrpc[sectionName as 'babe'] || {}),
|
||||
...this._createInterface(sectionName, userRpc[sectionName] || {})
|
||||
};
|
||||
if (!(this as Record<string, unknown>)[sectionName as Section]) {
|
||||
(this as Record<string, unknown>)[sectionName as Section] = {};
|
||||
}
|
||||
|
||||
const section = (this as Record<string, unknown>)[sectionName as Section] as Record<string, any>;
|
||||
|
||||
Object
|
||||
.entries({
|
||||
...this._createInterface(sectionName, jsonrpc[sectionName as 'babe'] || {}),
|
||||
...this._createInterface(sectionName, userRpc[sectionName] || {})
|
||||
})
|
||||
.forEach(([key, value]): void => {
|
||||
// we don't want to clobber existing, i.e. when this is called again after chain is determined
|
||||
if (!section[key]) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
section[key] = value;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private _createInterface<Section extends keyof RpcInterface> (section: string, methods: Record<string, DefinitionRpc | DefinitionRpcSub>): RpcInterface[Section] {
|
||||
return Object
|
||||
.keys(methods)
|
||||
.filter((method) => !this.mapping.has(`${section}_${method}`))
|
||||
.reduce((exposed, method): RpcInterface[Section] => {
|
||||
const def = methods[method];
|
||||
const isSubscription = !!(def as DefinitionRpcSub).pubsub;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/rpc-provider",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Transport providers for the API",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,19 +26,19 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/metadata": "1.22.1",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@polkadot/util-crypto": "^2.16.1",
|
||||
"bn.js": "^5.1.2",
|
||||
"eventemitter3": "^4.0.4",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"bn.js": "^5.1.3",
|
||||
"eventemitter3": "^4.0.5",
|
||||
"isomorphic-fetch": "^2.2.1",
|
||||
"websocket": "^1.0.31"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.16.1",
|
||||
"@polkadot/keyring": "^3.3.1",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^12.0.3"
|
||||
"nock": "^13.0.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,12 @@ describe('Http', (): void => {
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('allows custom headers', (): void => {
|
||||
expect(
|
||||
(): Http => new Http('https://', { foo: 'bar' })
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it('always returns isConnected true', (): void => {
|
||||
expect(http.isConnected()).toEqual(true);
|
||||
});
|
||||
|
||||
@@ -40,14 +40,17 @@ export default class HttpProvider implements ProviderInterface {
|
||||
|
||||
readonly #endpoint: string;
|
||||
|
||||
readonly #headers: Record<string, string>;
|
||||
|
||||
/**
|
||||
* @param {string} endpoint The endpoint url starting with http://
|
||||
*/
|
||||
constructor (endpoint: string = defaults.HTTP_URL) {
|
||||
constructor (endpoint: string = defaults.HTTP_URL, headers: Record<string, string> = {}) {
|
||||
assert(/^(https|http):\/\//.test(endpoint), `Endpoint should start with 'http://', received '${endpoint}'`);
|
||||
|
||||
this.#coder = new Coder();
|
||||
this.#endpoint = endpoint;
|
||||
this.#headers = headers;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +105,8 @@ export default class HttpProvider implements ProviderInterface {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Length': `${body.length}`,
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
...this.#headers
|
||||
},
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { JsonRpcResponse, ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitted, ProviderInterfaceEmitCb } from '../types';
|
||||
|
||||
import EventEmitter from 'eventemitter3';
|
||||
import { assert, isNull, isUndefined, logger } from '@polkadot/util';
|
||||
import { assert, isNull, isUndefined, isChildClass, logger } from '@polkadot/util';
|
||||
|
||||
import Coder from '../coder';
|
||||
import defaults from '../defaults';
|
||||
@@ -67,6 +67,8 @@ export default class WsProvider implements WSProviderInterface {
|
||||
|
||||
readonly #endpoints: string[];
|
||||
|
||||
readonly #headers: Record<string, string>;
|
||||
|
||||
readonly #eventemitter: EventEmitter;
|
||||
|
||||
readonly #handlers: Record<string, WsStateAwaiting> = {};
|
||||
@@ -89,7 +91,7 @@ export default class WsProvider implements WSProviderInterface {
|
||||
* @param {string | string[]} endpoint The endpoint url. Usually `ws://ip:9944` or `wss://ip:9944`, may provide an array of endpoint strings.
|
||||
* @param {boolean} autoConnect Whether to connect automatically or not.
|
||||
*/
|
||||
constructor (endpoint: string | string[] = defaults.WS_URL, autoConnectMs: number | false = 1000) {
|
||||
constructor (endpoint: string | string[] = defaults.WS_URL, autoConnectMs: number | false = 1000, headers: Record<string, string> = {}) {
|
||||
const endpoints = Array.isArray(endpoint)
|
||||
? endpoint
|
||||
: [endpoint];
|
||||
@@ -105,6 +107,7 @@ export default class WsProvider implements WSProviderInterface {
|
||||
this.#coder = new Coder();
|
||||
this.#endpointIndex = -1;
|
||||
this.#endpoints = endpoints;
|
||||
this.#headers = headers;
|
||||
this.#websocket = null;
|
||||
|
||||
if (autoConnectMs > 0) {
|
||||
@@ -138,7 +141,11 @@ export default class WsProvider implements WSProviderInterface {
|
||||
|
||||
const WS = await getWSClass();
|
||||
|
||||
this.#websocket = new WS(this.#endpoints[this.#endpointIndex]);
|
||||
this.#websocket = typeof WebSocket !== 'undefined' && isChildClass(WebSocket, WS)
|
||||
? new WS(this.#endpoints[this.#endpointIndex])
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore - WS may be an instance of w3cwebsocket, which supports headers
|
||||
: new WS(this.#endpoints[this.#endpointIndex], undefined, undefined, this.#headers);
|
||||
this.#websocket.onclose = this.#onSocketClose;
|
||||
this.#websocket.onerror = this.#onSocketError;
|
||||
this.#websocket.onmessage = this.#onSocketMessage;
|
||||
|
||||
@@ -28,6 +28,12 @@ describe('Ws', (): void => {
|
||||
createWs([]).isConnected()
|
||||
).toEqual(false);
|
||||
});
|
||||
|
||||
it('allows you to initialize the provider with custom headers', (): void => {
|
||||
expect(
|
||||
(): WsProvider => new WsProvider(TEST_WS_URL, 1000, { foo: 'bar' })
|
||||
).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Endpoint Parsing', (): void => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/typegen",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Type generation scripts",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
@@ -33,20 +33,20 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.10.3",
|
||||
"@babel/register": "^7.10.3",
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/api": "1.22.1",
|
||||
"@polkadot/metadata": "1.22.1",
|
||||
"@polkadot/rpc-provider": "1.22.1",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@babel/core": "^7.11.4",
|
||||
"@babel/register": "^7.10.5",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/api": "1.30.1",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/rpc-provider": "1.30.1",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"handlebars": "^4.7.6",
|
||||
"websocket": "^1.0.31",
|
||||
"yargs": "^15.3.1"
|
||||
"yargs": "^15.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/websocket": "^1.0.0",
|
||||
"@types/websocket": "^1.0.1",
|
||||
"@types/yargs": "^15.0.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
import Handlebars from 'handlebars';
|
||||
|
||||
import { TypeRegistry } from '@polkadot/types/create';
|
||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||
import { Definitions } from '@polkadot/types/types';
|
||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||
|
||||
import { createImports, getSimilarTypes, readTemplate, setImports, writeFile } from '../util';
|
||||
import { createImports, getSimilarTypes, formatType, readTemplate, setImports, writeFile } from '../util';
|
||||
|
||||
const StorageKeyTye = 'StorageKey | string | Uint8Array | any';
|
||||
|
||||
@@ -15,21 +16,28 @@ const template = readTemplate('rpc');
|
||||
const generateRpcTypesTemplate = Handlebars.compile(template);
|
||||
|
||||
/** @internal */
|
||||
export default function generateRpcTypes (dest = 'packages/api/src/augment/rpc.ts'): void {
|
||||
export function generateRpcTypes (importDefinitions: { [importPath: string]: Record<string, Definitions> }, dest: string): void {
|
||||
writeFile(dest, (): string => {
|
||||
const registry = new TypeRegistry();
|
||||
const allTypes = { '@polkadot/types/interfaces': definitions };
|
||||
const imports = createImports(allTypes);
|
||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||
|
||||
const imports = createImports(importDefinitions);
|
||||
const definitions = imports.definitions as Record<string, Definitions>;
|
||||
|
||||
const allDefs = Object.entries(importDefinitions).reduce((defs, [path, obj]) => {
|
||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||
}, {});
|
||||
|
||||
const rpcKeys = Object
|
||||
.keys(definitions)
|
||||
.filter((key) => Object.keys(definitions[key as 'babe'].rpc || {}).length !== 0)
|
||||
.filter((key) => Object.keys(definitions[key].rpc || {}).length !== 0)
|
||||
.sort();
|
||||
const modules = rpcKeys.map((section) => {
|
||||
const allMethods = Object.keys(definitions[section as 'babe'].rpc).sort().map((methodName) => {
|
||||
const def = definitions[section as 'babe'].rpc[methodName];
|
||||
|
||||
const modules = rpcKeys.map((sectionFullName) => {
|
||||
const rpc = definitions[sectionFullName].rpc;
|
||||
const section = sectionFullName.split('/').pop();
|
||||
|
||||
const allMethods = Object.keys(rpc).sort().map((methodName) => {
|
||||
const def = rpc[methodName];
|
||||
|
||||
let args;
|
||||
let type;
|
||||
@@ -69,7 +77,7 @@ export default function generateRpcTypes (dest = 'packages/api/src/augment/rpc.t
|
||||
return `${param.name}${param.isOptional ? '?' : ''}: ${similarTypes.join(' | ')}`;
|
||||
});
|
||||
|
||||
type = def.type;
|
||||
type = formatType(allDefs, def.type, imports);
|
||||
generic = '';
|
||||
}
|
||||
|
||||
@@ -105,3 +113,10 @@ export default function generateRpcTypes (dest = 'packages/api/src/augment/rpc.t
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export default function generateDefaultRpcTypes (): void {
|
||||
generateRpcTypes(
|
||||
{ '@polkadot/types/interfaces': defaultDefinitions },
|
||||
'packages/api/src/augment/rpc.ts'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import Vec from '@polkadot/types/codec/Vec';
|
||||
import Tuple from '@polkadot/types/codec/Tuple';
|
||||
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
|
||||
import GenericAccountId from '@polkadot/types/generic/AccountId';
|
||||
import GenericAddress from '@polkadot/types/generic/Address';
|
||||
import GenericLookupSource from '@polkadot/types/generic/LookupSource';
|
||||
import Vote from '@polkadot/types/generic/Vote';
|
||||
import Null from '@polkadot/types/primitive/Null';
|
||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
||||
@@ -92,18 +92,22 @@ export function getSimilarTypes (definitions: Record<string, ModuleTypes>, regis
|
||||
const Clazz = ClassOfUnsafe(registry, type);
|
||||
|
||||
if (isChildClass(Vec, Clazz)) {
|
||||
const subDef = (getTypeDef(type).sub) as TypeDef;
|
||||
const vecDef = getTypeDef(type);
|
||||
const subDef = (vecDef.sub) as TypeDef;
|
||||
|
||||
if (subDef.info === TypeDefInfo.Plain) {
|
||||
possibleTypes.push(`(${getSimilarTypes(definitions, registry, subDef.type, imports).join(' | ')})[]`);
|
||||
} else if (subDef.info === TypeDefInfo.Tuple) {
|
||||
const subs = (subDef.sub as TypeDef[]).map(({ type }): string =>
|
||||
getSimilarTypes(definitions, registry, type, imports).join(' | ')
|
||||
);
|
||||
// this could be that we define a Vec type and refer to it by name
|
||||
if (subDef) {
|
||||
if (subDef.info === TypeDefInfo.Plain) {
|
||||
possibleTypes.push(`(${getSimilarTypes(definitions, registry, subDef.type, imports).join(' | ')})[]`);
|
||||
} else if (subDef.info === TypeDefInfo.Tuple) {
|
||||
const subs = (subDef.sub as TypeDef[]).map(({ type }): string =>
|
||||
getSimilarTypes(definitions, registry, type, imports).join(' | ')
|
||||
);
|
||||
|
||||
possibleTypes.push(`([${subs.join(', ')}])[]`);
|
||||
} else {
|
||||
throw new Error(`Unhandled subtype in Vec, ${JSON.stringify(subDef)}`);
|
||||
possibleTypes.push(`([${subs.join(', ')}])[]`);
|
||||
} else {
|
||||
throw new Error(`Unhandled subtype in Vec, ${JSON.stringify(subDef)}`);
|
||||
}
|
||||
}
|
||||
} else if (isChildClass(Enum, Clazz)) {
|
||||
const e = new (Clazz as Constructor)(registry) as Enum;
|
||||
@@ -118,8 +122,8 @@ export function getSimilarTypes (definitions: Record<string, ModuleTypes>, regis
|
||||
possibleTypes.push('Uint8Array');
|
||||
} else if (isChildClass(AbstractInt as unknown as Constructor<UInt>, Clazz) || isChildClass(Compact, Clazz)) {
|
||||
possibleTypes.push('AnyNumber', 'Uint8Array');
|
||||
} else if (isChildClass(GenericAddress, Clazz)) {
|
||||
possibleTypes.push('Address', 'AccountId', 'AccountIndex', 'string', 'Uint8Array');
|
||||
} else if (isChildClass(GenericLookupSource, Clazz)) {
|
||||
possibleTypes.push('Address', 'AccountId', 'AccountIndex', 'LookupSource', 'string', 'Uint8Array');
|
||||
} else if (isChildClass(GenericAccountId, Clazz)) {
|
||||
possibleTypes.push('string', 'Uint8Array');
|
||||
} else if (isChildClass(registry.createClass('bool'), Clazz)) {
|
||||
@@ -141,8 +145,10 @@ export function getSimilarTypes (definitions: Record<string, ModuleTypes>, regis
|
||||
} else if (isChildClass(String, Clazz)) {
|
||||
possibleTypes.push('string');
|
||||
} else if (isChildClass(Tuple, Clazz)) {
|
||||
const subDef = getTypeDef(type).sub;
|
||||
const tupDef = getTypeDef(type);
|
||||
const subDef = tupDef.sub;
|
||||
|
||||
// this could be that we define a Tuple type and refer to it by name
|
||||
if (Array.isArray(subDef)) {
|
||||
const subs = subDef.map(({ type }) => getSimilarTypes(definitions, registry, type, imports).join(' | '));
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types-known",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,10 +26,10 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/types": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"bn.js": "^5.1.2"
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/types": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"bn.js": "^5.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bn.js": "^4.11.6"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import type BN from 'bn.js';
|
||||
import { Registry, RegistryTypes, OverrideModuleType, OverrideVersionedType } from '@polkadot/types/types';
|
||||
import { DefinitionRpc, DefinitionRpcSub, Registry, RegistryTypes, OverrideModuleType, OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
import { Text } from '@polkadot/types';
|
||||
import { bnToBn, isUndefined } from '@polkadot/util';
|
||||
@@ -58,7 +58,36 @@ export function getSpecTypes ({ knownTypes }: Registry, chainName: Text | string
|
||||
return {
|
||||
...filterVersions(typesSpec[_specName], _specVersion),
|
||||
...filterVersions(typesChain[_chainName], _specVersion),
|
||||
...filterVersions(knownTypes.typesBundle?.spec?.[_specName]?.types, _specVersion),
|
||||
...filterVersions(knownTypes.typesBundle?.chain?.[_chainName]?.types, _specVersion),
|
||||
...(knownTypes.typesSpec?.[_specName] || {}),
|
||||
...(knownTypes.typesChain?.[_chainName] || {})
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Based on the chain and runtimeVersion, get the applicable rpc definitions (ready for registration)
|
||||
*/
|
||||
export function getSpecRpc ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record<string, Record<string, DefinitionRpc | DefinitionRpcSub>> {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
|
||||
return {
|
||||
...(knownTypes.typesBundle?.spec?.[_specName]?.rpc || {}),
|
||||
...(knownTypes.typesBundle?.chain?.[_chainName]?.rpc || {})
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Based on the chain and runtimeVersion, get the applicable alias definitions (ready for registration)
|
||||
*/
|
||||
export function getSpecAlias ({ knownTypes }: Registry, chainName: Text | string, specName: Text | string): Record<string, OverrideModuleType> {
|
||||
const _chainName = chainName.toString();
|
||||
const _specName = specName.toString();
|
||||
|
||||
return {
|
||||
...(knownTypes.typesAlias || {}),
|
||||
...(knownTypes.typesBundle?.spec?.[_specName]?.alias || {}),
|
||||
...(knownTypes.typesBundle?.chain?.[_chainName]?.alias || {})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -29,6 +29,12 @@ const typesModules: Record<string, OverrideModuleType> = {
|
||||
parachains: {
|
||||
Id: 'ParaId'
|
||||
},
|
||||
proposeParachain: {
|
||||
Proposal: 'ParachainProposal'
|
||||
},
|
||||
proxy: {
|
||||
Announcement: 'ProxyAnnouncement'
|
||||
},
|
||||
society: {
|
||||
Judgement: 'SocietyJudgement',
|
||||
Vote: 'SocietyVote'
|
||||
|
||||
@@ -4,17 +4,47 @@
|
||||
|
||||
import { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
Address: 'LookupSource',
|
||||
AnchorData: {
|
||||
anchoredBlock: 'u64',
|
||||
docRoot: 'H256',
|
||||
id: 'H256'
|
||||
},
|
||||
Fee: {
|
||||
key: 'Hash',
|
||||
price: 'Balance'
|
||||
},
|
||||
MultiAccountData: {
|
||||
deposit: 'Balance',
|
||||
depositor: 'AccountId',
|
||||
signatories: 'Vec<AccountId>',
|
||||
threshold: 'u16'
|
||||
},
|
||||
Multiplier: 'Fixed64',
|
||||
PreCommitData: {
|
||||
expirationBlock: 'u64',
|
||||
identity: 'H256',
|
||||
signingRoot: 'H256'
|
||||
},
|
||||
Proof: {
|
||||
leafHash: 'H256',
|
||||
sortedHashes: 'H256'
|
||||
},
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
};
|
||||
|
||||
const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
// most chains started at 1000 (Fulvous at 224)
|
||||
minmax: [1, undefined],
|
||||
minmax: [229, undefined],
|
||||
types: {
|
||||
Address: 'AccountId',
|
||||
LookupSource: 'AccountId',
|
||||
Multiplier: 'Fixed64',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
StakingLedger: 'StakingLedgerTo240',
|
||||
Weight: 'u32'
|
||||
...sharedTypes,
|
||||
ChainId: 'u8',
|
||||
DepositNonce: 'u64',
|
||||
ResourceId: '[u8; 32]',
|
||||
'chainbridge::ChainId': 'u8'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -7,6 +7,7 @@ import { OverrideVersionedType } from '@polkadot/types/types';
|
||||
import centrifugeChain from './centrifuge-chain';
|
||||
import kusama from './kusama';
|
||||
import polkadot from './polkadot';
|
||||
import rococo from './rococo';
|
||||
import westend from './westend';
|
||||
|
||||
// Type overrides for specific spec types & versions as given in runtimeVersion
|
||||
@@ -14,6 +15,7 @@ const typesSpec: Record<string, OverrideVersionedType[]> = {
|
||||
'centrifuge-chain': centrifugeChain,
|
||||
kusama,
|
||||
polkadot,
|
||||
rococo,
|
||||
westend
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@ import { OverrideVersionedType } from '@polkadot/types/types';
|
||||
const sharedTypes = {
|
||||
Address: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId'
|
||||
LookupSource: 'AccountId',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'IdentityJudgement']
|
||||
}
|
||||
};
|
||||
|
||||
const versioned: OverrideVersionedType[] = [
|
||||
@@ -15,12 +18,12 @@ const versioned: OverrideVersionedType[] = [
|
||||
// 1020 is first CC3
|
||||
minmax: [1019, 1031],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchError: 'DispatchErrorTo198',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'Address',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
@@ -33,11 +36,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [1032, 1042],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'Address',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
@@ -51,11 +54,11 @@ const versioned: OverrideVersionedType[] = [
|
||||
// actual at 1045 (1043-1044 is dev)
|
||||
minmax: [1043, 1045],
|
||||
types: {
|
||||
Address: 'GenericAddress',
|
||||
Address: 'LookupSource',
|
||||
BalanceLock: 'BalanceLockTo212',
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'Address',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
ReferendumInfo: 'ReferendumInfoTo239',
|
||||
@@ -69,6 +72,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
types: {
|
||||
// Indices optional, not in transaction
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -81,6 +85,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1055, 1056],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
@@ -92,6 +97,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1057, 1061],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
DispatchInfo: 'DispatchInfoTo244',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
@@ -100,13 +106,15 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1062, 2012],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [2013, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -9,7 +9,7 @@ const sharedTypes = {
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'SudoBalances']
|
||||
_enum: ['Any', 'NonTransfer', 'Governance', 'Staking', 'SudoBalances', 'IdentityJudgement']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,13 +19,15 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [0, 12],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [13, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2017-2020 @polkadot/types-known authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { OverrideVersionedType } from '@polkadot/types/types';
|
||||
|
||||
const sharedTypes = {
|
||||
Address: 'AccountId',
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId'
|
||||
};
|
||||
|
||||
const versioned: OverrideVersionedType[] = [
|
||||
{
|
||||
minmax: [0, undefined],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
export default versioned;
|
||||
@@ -9,7 +9,7 @@ const sharedTypes = {
|
||||
Keys: 'SessionKeys5',
|
||||
LookupSource: 'AccountId',
|
||||
ProxyType: {
|
||||
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances']
|
||||
_enum: ['Any', 'NonTransfer', 'Staking', 'SudoBalances', 'IdentityJudgement']
|
||||
}
|
||||
};
|
||||
|
||||
@@ -18,6 +18,7 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [1, 2],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
Multiplier: 'Fixed64',
|
||||
OpenTip: 'OpenTipTo225',
|
||||
Weight: 'u32'
|
||||
@@ -27,13 +28,15 @@ const versioned: OverrideVersionedType[] = [
|
||||
minmax: [3, 22],
|
||||
types: {
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257',
|
||||
OpenTip: 'OpenTipTo225'
|
||||
}
|
||||
},
|
||||
{
|
||||
minmax: [23, undefined],
|
||||
types: {
|
||||
...sharedTypes
|
||||
...sharedTypes,
|
||||
CompactAssignments: 'CompactAssignmentsTo257'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/types",
|
||||
"version": "1.22.1",
|
||||
"version": "1.30.1",
|
||||
"description": "Implementation of the Parity codec",
|
||||
"main": "index.js",
|
||||
"keywords": [
|
||||
@@ -26,17 +26,17 @@
|
||||
},
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.3",
|
||||
"@polkadot/metadata": "1.22.1",
|
||||
"@polkadot/util": "^2.16.1",
|
||||
"@polkadot/util-crypto": "^2.16.1",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/metadata": "1.30.1",
|
||||
"@polkadot/util": "^3.3.1",
|
||||
"@polkadot/util-crypto": "^3.3.1",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^5.1.2",
|
||||
"bn.js": "^5.1.3",
|
||||
"memoizee": "^0.4.14",
|
||||
"rxjs": "^6.5.5"
|
||||
"rxjs": "^6.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^2.16.1",
|
||||
"@polkadot/keyring": "^3.3.1",
|
||||
"@types/memoizee": "^0.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,10 +14,11 @@ import { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
|
||||
import { EthereumAddress, StatementKind } from '@polkadot/types/interfaces/claims';
|
||||
import { MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
|
||||
import { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
|
||||
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultSuccess, ContractExecResultSuccessTo255, ContractExecResultTo255, ContractInfo, ContractStorageKey, Gas, PrefabWasmModule, PrefabWasmModuleReserved, Schedule, ScheduleTo212, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
|
||||
import { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
|
||||
import { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
|
||||
import { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
|
||||
import { EthereumAccountId, EthereumLookupSource } from '@polkadot/types/interfaces/ethereum';
|
||||
import { Account, Log, Vicinity } from '@polkadot/types/interfaces/evm';
|
||||
import { EcdsaSignature, Ed25519Signature, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV1, ExtrinsicPayloadV2, ExtrinsicPayloadV3, ExtrinsicPayloadV4, ExtrinsicSignatureV1, ExtrinsicSignatureV2, ExtrinsicSignatureV3, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV1, ExtrinsicV2, ExtrinsicV3, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
|
||||
import { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
|
||||
@@ -27,21 +28,24 @@ import { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiad
|
||||
import { CallMetadataV0, DoubleMapTypeLatest, DoubleMapTypeV10, DoubleMapTypeV11, DoubleMapTypeV3, DoubleMapTypeV4, DoubleMapTypeV5, DoubleMapTypeV6, DoubleMapTypeV7, DoubleMapTypeV8, DoubleMapTypeV9, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV8, ErrorMetadataV9, EventMetadataLatest, EventMetadataV0, EventMetadataV1, EventMetadataV10, EventMetadataV11, EventMetadataV2, EventMetadataV3, EventMetadataV4, EventMetadataV5, EventMetadataV6, EventMetadataV7, EventMetadataV8, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV0, FunctionArgumentMetadataV1, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV2, FunctionArgumentMetadataV3, FunctionArgumentMetadataV4, FunctionArgumentMetadataV5, FunctionArgumentMetadataV6, FunctionArgumentMetadataV7, FunctionArgumentMetadataV8, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV0, FunctionMetadataV1, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV2, FunctionMetadataV3, FunctionMetadataV4, FunctionMetadataV5, FunctionMetadataV6, FunctionMetadataV7, FunctionMetadataV8, FunctionMetadataV9, MapTypeLatest, MapTypeV0, MapTypeV10, MapTypeV11, MapTypeV2, MapTypeV3, MapTypeV4, MapTypeV5, MapTypeV6, MapTypeV7, MapTypeV8, MapTypeV9, MetadataAll, MetadataLatest, MetadataV0, MetadataV1, MetadataV10, MetadataV11, MetadataV2, MetadataV3, MetadataV4, MetadataV5, MetadataV6, MetadataV7, MetadataV8, MetadataV9, ModuleConstantMetadataLatest, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV6, ModuleConstantMetadataV7, ModuleConstantMetadataV8, ModuleConstantMetadataV9, ModuleMetadataLatest, ModuleMetadataV0, ModuleMetadataV1, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV2, ModuleMetadataV3, ModuleMetadataV4, ModuleMetadataV5, ModuleMetadataV6, ModuleMetadataV7, ModuleMetadataV8, ModuleMetadataV9, OuterDispatchCallV0, OuterDispatchMetadataV0, OuterEventEventMetadataEventsV0, OuterEventEventMetadataV0, OuterEventMetadataV0, PlainTypeLatest, PlainTypeV0, PlainTypeV10, PlainTypeV11, PlainTypeV2, PlainTypeV3, PlainTypeV4, PlainTypeV5, PlainTypeV6, PlainTypeV7, PlainTypeV8, PlainTypeV9, RuntimeModuleMetadataV0, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV6, StorageEntryMetadataV7, StorageEntryMetadataV8, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV6, StorageEntryModifierV7, StorageEntryModifierV8, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV6, StorageEntryTypeV7, StorageEntryTypeV8, StorageEntryTypeV9, StorageFunctionMetadataV0, StorageFunctionMetadataV1, StorageFunctionMetadataV2, StorageFunctionMetadataV3, StorageFunctionMetadataV4, StorageFunctionMetadataV5, StorageFunctionModifierV0, StorageFunctionModifierV1, StorageFunctionModifierV2, StorageFunctionModifierV3, StorageFunctionModifierV4, StorageFunctionModifierV5, StorageFunctionTypeV0, StorageFunctionTypeV1, StorageFunctionTypeV2, StorageFunctionTypeV3, StorageFunctionTypeV4, StorageFunctionTypeV5, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV4, StorageHasherV5, StorageHasherV6, StorageHasherV7, StorageHasherV8, StorageHasherV9, StorageMetadataLatest, StorageMetadataV0, StorageMetadataV10, StorageMetadataV11, StorageMetadataV7, StorageMetadataV8, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
|
||||
import { StorageKind } from '@polkadot/types/interfaces/offchain';
|
||||
import { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
|
||||
import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, CandidateCommitments, CandidateReceipt, CollatorId, CollatorSignature, DoubleVoteReport, DownwardMessage, GlobalValidationSchedule, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, LocalValidationData, NewBidder, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, Remark, Retriable, Scheduling, SigningContext, SlotRange, Statement, SubId, UpwardMessage, ValidationCode, ValidatorSignature, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import { AbridgedCandidateReceipt, AttestedCandidate, AuctionIndex, Bidder, CandidateCommitments, CandidateReceipt, CollatorId, CollatorSignature, DoubleVoteReport, DownwardMessage, GlobalValidationSchedule, HeadData, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, LeasePeriod, LeasePeriodOf, LocalValidationData, NewBidder, ParaId, ParaInfo, ParaPastCodeMeta, ParaScheduling, ParachainDispatchOrigin, ParachainProposal, RegisteredParachainInfo, RelayChainBlockNumber, Remark, Retriable, Scheduling, SigningContext, SlotRange, Statement, SubId, UpwardMessage, ValidationCode, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
|
||||
import { RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
|
||||
import { Approvals } from '@polkadot/types/interfaces/poll';
|
||||
import { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
|
||||
import { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
|
||||
import { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
|
||||
import { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, H160, H256, H512, Hash, Header, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, Origin, Pays, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, ProxyType, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { AccountId, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, Call, CallHash, CallHashOf, ChangesTrieConfiguration, Consensus, ConsensusEngineId, Digest, DigestItem, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, GenericAddress, H160, H256, H512, Hash, Header, I32F32, Index, Justification, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, OpaqueCall, Origin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, StorageData, U32F32, ValidatorId, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
|
||||
import { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, TaskAddress } from '@polkadot/types/interfaces/scheduler';
|
||||
import { FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, ValidatorCount } from '@polkadot/types/interfaces/session';
|
||||
import { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
|
||||
import { ActiveEraInfo, CompactAssignments, CompactScore, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, OffchainAccuracy, PerU16, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactScore, CompactScoreCompact, ElectionCompute, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RewardDestination, RewardPoint, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196 } from '@polkadot/types/interfaces/staking';
|
||||
import { ApiId, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, StorageChangeSet } from '@polkadot/types/interfaces/state';
|
||||
import { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
||||
import { AccountInfo, ApplyExtrinsicResult, ChainProperties, ChainType, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, EventRecordTo76, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, Phase, RefCount, TransactionValidityError, UnknownTransaction } from '@polkadot/types/interfaces/system';
|
||||
import { OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
|
||||
import { Multiplier } from '@polkadot/types/interfaces/txpayment';
|
||||
import { CallHash, Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
|
||||
import { VestingInfo } from '@polkadot/types/interfaces/vesting';
|
||||
|
||||
declare module '@polkadot/types/types/registry' {
|
||||
@@ -126,6 +130,50 @@ declare module '@polkadot/types/types/registry' {
|
||||
Raw: Raw;
|
||||
'Option<Raw>': Option<Raw>;
|
||||
'Vec<Raw>': Vec<Raw>;
|
||||
Fixed64: Fixed64;
|
||||
'Option<Fixed64>': Option<Fixed64>;
|
||||
'Vec<Fixed64>': Vec<Fixed64>;
|
||||
FixedI64: FixedI64;
|
||||
'Option<FixedI64>': Option<FixedI64>;
|
||||
'Vec<FixedI64>': Vec<FixedI64>;
|
||||
FixedU64: FixedU64;
|
||||
'Option<FixedU64>': Option<FixedU64>;
|
||||
'Vec<FixedU64>': Vec<FixedU64>;
|
||||
Fixed128: Fixed128;
|
||||
'Option<Fixed128>': Option<Fixed128>;
|
||||
'Vec<Fixed128>': Vec<Fixed128>;
|
||||
FixedI128: FixedI128;
|
||||
'Option<FixedI128>': Option<FixedI128>;
|
||||
'Vec<FixedI128>': Vec<FixedI128>;
|
||||
FixedU128: FixedU128;
|
||||
'Option<FixedU128>': Option<FixedU128>;
|
||||
'Vec<FixedU128>': Vec<FixedU128>;
|
||||
I32F32: I32F32;
|
||||
'Option<I32F32>': Option<I32F32>;
|
||||
'Vec<I32F32>': Vec<I32F32>;
|
||||
U32F32: U32F32;
|
||||
'Option<U32F32>': Option<U32F32>;
|
||||
'Vec<U32F32>': Vec<U32F32>;
|
||||
PerU16: PerU16;
|
||||
'Compact<PerU16>': Compact<PerU16>;
|
||||
'Option<PerU16>': Option<PerU16>;
|
||||
'Vec<PerU16>': Vec<PerU16>;
|
||||
Perbill: Perbill;
|
||||
'Compact<Perbill>': Compact<Perbill>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
Percent: Percent;
|
||||
'Compact<Percent>': Compact<Percent>;
|
||||
'Option<Percent>': Option<Percent>;
|
||||
'Vec<Percent>': Vec<Percent>;
|
||||
Permill: Permill;
|
||||
'Compact<Permill>': Compact<Permill>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
Perquintill: Perquintill;
|
||||
'Compact<Perquintill>': Compact<Perquintill>;
|
||||
'Option<Perquintill>': Option<Perquintill>;
|
||||
'Vec<Perquintill>': Vec<Perquintill>;
|
||||
AccountId: AccountId;
|
||||
'Option<AccountId>': Option<AccountId>;
|
||||
'Vec<AccountId>': Vec<AccountId>;
|
||||
@@ -159,6 +207,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
Call: Call;
|
||||
'Option<Call>': Option<Call>;
|
||||
'Vec<Call>': Vec<Call>;
|
||||
CallHash: CallHash;
|
||||
'Option<CallHash>': Option<CallHash>;
|
||||
'Vec<CallHash>': Vec<CallHash>;
|
||||
CallHashOf: CallHashOf;
|
||||
'Option<CallHashOf>': Option<CallHashOf>;
|
||||
'Vec<CallHashOf>': Vec<CallHashOf>;
|
||||
ChangesTrieConfiguration: ChangesTrieConfiguration;
|
||||
'Option<ChangesTrieConfiguration>': Option<ChangesTrieConfiguration>;
|
||||
'Vec<ChangesTrieConfiguration>': Vec<ChangesTrieConfiguration>;
|
||||
@@ -174,12 +228,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
ExtrinsicsWeight: ExtrinsicsWeight;
|
||||
'Option<ExtrinsicsWeight>': Option<ExtrinsicsWeight>;
|
||||
'Vec<ExtrinsicsWeight>': Vec<ExtrinsicsWeight>;
|
||||
Fixed64: Fixed64;
|
||||
'Option<Fixed64>': Option<Fixed64>;
|
||||
'Vec<Fixed64>': Vec<Fixed64>;
|
||||
Fixed128: Fixed128;
|
||||
'Option<Fixed128>': Option<Fixed128>;
|
||||
'Vec<Fixed128>': Vec<Fixed128>;
|
||||
GenericAddress: GenericAddress;
|
||||
'Option<GenericAddress>': Option<GenericAddress>;
|
||||
'Vec<GenericAddress>': Vec<GenericAddress>;
|
||||
H160: H160;
|
||||
'Option<H160>': Option<H160>;
|
||||
'Vec<H160>': Vec<H160>;
|
||||
@@ -225,37 +276,21 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<Moment>': Compact<Moment>;
|
||||
'Option<Moment>': Option<Moment>;
|
||||
'Vec<Moment>': Vec<Moment>;
|
||||
OpaqueCall: OpaqueCall;
|
||||
'Option<OpaqueCall>': Option<OpaqueCall>;
|
||||
'Vec<OpaqueCall>': Vec<OpaqueCall>;
|
||||
Origin: Origin;
|
||||
'Option<Origin>': Option<Origin>;
|
||||
'Vec<Origin>': Vec<Origin>;
|
||||
Pays: Pays;
|
||||
'Option<Pays>': Option<Pays>;
|
||||
'Vec<Pays>': Vec<Pays>;
|
||||
Perbill: Perbill;
|
||||
'Compact<Perbill>': Compact<Perbill>;
|
||||
'Option<Perbill>': Option<Perbill>;
|
||||
'Vec<Perbill>': Vec<Perbill>;
|
||||
Percent: Percent;
|
||||
'Compact<Percent>': Compact<Percent>;
|
||||
'Option<Percent>': Option<Percent>;
|
||||
'Vec<Percent>': Vec<Percent>;
|
||||
Permill: Permill;
|
||||
'Compact<Permill>': Compact<Permill>;
|
||||
'Option<Permill>': Option<Permill>;
|
||||
'Vec<Permill>': Vec<Permill>;
|
||||
Perquintill: Perquintill;
|
||||
'Compact<Perquintill>': Compact<Perquintill>;
|
||||
'Option<Perquintill>': Option<Perquintill>;
|
||||
'Vec<Perquintill>': Vec<Perquintill>;
|
||||
Phantom: Phantom;
|
||||
'Option<Phantom>': Option<Phantom>;
|
||||
'Vec<Phantom>': Vec<Phantom>;
|
||||
PhantomData: PhantomData;
|
||||
'Option<PhantomData>': Option<PhantomData>;
|
||||
'Vec<PhantomData>': Vec<PhantomData>;
|
||||
ProxyType: ProxyType;
|
||||
'Option<ProxyType>': Option<ProxyType>;
|
||||
'Vec<ProxyType>': Vec<ProxyType>;
|
||||
Releases: Releases;
|
||||
'Option<Releases>': Option<Releases>;
|
||||
'Vec<Releases>': Vec<Releases>;
|
||||
@@ -419,6 +454,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
ContractCallRequest: ContractCallRequest;
|
||||
'Option<ContractCallRequest>': Option<ContractCallRequest>;
|
||||
'Vec<ContractCallRequest>': Vec<ContractCallRequest>;
|
||||
ContractExecResultSuccessTo255: ContractExecResultSuccessTo255;
|
||||
'Option<ContractExecResultSuccessTo255>': Option<ContractExecResultSuccessTo255>;
|
||||
'Vec<ContractExecResultSuccessTo255>': Vec<ContractExecResultSuccessTo255>;
|
||||
ContractExecResultTo255: ContractExecResultTo255;
|
||||
'Option<ContractExecResultTo255>': Option<ContractExecResultTo255>;
|
||||
'Vec<ContractExecResultTo255>': Vec<ContractExecResultTo255>;
|
||||
ContractExecResultSuccess: ContractExecResultSuccess;
|
||||
'Option<ContractExecResultSuccess>': Option<ContractExecResultSuccess>;
|
||||
'Vec<ContractExecResultSuccess>': Vec<ContractExecResultSuccess>;
|
||||
@@ -778,6 +819,15 @@ declare module '@polkadot/types/types/registry' {
|
||||
Reporter: Reporter;
|
||||
'Option<Reporter>': Option<Reporter>;
|
||||
'Vec<Reporter>': Vec<Reporter>;
|
||||
ProxyDefinition: ProxyDefinition;
|
||||
'Option<ProxyDefinition>': Option<ProxyDefinition>;
|
||||
'Vec<ProxyDefinition>': Vec<ProxyDefinition>;
|
||||
ProxyType: ProxyType;
|
||||
'Option<ProxyType>': Option<ProxyType>;
|
||||
'Vec<ProxyType>': Vec<ProxyType>;
|
||||
ProxyAnnouncement: ProxyAnnouncement;
|
||||
'Option<ProxyAnnouncement>': Option<ProxyAnnouncement>;
|
||||
'Vec<ProxyAnnouncement>': Vec<ProxyAnnouncement>;
|
||||
ActiveRecovery: ActiveRecovery;
|
||||
'Option<ActiveRecovery>': Option<ActiveRecovery>;
|
||||
'Vec<ActiveRecovery>': Vec<ActiveRecovery>;
|
||||
@@ -873,9 +923,15 @@ declare module '@polkadot/types/types/registry' {
|
||||
CompactAssignments: CompactAssignments;
|
||||
'Option<CompactAssignments>': Option<CompactAssignments>;
|
||||
'Vec<CompactAssignments>': Vec<CompactAssignments>;
|
||||
CompactAssignmentsTo257: CompactAssignmentsTo257;
|
||||
'Option<CompactAssignmentsTo257>': Option<CompactAssignmentsTo257>;
|
||||
'Vec<CompactAssignmentsTo257>': Vec<CompactAssignmentsTo257>;
|
||||
CompactScore: CompactScore;
|
||||
'Option<CompactScore>': Option<CompactScore>;
|
||||
'Vec<CompactScore>': Vec<CompactScore>;
|
||||
CompactScoreCompact: CompactScoreCompact;
|
||||
'Option<CompactScoreCompact>': Option<CompactScoreCompact>;
|
||||
'Vec<CompactScoreCompact>': Vec<CompactScoreCompact>;
|
||||
ElectionCompute: ElectionCompute;
|
||||
'Option<ElectionCompute>': Option<ElectionCompute>;
|
||||
'Vec<ElectionCompute>': Vec<ElectionCompute>;
|
||||
@@ -923,13 +979,15 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<NominatorIndex>': Compact<NominatorIndex>;
|
||||
'Option<NominatorIndex>': Option<NominatorIndex>;
|
||||
'Vec<NominatorIndex>': Vec<NominatorIndex>;
|
||||
NominatorIndexCompact: NominatorIndexCompact;
|
||||
'Option<NominatorIndexCompact>': Option<NominatorIndexCompact>;
|
||||
'Vec<NominatorIndexCompact>': Vec<NominatorIndexCompact>;
|
||||
OffchainAccuracy: OffchainAccuracy;
|
||||
'Option<OffchainAccuracy>': Option<OffchainAccuracy>;
|
||||
'Vec<OffchainAccuracy>': Vec<OffchainAccuracy>;
|
||||
PerU16: PerU16;
|
||||
'Compact<PerU16>': Compact<PerU16>;
|
||||
'Option<PerU16>': Option<PerU16>;
|
||||
'Vec<PerU16>': Vec<PerU16>;
|
||||
OffchainAccuracyCompact: OffchainAccuracyCompact;
|
||||
'Option<OffchainAccuracyCompact>': Option<OffchainAccuracyCompact>;
|
||||
'Vec<OffchainAccuracyCompact>': Vec<OffchainAccuracyCompact>;
|
||||
PhragmenScore: PhragmenScore;
|
||||
'Option<PhragmenScore>': Option<PhragmenScore>;
|
||||
'Vec<PhragmenScore>': Vec<PhragmenScore>;
|
||||
@@ -978,6 +1036,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
'Compact<ValidatorIndex>': Compact<ValidatorIndex>;
|
||||
'Option<ValidatorIndex>': Option<ValidatorIndex>;
|
||||
'Vec<ValidatorIndex>': Vec<ValidatorIndex>;
|
||||
ValidatorIndexCompact: ValidatorIndexCompact;
|
||||
'Option<ValidatorIndexCompact>': Option<ValidatorIndexCompact>;
|
||||
'Vec<ValidatorIndexCompact>': Vec<ValidatorIndexCompact>;
|
||||
ValidatorPrefs: ValidatorPrefs;
|
||||
'Option<ValidatorPrefs>': Option<ValidatorPrefs>;
|
||||
'Vec<ValidatorPrefs>': Vec<ValidatorPrefs>;
|
||||
@@ -1127,9 +1188,6 @@ declare module '@polkadot/types/types/registry' {
|
||||
Multiplier: Multiplier;
|
||||
'Option<Multiplier>': Option<Multiplier>;
|
||||
'Vec<Multiplier>': Vec<Multiplier>;
|
||||
CallHash: CallHash;
|
||||
'Option<CallHash>': Option<CallHash>;
|
||||
'Vec<CallHash>': Vec<CallHash>;
|
||||
Multisig: Multisig;
|
||||
'Option<Multisig>': Option<Multisig>;
|
||||
'Vec<Multisig>': Vec<Multisig>;
|
||||
@@ -1154,6 +1212,12 @@ declare module '@polkadot/types/types/registry' {
|
||||
StatementKind: StatementKind;
|
||||
'Option<StatementKind>': Option<StatementKind>;
|
||||
'Vec<StatementKind>': Vec<StatementKind>;
|
||||
ParachainProposal: ParachainProposal;
|
||||
'Option<ParachainProposal>': Option<ParachainProposal>;
|
||||
'Vec<ParachainProposal>': Vec<ParachainProposal>;
|
||||
RegisteredParachainInfo: RegisteredParachainInfo;
|
||||
'Option<RegisteredParachainInfo>': Option<RegisteredParachainInfo>;
|
||||
'Vec<RegisteredParachainInfo>': Vec<RegisteredParachainInfo>;
|
||||
AbridgedCandidateReceipt: AbridgedCandidateReceipt;
|
||||
'Option<AbridgedCandidateReceipt>': Option<AbridgedCandidateReceipt>;
|
||||
'Vec<AbridgedCandidateReceipt>': Vec<AbridgedCandidateReceipt>;
|
||||
@@ -1228,6 +1292,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
ParaScheduling: ParaScheduling;
|
||||
'Option<ParaScheduling>': Option<ParaScheduling>;
|
||||
'Vec<ParaScheduling>': Vec<ParaScheduling>;
|
||||
RelayChainBlockNumber: RelayChainBlockNumber;
|
||||
'Option<RelayChainBlockNumber>': Option<RelayChainBlockNumber>;
|
||||
'Vec<RelayChainBlockNumber>': Vec<RelayChainBlockNumber>;
|
||||
Remark: Remark;
|
||||
'Option<Remark>': Option<Remark>;
|
||||
'Vec<Remark>': Vec<Remark>;
|
||||
@@ -1253,6 +1320,9 @@ declare module '@polkadot/types/types/registry' {
|
||||
UpwardMessage: UpwardMessage;
|
||||
'Option<UpwardMessage>': Option<UpwardMessage>;
|
||||
'Vec<UpwardMessage>': Vec<UpwardMessage>;
|
||||
ValidationFunctionParams: ValidationFunctionParams;
|
||||
'Option<ValidationFunctionParams>': Option<ValidationFunctionParams>;
|
||||
'Vec<ValidationFunctionParams>': Vec<ValidationFunctionParams>;
|
||||
ValidationCode: ValidationCode;
|
||||
'Option<ValidationCode>': Option<ValidationCode>;
|
||||
'Vec<ValidationCode>': Vec<ValidationCode>;
|
||||
@@ -1268,6 +1338,21 @@ declare module '@polkadot/types/types/registry' {
|
||||
WinningDataEntry: WinningDataEntry;
|
||||
'Option<WinningDataEntry>': Option<WinningDataEntry>;
|
||||
'Vec<WinningDataEntry>': Vec<WinningDataEntry>;
|
||||
Approvals: Approvals;
|
||||
'Option<Approvals>': Option<Approvals>;
|
||||
'Vec<Approvals>': Vec<Approvals>;
|
||||
AccountStatus: AccountStatus;
|
||||
'Option<AccountStatus>': Option<AccountStatus>;
|
||||
'Vec<AccountStatus>': Vec<AccountStatus>;
|
||||
AccountValidity: AccountValidity;
|
||||
'Option<AccountValidity>': Option<AccountValidity>;
|
||||
'Vec<AccountValidity>': Vec<AccountValidity>;
|
||||
EthereumAccountId: EthereumAccountId;
|
||||
'Option<EthereumAccountId>': Option<EthereumAccountId>;
|
||||
'Vec<EthereumAccountId>': Vec<EthereumAccountId>;
|
||||
EthereumLookupSource: EthereumLookupSource;
|
||||
'Option<EthereumLookupSource>': Option<EthereumLookupSource>;
|
||||
'Vec<EthereumLookupSource>': Vec<EthereumLookupSource>;
|
||||
CallMetadataV0: CallMetadataV0;
|
||||
'Option<CallMetadataV0>': Option<CallMetadataV0>;
|
||||
'Vec<CallMetadataV0>': Vec<CallMetadataV0>;
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from './Compact';
|
||||
import Raw from './Raw';
|
||||
@@ -41,7 +40,7 @@ export default abstract class AbstractArray<T extends Codec> extends Array<T> im
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,7 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyNumber, Codec, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { assert, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import { BN_ZERO, assert, bnToBn, bnToHex, bnToU8a, formatBalance, formatNumber, hexToBn, isHex, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
@@ -77,6 +76,7 @@ export default abstract class AbstractInt extends BN implements Codec {
|
||||
this.#isHexJson = isHexJson;
|
||||
this.#isSigned = isSigned;
|
||||
|
||||
assert(isSigned || this.gte(BN_ZERO), `${this.toRawType()}: Negative number passed to unsigned type`);
|
||||
assert(super.bitLength() <= bitLength, `${this.toRawType()}: Input too large. Found input with ${super.bitLength()} bits, expected ${bitLength}`);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ export default abstract class AbstractInt extends BN implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,7 +161,7 @@ export default abstract class AbstractInt extends BN implements Codec {
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public toHuman (isExpanded?: boolean): any {
|
||||
public toHuman (isExpanded?: boolean): string {
|
||||
// FIXME we need proper expansion here
|
||||
return this instanceof this.registry.createClass('Balance')
|
||||
? this.isMax()
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Constructor, Codec, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { isHex, hexToU8a, isU8a, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from './Compact';
|
||||
import Raw from './Raw';
|
||||
@@ -117,7 +116,7 @@ export default class BTreeSet<V extends Codec = Codec> extends Set<V> implements
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +170,7 @@ export default class BTreeSet<V extends Codec = Codec> extends Set<V> implements
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return `BTreeSet<${new this.#ValClass(this.registry).toRawType()}>`;
|
||||
return `BTreeSet<${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, BareOpts, Codec, Registry } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
/**
|
||||
@@ -34,7 +32,7 @@ export default abstract class Base<T extends Codec> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyNumber, Codec, Constructor, ICompact, InterfaceTypes, Registry } from '../types';
|
||||
import { H256 } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, AnyNumber, Codec, Constructor, ICompact, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { compactAddLength, compactFromU8a, compactStripLength, compactToU8a, isBigInt, isBn, isNumber, isString } from '@polkadot/util';
|
||||
@@ -10,7 +11,7 @@ import { DEFAULT_BITLENGTH } from '@polkadot/util/compact/defaults';
|
||||
|
||||
import typeToConstructor from './utils/typeToConstructor';
|
||||
import { UIntBitLength } from './AbstractInt';
|
||||
import Base from './Base';
|
||||
import Raw from './Raw';
|
||||
|
||||
export interface CompactEncodable extends Codec {
|
||||
bitLength (): number;
|
||||
@@ -26,11 +27,17 @@ export interface CompactEncodable extends Codec {
|
||||
* used by other types to add length-prefixed encoding, or in the case of wrapped types, taking
|
||||
* a number and making the compact representation thereof
|
||||
*/
|
||||
export default class Compact<T extends CompactEncodable> extends Base<T> implements ICompact<T> {
|
||||
export default class Compact<T extends CompactEncodable> implements ICompact<T> {
|
||||
public readonly registry: Registry;
|
||||
|
||||
readonly #Type: Constructor<T>;
|
||||
|
||||
readonly #raw: T;
|
||||
|
||||
constructor (registry: Registry, Type: Constructor<T> | keyof InterfaceTypes, value: Compact<T> | AnyNumber = 0) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
super(registry, Compact.decodeCompact<T>(registry, typeToConstructor(registry, Type), value));
|
||||
this.registry = registry;
|
||||
this.#Type = typeToConstructor(registry, Type);
|
||||
this.#raw = Compact.decodeCompact<T>(registry, this.#Type, value) as T;
|
||||
}
|
||||
|
||||
public static with<T extends CompactEncodable> (Type: Constructor<T> | keyof InterfaceTypes): Constructor<Compact<T>> {
|
||||
@@ -61,7 +68,7 @@ export default class Compact<T extends CompactEncodable> extends Base<T> impleme
|
||||
/** @internal */
|
||||
public static decodeCompact<T extends CompactEncodable> (registry: Registry, Type: Constructor<T>, value: Compact<T> | AnyNumber): CompactEncodable {
|
||||
if (value instanceof Compact) {
|
||||
return new Type(registry, value._raw);
|
||||
return new Type(registry, value.#raw);
|
||||
} else if (isString(value) || isNumber(value) || isBn(value) || isBigInt(value)) {
|
||||
return new Type(registry, value);
|
||||
}
|
||||
@@ -71,20 +78,41 @@ export default class Compact<T extends CompactEncodable> extends Base<T> impleme
|
||||
return new Type(registry, _value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
return this.toU8a().length;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the value is an empty value
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
return this.#raw.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the number of bits in the value
|
||||
*/
|
||||
public bitLength (): number {
|
||||
return this._raw.bitLength();
|
||||
return this.#raw.bitLength();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
public eq (other?: unknown): boolean {
|
||||
return this._raw.eq(
|
||||
return this.#raw.eq(
|
||||
other instanceof Compact
|
||||
? other._raw
|
||||
? other.#raw
|
||||
: other
|
||||
);
|
||||
}
|
||||
@@ -93,21 +121,49 @@ export default class Compact<T extends CompactEncodable> extends Base<T> impleme
|
||||
* @description Returns the BN representation of the number
|
||||
*/
|
||||
public toBn (): BN {
|
||||
return this._raw.toBn();
|
||||
return this.#raw.toBn();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a hex string representation of the value. isLe returns a LE (number-only) representation
|
||||
*/
|
||||
public toHex (isLe?: boolean): string {
|
||||
return this.#raw.toHex(isLe);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (isExtended?: boolean): AnyJson {
|
||||
return this.#raw.toHuman(isExtended);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): AnyJson {
|
||||
return this.#raw.toJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the number representation for the value
|
||||
*/
|
||||
public toNumber (): number {
|
||||
return this._raw.toNumber();
|
||||
return this.#raw.toNumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return `Compact<${this._raw.toRawType()}>`;
|
||||
return `Compact<${this.registry.getClassName(this.#Type) || this.#raw.toRawType()}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
return this.#raw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,13 +172,13 @@ export default class Compact<T extends CompactEncodable> extends Base<T> impleme
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
return Compact.encodeU8a(this._raw.toBn());
|
||||
return Compact.encodeU8a(this.#raw.toBn());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the embedded [[UInt]] or [[Moment]] value
|
||||
*/
|
||||
public unwrap (): T {
|
||||
return this._raw;
|
||||
return this.#raw;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import { AnyNumber, Codec, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { bnToBn, bnToHex, bnToU8a, isString, isU8a, u8aToBn } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { UIntBitLength } from './AbstractInt';
|
||||
|
||||
@@ -58,7 +57,7 @@ export default class CodecDate extends Date implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return this.registry.createType('H256', blake2AsU8a(this.toU8a(), 256));
|
||||
return this.registry.createType('H256', this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { H256 } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { assert, hexToU8a, isHex, isNumber, isObject, isString, isU8a, isUndefined, stringCamelCase, stringUpperFirst, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Null from '../primitive/Null';
|
||||
import { mapToTypeMap } from './utils';
|
||||
import Base from './Base';
|
||||
import Raw from './Raw';
|
||||
import Struct from './Struct';
|
||||
|
||||
// export interface, this is used in Enum.with, so required as public by TS
|
||||
@@ -114,25 +115,29 @@ function decodeEnum (registry: Registry, def: TypesDef, value?: any, index?: num
|
||||
// TODO:
|
||||
// - As per Enum, actually use TS enum
|
||||
// - It should rather probably extend Enum instead of copying code
|
||||
export default class Enum extends Base<Codec> {
|
||||
private _def: TypesDef;
|
||||
export default class Enum implements Codec {
|
||||
public readonly registry: Registry;
|
||||
|
||||
private _index: number;
|
||||
readonly #def: TypesDef;
|
||||
|
||||
private _indexes: number[];
|
||||
readonly #index: number;
|
||||
|
||||
private _isBasic: boolean;
|
||||
readonly #indexes: number[];
|
||||
|
||||
readonly #isBasic: boolean;
|
||||
|
||||
readonly #raw: Codec;
|
||||
|
||||
constructor (registry: Registry, def: Record<string, keyof InterfaceTypes | Constructor> | string[], value?: unknown, index?: number) {
|
||||
const defInfo = extractDef(registry, def);
|
||||
const decoded = decodeEnum(registry, defInfo.def, value, index);
|
||||
|
||||
super(registry, decoded.value);
|
||||
|
||||
this._def = defInfo.def;
|
||||
this._isBasic = defInfo.isBasic;
|
||||
this._indexes = Object.keys(defInfo.def).map((_, index): number => index);
|
||||
this._index = this._indexes.indexOf(decoded.index) || 0;
|
||||
this.registry = registry;
|
||||
this.#def = defInfo.def;
|
||||
this.#isBasic = defInfo.isBasic;
|
||||
this.#indexes = Object.keys(defInfo.def).map((_, index): number => index);
|
||||
this.#index = this.#indexes.indexOf(decoded.index) || 0;
|
||||
this.#raw = decoded.value;
|
||||
}
|
||||
|
||||
public static with (Types: Record<string, keyof InterfaceTypes | Constructor> | string[]): EnumConstructor<Enum> {
|
||||
@@ -140,7 +145,7 @@ export default class Enum extends Base<Codec> {
|
||||
constructor (registry: Registry, value?: unknown, index?: number) {
|
||||
super(registry, Types, value, index);
|
||||
|
||||
Object.keys(this._def).forEach((_key): void => {
|
||||
Object.keys(this.#def).forEach((_key): void => {
|
||||
const name = stringUpperFirst(stringCamelCase(_key.replace(' ', '_')));
|
||||
const askey = `as${name}`;
|
||||
const iskey = `is${name}`;
|
||||
@@ -175,21 +180,35 @@ export default class Enum extends Base<Codec> {
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
return 1 + this._raw.encodedLength;
|
||||
return 1 + this.#raw.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The index of the metadata value
|
||||
*/
|
||||
public get index (): number {
|
||||
return this._index;
|
||||
return this.#index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description true if this is a basic enum (no values)
|
||||
*/
|
||||
public get isBasic (): boolean {
|
||||
return this._isBasic;
|
||||
return this.#isBasic;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Checks if the value is an empty value
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
return this.#raw.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,35 +222,35 @@ export default class Enum extends Base<Codec> {
|
||||
* @description Checks if the Enum points to a [[Null]] type (deprecated, use isNone)
|
||||
*/
|
||||
public get isNull (): boolean {
|
||||
return this._raw instanceof Null;
|
||||
return this.#raw instanceof Null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The available keys for this enum
|
||||
*/
|
||||
public get defEntries (): string[] {
|
||||
return Object.keys(this._def);
|
||||
return Object.keys(this.#def);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The available keys for this enum
|
||||
*/
|
||||
public get defKeys (): string[] {
|
||||
return Object.keys(this._def);
|
||||
return Object.keys(this.#def);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The name of the type this enum value represents
|
||||
*/
|
||||
public get type (): string {
|
||||
return this.defKeys[this._index];
|
||||
return this.defKeys[this.#index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The value of the enum
|
||||
*/
|
||||
public get value (): Codec {
|
||||
return this._raw;
|
||||
return this.#raw;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +260,7 @@ export default class Enum extends Base<Codec> {
|
||||
// cater for the case where we only pass the enum index
|
||||
if (isNumber(other)) {
|
||||
return this.toNumber() === other;
|
||||
} else if (this._isBasic && isString(other)) {
|
||||
} else if (this.#isBasic && isString(other)) {
|
||||
return this.type === other;
|
||||
} else if (isU8a(other)) {
|
||||
return !this.toU8a().some((entry, index): boolean => entry !== other[index]);
|
||||
@@ -268,34 +287,34 @@ export default class Enum extends Base<Codec> {
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (isExtended?: boolean): AnyJson {
|
||||
return this._isBasic
|
||||
return this.#isBasic
|
||||
? this.type
|
||||
: { [this.type]: this._raw.toHuman(isExtended) };
|
||||
: { [this.type]: this.#raw.toHuman(isExtended) };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): AnyJson {
|
||||
return this._isBasic
|
||||
return this.#isBasic
|
||||
? this.type
|
||||
: { [this.type]: this._raw.toJSON() };
|
||||
: { [this.type]: this.#raw.toJSON() };
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the number representation for the value
|
||||
*/
|
||||
public toNumber (): number {
|
||||
return this._index;
|
||||
return this.#index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a raw struct representation of the enum types
|
||||
*/
|
||||
protected _toRawStruct (): string[] | Record<string, string> {
|
||||
return this._isBasic
|
||||
return this.#isBasic
|
||||
? this.defKeys
|
||||
: Struct.typesToMap(this.registry, this._def);
|
||||
: Struct.typesToMap(this.registry, this.#def);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,11 +338,11 @@ export default class Enum extends Base<Codec> {
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
const index = this._indexes[this._index];
|
||||
const index = this.#indexes[this.#index];
|
||||
|
||||
return u8aConcat(
|
||||
new Uint8Array([index]),
|
||||
this._raw.toU8a(isBare)
|
||||
this.#raw.toU8a(isBare)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Constructor, Codec, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { isHex, hexToU8a, isObject, isU8a, u8aConcat, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from './Compact';
|
||||
import Raw from './Raw';
|
||||
@@ -126,7 +125,7 @@ export default class CodecMap<K extends Codec = Codec, V extends Codec = Codec>
|
||||
* @description Returns a hash of the value
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,7 +179,7 @@ export default class CodecMap<K extends Codec = Codec, V extends Codec = Codec>
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return `${this.#type}<${new this.#KeyClass(this.registry).toRawType()},${new this.#ValClass(this.registry).toRawType()}>`;
|
||||
return `${this.#type}<${this.registry.getClassName(this.#KeyClass) || new this.#KeyClass(this.registry).toRawType()},${this.registry.getClassName(this.#ValClass) || new this.#ValClass(this.registry).toRawType()}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
import { H256 } from '@polkadot/types/interfaces';
|
||||
import { AnyJson, Codec, Constructor, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { isNull, isU8a, isUndefined, u8aToHex } from '@polkadot/util';
|
||||
|
||||
import Null from '../primitive/Null';
|
||||
import { typeToConstructor } from './utils';
|
||||
import Base from './Base';
|
||||
import Raw from './Raw';
|
||||
|
||||
/** @internal */
|
||||
function decodeOptionU8a (registry: Registry, Type: Constructor, value: Uint8Array): Codec {
|
||||
@@ -48,15 +49,17 @@ function decodeOption (registry: Registry, typeName: Constructor | keyof Interfa
|
||||
* implements that - decodes, checks for optionality and wraps the required structure
|
||||
* with a value if/as required/found.
|
||||
*/
|
||||
export default class Option<T extends Codec> extends Base<T> {
|
||||
export default class Option<T extends Codec> implements Codec {
|
||||
public readonly registry: Registry;
|
||||
|
||||
readonly #Type: Constructor<T>;
|
||||
|
||||
constructor (registry: Registry, typeName: Constructor<T> | keyof InterfaceTypes, value?: unknown) {
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
super(registry, decodeOption(registry, typeName, value));
|
||||
readonly #raw: T;
|
||||
|
||||
constructor (registry: Registry, typeName: Constructor<T> | keyof InterfaceTypes, value?: unknown) {
|
||||
this.registry = registry;
|
||||
this.#Type = typeToConstructor(registry, typeName);
|
||||
this.#raw = decodeOption(registry, typeName, value) as T;
|
||||
}
|
||||
|
||||
public static with<O extends Codec> (Type: Constructor<O> | keyof InterfaceTypes): Constructor<Option<O>> {
|
||||
@@ -72,7 +75,14 @@ export default class Option<T extends Codec> extends Base<T> {
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
// boolean byte (has value, doesn't have) along with wrapped length
|
||||
return 1 + this._raw.encodedLength;
|
||||
return 1 + this.#raw.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +96,7 @@ export default class Option<T extends Codec> extends Base<T> {
|
||||
* @description Checks if the Option has no value
|
||||
*/
|
||||
public get isNone (): boolean {
|
||||
return this._raw instanceof Null;
|
||||
return this.#raw instanceof Null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -100,7 +110,7 @@ export default class Option<T extends Codec> extends Base<T> {
|
||||
* @description The actual value for the Option
|
||||
*/
|
||||
public get value (): Codec {
|
||||
return this._raw;
|
||||
return this.#raw;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -125,31 +135,52 @@ export default class Option<T extends Codec> extends Base<T> {
|
||||
: u8aToHex(this.toU8a().subarray(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (isExtended?: boolean): AnyJson {
|
||||
return this.#raw.toHuman(isExtended);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): AnyJson {
|
||||
return this.#raw.toJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (isBare?: boolean): string {
|
||||
const wrapped = new this.#Type(this.registry).toRawType();
|
||||
const wrapped = this.registry.getClassName(this.#Type) || new this.#Type(this.registry).toRawType();
|
||||
|
||||
return isBare
|
||||
? wrapped
|
||||
: `Option<${wrapped}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
return this.#raw.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
if (isBare) {
|
||||
return this._raw.toU8a(true);
|
||||
return this.#raw.toU8a(true);
|
||||
}
|
||||
|
||||
const u8a = new Uint8Array(this.encodedLength);
|
||||
|
||||
if (this.isSome) {
|
||||
u8a.set([1]);
|
||||
u8a.set(this._raw.toU8a(), 1);
|
||||
u8a.set(this.#raw.toU8a(), 1);
|
||||
}
|
||||
|
||||
return u8a;
|
||||
@@ -163,7 +194,7 @@ export default class Option<T extends Codec> extends Base<T> {
|
||||
throw new Error('Option: unwrapping a None value');
|
||||
}
|
||||
|
||||
return this._raw;
|
||||
return this.#raw;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,7 @@ const testEncode = (to: CodecTo, expected: any): void =>
|
||||
expect(e[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
describe('U8a', (): void => {
|
||||
describe('Raw', (): void => {
|
||||
let u8a: Raw;
|
||||
|
||||
beforeEach((): void => {
|
||||
@@ -74,5 +74,21 @@ describe('U8a', (): void => {
|
||||
it('compares against hex inputs', (): void => {
|
||||
expect(u8a.eq('0x0102030405')).toBe(true);
|
||||
});
|
||||
|
||||
it('has valid isAscii', (): void => {
|
||||
expect(u8a.isAscii).toBe(false);
|
||||
expect(new Raw(registry, '0x2021222324').isAscii).toBe(true);
|
||||
});
|
||||
|
||||
it('has valid toUtf8', (): void => {
|
||||
expect(new Raw(registry, 'Приветствую, ми').toUtf8()).toEqual('Приветствую, ми');
|
||||
expect(new Raw(registry, '0xe4bda0e5a5bd').toUtf8()).toEqual('你好');
|
||||
});
|
||||
|
||||
it('throws on invalid utf8', (): void => {
|
||||
expect(
|
||||
() => new Raw(registry, '0x7f07b1f87709608bee603bbc79a0dfc29cd315c1351a83aa31adf7458d7d3003').toUtf8()
|
||||
).toThrow(/The character sequence is not a valid Utf8 string/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, AnyU8a, IU8a, Registry } from '../types';
|
||||
|
||||
import { isU8a, isUndefined, u8aToHex, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import { assert, isAscii, isU8a, isUndefined, isUtf8, u8aToHex, u8aToString, u8aToU8a } from '@polkadot/util';
|
||||
|
||||
/** @internal */
|
||||
function decodeU8a (value?: any): Uint8Array {
|
||||
@@ -46,14 +45,28 @@ export default class Raw extends Uint8Array implements IU8a {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the wrapped value contains only ASCII printable characters
|
||||
*/
|
||||
public get isAscii (): boolean {
|
||||
return isAscii(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the type wraps an empty/default all-0 value
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
return !this.length || isUndefined(this.find((value): boolean => !!value));
|
||||
return !this.length || isUndefined(this.find((value) => !!value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns true if the wrapped value contains only utf8 characters
|
||||
*/
|
||||
public get isUtf8 (): boolean {
|
||||
return isUtf8(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,7 +90,7 @@ export default class Raw extends Uint8Array implements IU8a {
|
||||
public eq (other?: unknown): boolean {
|
||||
if (other instanceof Uint8Array) {
|
||||
return (this.length === other.length) &&
|
||||
!this.some((value, index): boolean => value !== other[index]);
|
||||
!this.some((value, index) => value !== other[index]);
|
||||
}
|
||||
|
||||
return this.eq(decodeU8a(other));
|
||||
@@ -103,7 +116,9 @@ export default class Raw extends Uint8Array implements IU8a {
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): AnyJson {
|
||||
return this.toJSON();
|
||||
return this.isAscii
|
||||
? this.toUtf8()
|
||||
: this.toJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -135,4 +150,13 @@ export default class Raw extends Uint8Array implements IU8a {
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
return Uint8Array.from(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the wrapped data as a UTF-8 string
|
||||
*/
|
||||
public toUtf8 (): string {
|
||||
assert(this.isUtf8, 'The character sequence is not a valid Utf8 string');
|
||||
|
||||
return u8aToString(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,6 @@ describe('Result', (): void => {
|
||||
});
|
||||
|
||||
it('returns a proper raw typedef rom a built-in', (): void => {
|
||||
expect(registry.createType('DispatchResult').toRawType()).toEqual('Result<(),{"_enum":{"Other":"Null","CannotLookup":"Null","BadOrigin":"Null","Module":"{\\"index\\":\\"u8\\",\\"error\\":\\"u8\\"}"}}>');
|
||||
expect(registry.createType('DispatchResult').toRawType()).toEqual('Result<(),DispatchError>');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,7 +50,7 @@ export default class Result<O extends Codec, E extends Codec> extends Enum {
|
||||
* @description Checks if the Result has no value
|
||||
*/
|
||||
public get isEmpty (): boolean {
|
||||
return this.isOk && this._raw.isEmpty;
|
||||
return this.isOk && this.value.isEmpty;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,6 @@ import { Codec, Constructor, Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { assert, bnToBn, bnToU8a, isBn, isU8a, isNumber, isString, isUndefined, stringCamelCase, stringUpperFirst, u8aToHex, u8aToBn, u8aToU8a } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
import { compareArray } from './utils';
|
||||
@@ -127,7 +126,7 @@ export default class CodecSet extends Set<string> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import AccountId from '../generic/AccountId';
|
||||
import Text from '../primitive/Text';
|
||||
import U32 from '../primitive/U32';
|
||||
import { CodecTo } from '../types';
|
||||
@@ -221,20 +220,20 @@ describe('Struct', (): void => {
|
||||
it('generates sane toRawType', (): void => {
|
||||
expect(
|
||||
new Struct(registry, {
|
||||
accountId: AccountId,
|
||||
accountId: 'AccountId',
|
||||
balanceCompact: registry.createClass('Compact<Balance>'),
|
||||
blockNumber: registry.createClass('BlockNumber'),
|
||||
compactNumber: registry.createClass('Compact<BlockNumber>'),
|
||||
optionNumber: registry.createClass('Option<BlockNumber>'),
|
||||
counter: U32,
|
||||
vector: Vec.with(AccountId)
|
||||
vector: Vec.with('AccountId')
|
||||
}).toRawType()
|
||||
).toEqual(JSON.stringify({
|
||||
accountId: 'AccountId',
|
||||
balanceCompact: 'Compact<Balance>', // Override in Uint
|
||||
blockNumber: 'u32',
|
||||
compactNumber: 'Compact<u32>',
|
||||
optionNumber: 'Option<u32>',
|
||||
blockNumber: 'BlockNumber',
|
||||
compactNumber: 'Compact<BlockNumber>',
|
||||
optionNumber: 'Option<BlockNumber>',
|
||||
counter: 'u32',
|
||||
vector: 'Vec<AccountId>'
|
||||
}));
|
||||
@@ -242,7 +241,7 @@ describe('Struct', (): void => {
|
||||
|
||||
it('generates sane toRawType (via with)', (): void => {
|
||||
const Type = Struct.with({
|
||||
accountId: AccountId,
|
||||
accountId: 'AccountId',
|
||||
balance: registry.createClass('Balance')
|
||||
});
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, BareOpts, Codec, Constructor, ConstructorDef, InterfaceTypes, Registry } from '../types';
|
||||
|
||||
import { hexToU8a, isBoolean, isFunction, isHex, isObject, isU8a, isUndefined, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
import { compareMap, decodeU8a, mapToTypeMap } from './utils';
|
||||
@@ -198,7 +197,7 @@ export default class Struct<
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,11 +266,11 @@ export default class Struct<
|
||||
}
|
||||
|
||||
public static typesToMap (registry: Registry, Types: Record<string, Constructor>): Record<string, string> {
|
||||
return Object.entries(Types).reduce((result, [key, Type]): Record<string, string> => {
|
||||
result[key] = new Type(registry).toRawType();
|
||||
return Object.entries(Types).reduce((result: Record<string, string>, [key, Type]): Record<string, string> => {
|
||||
result[key] = registry.getClassName(Type) || new Type(registry).toRawType();
|
||||
|
||||
return result;
|
||||
}, {} as Record<string, string>);
|
||||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import { H256 } from '../interfaces/runtime';
|
||||
import { AnyJson, Codec, Registry } from '../types';
|
||||
|
||||
import { isUndefined } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from './Raw';
|
||||
|
||||
@@ -61,7 +60,7 @@ export default class StructAny extends Map<string, any> implements Codec {
|
||||
* @description returns a hash of the contents
|
||||
*/
|
||||
public get hash (): H256 {
|
||||
return new Raw(this.registry, blake2AsU8a(this.toU8a(), 256));
|
||||
return new Raw(this.registry, this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -131,14 +131,14 @@ describe('Tuple', (): void => {
|
||||
it('generates sane value with array types', (): void => {
|
||||
expect(
|
||||
new Tuple(registry, [U128, registry.createClass('BlockNumber')]).toRawType()
|
||||
).toEqual('(u128,u32)');
|
||||
).toEqual('(u128,BlockNumber)');
|
||||
});
|
||||
|
||||
it('generates sane value with object types', (): void => {
|
||||
expect(
|
||||
// eslint-disable-next-line sort-keys
|
||||
new Tuple(registry, { number: U128, blockNumber: registry.createClass('BlockNumber') }).toRawType()
|
||||
).toEqual('(u128,u32)');
|
||||
).toEqual('(u128,BlockNumber)');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -101,7 +101,9 @@ export default class Tuple extends AbstractArray<Codec> {
|
||||
Array.isArray(this._Types)
|
||||
? this._Types
|
||||
: Object.values(this._Types)
|
||||
).map((Type): string => new Type(this.registry).toRawType());
|
||||
).map((Type) =>
|
||||
this.registry.getClassName(Type) || new Type(this.registry).toRawType()
|
||||
);
|
||||
|
||||
return `(${types.join(',')})`;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,12 @@ describe('UInt', (): void => {
|
||||
).toThrow('u32: Input too large. Found input with 164 bits, expected 32');
|
||||
});
|
||||
|
||||
it('fails on negative numbers', (): void => {
|
||||
expect(
|
||||
(): UInt => new UInt(registry, -123, 32)
|
||||
).toThrow('u32: Negative number passed to unsigned type');
|
||||
});
|
||||
|
||||
it('allows for construction via BigInt', (): void => {
|
||||
expect(
|
||||
new UInt(registry, 123456789123456789123456789n, 128).toHuman()
|
||||
|
||||
@@ -92,6 +92,6 @@ export default class Vec<T extends Codec> extends AbstractArray<T> {
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return `Vec<${new this._Type(this.registry).toRawType()}>`;
|
||||
return `Vec<${this.registry.getClassName(this._Type) || new this._Type(this.registry).toRawType()}>`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ const infoMapping: Record<TypeDefInfo, (registry: Registry, value: TypeDef) => C
|
||||
const Clazz = Struct.with({ previous: type, next: type } as any);
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||
ClassOf.prototype.toRawType = function (): string {
|
||||
Clazz.prototype.toRawType = function (): string {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call
|
||||
return `Linkage<${this.next.toRawType(true)}>`;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
import { TypeDef, TypeDefInfo } from './types';
|
||||
|
||||
import { getTypeDef } from '.';
|
||||
import { TypeRegistry, getTypeDef } from '.';
|
||||
|
||||
describe('getTypeDef', (): void => {
|
||||
it('does not allow invalid tuples, end )', (): void => {
|
||||
@@ -290,4 +290,32 @@ describe('getTypeDef', (): void => {
|
||||
type: '[[u8;32];3]'
|
||||
});
|
||||
});
|
||||
|
||||
it('creates recursive structures', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
registry.register({
|
||||
Recursive: {
|
||||
data: 'Vec<Recursive>'
|
||||
}
|
||||
});
|
||||
|
||||
const raw = registry.createType('Recursive' as 'u32').toRawType();
|
||||
|
||||
expect(
|
||||
getTypeDef(raw)
|
||||
).toEqual({
|
||||
info: TypeDefInfo.Struct,
|
||||
sub: [{
|
||||
info: TypeDefInfo.Vec,
|
||||
name: 'data',
|
||||
sub: {
|
||||
info: TypeDefInfo.Plain,
|
||||
type: 'Recursive'
|
||||
},
|
||||
type: 'Vec<Recursive>'
|
||||
}],
|
||||
type: '{"data":"Vec<Recursive>"}'
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,10 +9,17 @@ import { assert } from '@polkadot/util';
|
||||
import sanitize from './sanitize';
|
||||
import { typeSplit } from './typeSplit';
|
||||
|
||||
interface TypeDefOptions {
|
||||
name?: string;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
const MAX_NESTED = 64;
|
||||
|
||||
// decode an enum of either of the following forms
|
||||
// { _enum: ['A', 'B', 'C'] }
|
||||
// { _enum: { A: AccountId, B: Balance, C: u32 } }
|
||||
function _decodeEnum (value: TypeDef, details: string[] | Record<string, string>): TypeDef {
|
||||
function _decodeEnum (value: TypeDef, details: string[] | Record<string, string>, count: number): TypeDef {
|
||||
value.info = TypeDefInfo.Enum;
|
||||
|
||||
// not as pretty, but remain compatible with oo7 for both struct and Array types
|
||||
@@ -24,7 +31,7 @@ function _decodeEnum (value: TypeDef, details: string[] | Record<string, string>
|
||||
}))
|
||||
: Object.entries(details).map(([name, type]): TypeDef =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
getTypeDef(type || 'Null', { name })
|
||||
getTypeDef(type || 'Null', { name }, count)
|
||||
);
|
||||
|
||||
return value;
|
||||
@@ -50,13 +57,13 @@ function _decodeSet (value: TypeDef, details: Record<string, number>): TypeDef {
|
||||
|
||||
// decode a struct, set or enum
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function _decodeStruct (value: TypeDef, type: string, _: string): TypeDef {
|
||||
function _decodeStruct (value: TypeDef, type: string, _: string, count: number): TypeDef {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
||||
const parsed: Record<string, any> = JSON.parse(type);
|
||||
const keys = Object.keys(parsed);
|
||||
|
||||
if (keys.length === 1 && keys[0] === '_enum') {
|
||||
return _decodeEnum(value, parsed[keys[0]]);
|
||||
return _decodeEnum(value, parsed[keys[0]], count);
|
||||
} else if (keys.length === 1 && keys[0] === '_set') {
|
||||
return _decodeSet(value, parsed[keys[0]]);
|
||||
}
|
||||
@@ -66,7 +73,7 @@ function _decodeStruct (value: TypeDef, type: string, _: string): TypeDef {
|
||||
: undefined;
|
||||
value.sub = keys.filter((name) => !['_alias'].includes(name)).map((name): TypeDef =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
getTypeDef(parsed[name], { name })
|
||||
getTypeDef(parsed[name], { name }, count)
|
||||
);
|
||||
|
||||
return value;
|
||||
@@ -74,7 +81,7 @@ function _decodeStruct (value: TypeDef, type: string, _: string): TypeDef {
|
||||
|
||||
// decode a fixed vector, e.g. [u8;32]
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function _decodeFixedVec (value: TypeDef, type: string, _: string): TypeDef {
|
||||
function _decodeFixedVec (value: TypeDef, type: string, _: string, count: number): TypeDef {
|
||||
const [vecType, strLength, displayName] = type.substr(1, type.length - 2).split(';');
|
||||
const length = parseInt(strLength.trim(), 10);
|
||||
|
||||
@@ -84,18 +91,18 @@ function _decodeFixedVec (value: TypeDef, type: string, _: string): TypeDef {
|
||||
value.displayName = displayName;
|
||||
value.length = length;
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
value.sub = getTypeDef(vecType);
|
||||
value.sub = getTypeDef(vecType, {}, count);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
// decode a tuple
|
||||
function _decodeTuple (value: TypeDef, _: string, subType: string): TypeDef {
|
||||
function _decodeTuple (value: TypeDef, _: string, subType: string, count: number): TypeDef {
|
||||
value.sub = subType.length === 0
|
||||
? []
|
||||
: typeSplit(subType).map((inner): TypeDef =>
|
||||
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
||||
getTypeDef(inner)
|
||||
getTypeDef(inner, {}, count)
|
||||
);
|
||||
|
||||
return value;
|
||||
@@ -103,7 +110,7 @@ function _decodeTuple (value: TypeDef, _: string, subType: string): TypeDef {
|
||||
|
||||
// decode a Int/UInt<bitLength[, name]>
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
function _decodeInt (value: TypeDef, type: string, _: string, clazz: 'Int' | 'UInt' = 'Int'): TypeDef {
|
||||
function _decodeAnyInt (value: TypeDef, type: string, _: string, clazz: 'Int' | 'UInt'): TypeDef {
|
||||
const [strLength, displayName] = type.substr(clazz.length + 1, type.length - clazz.length - 1 - 1).split(',');
|
||||
const length = parseInt(strLength.trim(), 10);
|
||||
|
||||
@@ -116,8 +123,12 @@ function _decodeInt (value: TypeDef, type: string, _: string, clazz: 'Int' | 'UI
|
||||
return value;
|
||||
}
|
||||
|
||||
function _decodeInt (value: TypeDef, type: string, subType: string): TypeDef {
|
||||
return _decodeAnyInt(value, type, subType, 'Int');
|
||||
}
|
||||
|
||||
function _decodeUInt (value: TypeDef, type: string, subType: string): TypeDef {
|
||||
return _decodeInt(value, type, subType, 'UInt');
|
||||
return _decodeAnyInt(value, type, subType, 'UInt');
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@@ -139,7 +150,7 @@ function hasWrapper (type: string, [start, end]: [string, string, TypeDefInfo, a
|
||||
return true;
|
||||
}
|
||||
|
||||
const nestedExtraction: [string, string, TypeDefInfo, (value: TypeDef, type: string, subType: string) => TypeDef][] = [
|
||||
const nestedExtraction: [string, string, TypeDefInfo, (value: TypeDef, type: string, subType: string, count: number) => TypeDef][] = [
|
||||
['[', ']', TypeDefInfo.VecFixed, _decodeFixedVec],
|
||||
['{', '}', TypeDefInfo.Struct, _decodeStruct],
|
||||
['(', ')', TypeDefInfo.Tuple, _decodeTuple],
|
||||
@@ -164,15 +175,17 @@ function extractSubType (type: string, [start, end]: [string, string, TypeDefInf
|
||||
return type.substr(start.length, type.length - start.length - end.length);
|
||||
}
|
||||
|
||||
interface TypeDefOptions {
|
||||
name?: string;
|
||||
displayName?: string;
|
||||
}
|
||||
|
||||
export function getTypeDef (_type: string, { displayName, name }: TypeDefOptions = {}): TypeDef {
|
||||
export function getTypeDef (_type: string, { displayName, name }: TypeDefOptions = {}, count = 0): TypeDef {
|
||||
// create the type via Type, allowing types to be sanitized
|
||||
const type = sanitize(_type);
|
||||
const value: TypeDef = { displayName, info: TypeDefInfo.Plain, name, type };
|
||||
|
||||
if (++count === MAX_NESTED) {
|
||||
console.warn('getTypeDef: Maximum nested limit reached');
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
const nested = nestedExtraction.find((nested): boolean =>
|
||||
hasWrapper(type, nested)
|
||||
);
|
||||
@@ -180,7 +193,7 @@ export function getTypeDef (_type: string, { displayName, name }: TypeDefOptions
|
||||
if (nested) {
|
||||
value.info = nested[2];
|
||||
|
||||
return nested[3](value, type, extractSubType(type, nested));
|
||||
return nested[3](value, type, extractSubType(type, nested), count);
|
||||
}
|
||||
|
||||
const wrapped = wrappedExtraction.find((wrapped): boolean =>
|
||||
@@ -189,7 +202,7 @@ export function getTypeDef (_type: string, { displayName, name }: TypeDefOptions
|
||||
|
||||
if (wrapped) {
|
||||
value.info = wrapped[2];
|
||||
value.sub = getTypeDef(extractSubType(type, wrapped));
|
||||
value.sub = getTypeDef(extractSubType(type, wrapped), {}, count);
|
||||
}
|
||||
|
||||
return value;
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
import { Codec, Constructor } from '../types';
|
||||
|
||||
import { isChildClass } from '@polkadot/util';
|
||||
import { isChildClass, u8aToU8a } from '@polkadot/util';
|
||||
import { keccakAsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Struct from '../codec/Struct';
|
||||
import DoNotConstruct from '../primitive/DoNotConstruct';
|
||||
@@ -76,7 +77,35 @@ describe('TypeRegistry', (): void => {
|
||||
expect((first as any).next.unwrap().next.isSome).toBe(false);
|
||||
});
|
||||
|
||||
it('can register cross-referencing types ()', (): void => {
|
||||
it('can register non-embedded recursive types', (): void => {
|
||||
registry.register({
|
||||
Operation: {
|
||||
data: 'OperationData'
|
||||
},
|
||||
OperationData: {
|
||||
ops: 'Vec<Operation>'
|
||||
},
|
||||
Rule: {
|
||||
data: 'RuleData'
|
||||
},
|
||||
RuleData: {
|
||||
ops: 'Vec<Operation>'
|
||||
}
|
||||
});
|
||||
|
||||
expect(registry.hasDef('Rule')).toBe(true);
|
||||
expect(registry.hasClass('Rule')).toBe(false);
|
||||
|
||||
const Rule = registry.getOrThrow('Rule');
|
||||
|
||||
expect(registry.hasClass('Rule')).toBe(true);
|
||||
|
||||
const instance = new Rule(registry);
|
||||
|
||||
expect(instance.toRawType()).toEqual('{"data":"RuleData"}');
|
||||
});
|
||||
|
||||
it('can register cross-referencing types', (): void => {
|
||||
registry.register({
|
||||
A: {
|
||||
next: 'B'
|
||||
@@ -131,4 +160,30 @@ describe('TypeRegistry', (): void => {
|
||||
expect(struct.bar.toString()).toEqual('testing');
|
||||
});
|
||||
});
|
||||
|
||||
it('hashes via blake2 by default', (): void => {
|
||||
expect(
|
||||
registry.hash(u8aToU8a('abc'))
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
|
||||
it('hashes via override hasher', (): void => {
|
||||
registry.setHasher(keccakAsU8a);
|
||||
|
||||
expect(
|
||||
registry.hash(u8aToU8a('test value'))
|
||||
).toEqual(
|
||||
u8aToU8a('0x2d07364b5c231c56ce63d49430e085ea3033c750688ba532b24029124c26ca5e')
|
||||
);
|
||||
|
||||
registry.setHasher();
|
||||
|
||||
expect(
|
||||
registry.hash(u8aToU8a('abc'))
|
||||
).toEqual(
|
||||
new Uint8Array([189, 221, 129, 60, 99, 66, 57, 114, 49, 113, 239, 63, 238, 152, 87, 155, 148, 150, 78, 59, 177, 203, 62, 66, 114, 98, 200, 192, 104, 213, 35, 25])
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import { CallFunction, Codec, Constructor, InterfaceTypes, RegistryError, Regist
|
||||
|
||||
import extrinsicsFromMeta from '@polkadot/metadata/Decorated/extrinsics/fromMetadata';
|
||||
import { assert, formatBalance, isFunction, isString, isU8a, isUndefined, stringCamelCase, u8aToHex } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Raw from '../codec/Raw';
|
||||
import { defaultExtensions, expandExtensionTypes, findUnknownExtensions } from '../extrinsic/signedExtensions';
|
||||
@@ -94,6 +95,8 @@ export class TypeRegistry implements Registry {
|
||||
|
||||
#chainProperties?: ChainProperties;
|
||||
|
||||
#hasher: (data: Uint8Array) => Uint8Array = blake2AsU8a;
|
||||
|
||||
#knownTypes: RegisteredTypes = {};
|
||||
|
||||
#signedExtensions: string[] = defaultExtensions;
|
||||
@@ -225,6 +228,14 @@ export class TypeRegistry implements Registry {
|
||||
return this.#chainProperties;
|
||||
}
|
||||
|
||||
public getClassName (clazz: Constructor): string | undefined {
|
||||
const entry = [...this.#classes.entries()].find(([, test]) => test === clazz);
|
||||
|
||||
return entry
|
||||
? entry[0]
|
||||
: undefined;
|
||||
}
|
||||
|
||||
public getDefinition (name: string): string | undefined {
|
||||
return this.#definitions.get(name);
|
||||
}
|
||||
@@ -263,6 +274,10 @@ export class TypeRegistry implements Registry {
|
||||
return !this.#unknownTypes.get(name) && (this.hasClass(name) || this.hasDef(name));
|
||||
}
|
||||
|
||||
public hash (data: Uint8Array): Uint8Array {
|
||||
return this.#hasher(data);
|
||||
}
|
||||
|
||||
public register (type: Constructor | RegistryTypes): void;
|
||||
|
||||
// eslint-disable-next-line no-dupe-class-members
|
||||
@@ -309,6 +324,10 @@ export class TypeRegistry implements Registry {
|
||||
}
|
||||
}
|
||||
|
||||
setHasher (hasher: (data: Uint8Array) => Uint8Array = blake2AsU8a): void {
|
||||
this.#hasher = hasher;
|
||||
}
|
||||
|
||||
setKnownTypes (knownTypes: RegisteredTypes): void {
|
||||
this.#knownTypes = knownTypes;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import Raw from '../codec/Raw';
|
||||
import AccountId from './AccountId';
|
||||
|
||||
describe('EthereumAccountId', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
describe('defaults', (): void => {
|
||||
const id = registry.createType('EthereumAccountId');
|
||||
|
||||
it('has a 20-byte length', (): void => {
|
||||
expect(id).toHaveLength(20);
|
||||
});
|
||||
|
||||
it('is empty by default', (): void => {
|
||||
expect(id.isEmpty).toBe(true);
|
||||
});
|
||||
|
||||
it('equals the empty address', (): void => {
|
||||
expect(id.eq('0x0000000000000000000000000000000000000000')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decoding', (): void => {
|
||||
const testDecode = (type: string, input: Uint8Array | string | AccountId, expected: string): void =>
|
||||
it(`can decode from ${type}`, (): void => {
|
||||
const a = registry.createType('EthereumAccountId', input);
|
||||
|
||||
expect(a.toString()).toBe(expected);
|
||||
});
|
||||
|
||||
testDecode(
|
||||
'AccountId',
|
||||
registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'),
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testDecode('hex', '0x4119b2e6c3cb618f4f0B93ac77f9Beec7ff02887', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
testDecode(
|
||||
'Raw',
|
||||
new Raw(registry, [
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2
|
||||
]),
|
||||
'0x0102030405060708010201020304050607080102'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array',
|
||||
Uint8Array.from([
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 1, 2
|
||||
]),
|
||||
'0x0102030405060708010201020304050607080102'
|
||||
);
|
||||
});
|
||||
|
||||
describe('encoding', (): void => {
|
||||
const testEncode = (to: 'toHex' | 'toJSON' | 'toString' | 'toU8a', expected: Uint8Array | string, input = '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'): void =>
|
||||
it(`can encode ${to}`, (): void => {
|
||||
const a = registry.createType('EthereumAccountId', input);
|
||||
|
||||
expect(a[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
testEncode('toHex', '0x4119b2e6c3cb618f4f0b93ac77f9beec7ff02887');
|
||||
testEncode('toJSON', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
testEncode('toString', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
testEncode('toString', '0x0000000000000000000000000000000000000000', '0x00');
|
||||
testEncode('toU8a', Uint8Array.from([
|
||||
0x41, 0x19, 0xb2, 0xe6, 0xc3, 0xcb, 0x61, 0x8f, 0x4f, 0x0b,
|
||||
0x93, 0xac, 0x77, 0xf9, 0xbe, 0xec, 0x7f, 0xf0, 0x28, 0x87
|
||||
]));
|
||||
|
||||
it('decodes to a non-empty value', (): void => {
|
||||
expect(registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887').isEmpty).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,75 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AnyString, AnyU8a, Registry } from '../types';
|
||||
|
||||
import { hexToU8a, isHex, isString, isU8a, u8aToU8a } from '@polkadot/util';
|
||||
import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
||||
|
||||
import U8aFixed from '../codec/U8aFixed';
|
||||
|
||||
/** @internal */
|
||||
function decodeAccountId (value: AnyU8a | AnyString): AnyU8a {
|
||||
if (isU8a(value) || Array.isArray(value)) {
|
||||
return u8aToU8a(value);
|
||||
} else if (isHex(value) || isEthereumAddress(value)) {
|
||||
return hexToU8a(value.toString());
|
||||
} else if (isString(value)) {
|
||||
return u8aToU8a((value as string).toString());
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name EthereumAccountId
|
||||
* @description
|
||||
* A wrapper around an Ethereum-compatible AccountId. Since we are dealing with
|
||||
* underlying addresses (20 bytes in length), we extend from U8aFixed which is
|
||||
* just a Uint8Array wrapper with a fixed length.
|
||||
*/
|
||||
export default class AccountId extends U8aFixed {
|
||||
constructor (registry: Registry, value: AnyU8a = new Uint8Array()) {
|
||||
super(registry, decodeAccountId(value), 160);
|
||||
}
|
||||
|
||||
public static encode (value: Uint8Array): string {
|
||||
return ethereumEncode(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Compares the value of the input to see if there is a match
|
||||
*/
|
||||
public eq (other?: unknown): boolean {
|
||||
return super.eq(decodeAccountId(other as AnyU8a));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to to a human-friendly JSON, with additional fields, expansion and formatting of information
|
||||
*/
|
||||
public toHuman (): string {
|
||||
return this.toJSON();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Converts the Object to JSON, typically used for RPC transfers
|
||||
*/
|
||||
public toJSON (): string {
|
||||
return this.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the string representation of the value
|
||||
*/
|
||||
public toString (): string {
|
||||
return AccountId.encode(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return 'AccountId';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { TypeRegistry } from '../create';
|
||||
import AccountIndex from '../generic/AccountIndex';
|
||||
import AccountId from './AccountId';
|
||||
import Address from './LookupSource';
|
||||
|
||||
describe('EthereumLookupSource', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
const testDecode = (type: string, input: Address | AccountId | AccountIndex | number[] | Uint8Array, expected: string): void =>
|
||||
it(`can decode from ${type}`, (): void => {
|
||||
const a = registry.createType('EthereumLookupSource', input);
|
||||
|
||||
expect(a.toString()).toBe(expected);
|
||||
});
|
||||
|
||||
describe('decoding', (): void => {
|
||||
testDecode(
|
||||
'Address',
|
||||
registry.createType('EthereumLookupSource', '0x00a329c0648769a73afac7f9381e08fb43dbea72'),
|
||||
'0x00a329c0648769A73afAc7F9381E08FB43dBEA72'
|
||||
);
|
||||
testDecode(
|
||||
'AccountId',
|
||||
registry.createType('EthereumAccountId', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'),
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (mixed prefixes)',
|
||||
registry.createType('EthereumLookupSource', '2jpAFn'),
|
||||
// NOTE Expected address here is encoded with prefix 42, input above with 68
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (hex)',
|
||||
registry.createType('AccountIndex', '0x0100'),
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 255)',
|
||||
Uint8Array.from([
|
||||
255,
|
||||
0x41, 0x19, 0xb2, 0xe6, 0xc3, 0xcb, 0x61, 0x8f, 0x4f, 0x0b,
|
||||
0x93, 0xac, 0x77, 0xf9, 0xbe, 0xec, 0x7f, 0xf0, 0x28, 0x87
|
||||
]),
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 1 byte)',
|
||||
Uint8Array.from([1]),
|
||||
'F7NZ'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 2 bytes)',
|
||||
Uint8Array.from([0xfc, 0, 1]),
|
||||
'25GUyv'
|
||||
);
|
||||
testDecode(
|
||||
'Uint8Array (with prefix 4 bytes)',
|
||||
Uint8Array.from([0xfd, 17, 18, 19, 20]),
|
||||
'Mwz15xP2'
|
||||
);
|
||||
});
|
||||
|
||||
describe('encoding', (): void => {
|
||||
const testEncode = (to: 'toHex' | 'toString' | 'toU8a', expected: string | Uint8Array): void =>
|
||||
it(`can encode ${to}`, (): void => {
|
||||
const a = registry.createType('EthereumLookupSource', '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887');
|
||||
|
||||
expect(a[to]()).toEqual(expected);
|
||||
});
|
||||
|
||||
testEncode(
|
||||
'toHex',
|
||||
'0xff4119b2e6c3cb618f4f0b93ac77f9beec7ff02887'
|
||||
);
|
||||
testEncode(
|
||||
'toString',
|
||||
'0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887'
|
||||
);
|
||||
testEncode(
|
||||
'toU8a',
|
||||
Uint8Array.from([
|
||||
255,
|
||||
0x41, 0x19, 0xb2, 0xe6, 0xc3, 0xcb, 0x61, 0x8f, 0x4f, 0x0b,
|
||||
0x93, 0xac, 0x77, 0xf9, 0xbe, 0xec, 0x7f, 0xf0, 0x28, 0x87
|
||||
])
|
||||
);
|
||||
});
|
||||
|
||||
describe('utility', (): void => {
|
||||
it('equals on AccountId', (): void => {
|
||||
const addr = '0x4119b2e6c3Cb618F4f0B93ac77f9BeeC7FF02887';
|
||||
|
||||
expect(registry.createType('EthereumLookupSource', addr).eq(addr)).toBe(true);
|
||||
});
|
||||
|
||||
it('equals on AccountIndex', (): void => {
|
||||
// see the test below - these are equivalent (with different prefix encoding)
|
||||
expect(registry.createType('EthereumLookupSource', '2jpAFn').eq('25GUyv')).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,124 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Registry } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import { isBn, isHex, isNumber, isU8a, u8aConcat, u8aToHex, u8aToU8a, u8aToBn } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
import Base from '../codec/Base';
|
||||
import AccountIndex from '../generic/AccountIndex';
|
||||
import EthereumAccountId from './AccountId';
|
||||
|
||||
type AnyAddress = BN | LookupSource | EthereumAccountId | AccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
/** @internal */
|
||||
function decodeString (registry: Registry, value: string): EthereumAccountId | AccountIndex {
|
||||
const decoded = decodeAddress(value);
|
||||
|
||||
return decoded.length === 20
|
||||
? registry.createType('EthereumAccountId', decoded)
|
||||
: registry.createType('AccountIndex', u8aToBn(decoded, true));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
function decodeU8a (registry: Registry, value: Uint8Array): EthereumAccountId | AccountIndex {
|
||||
// This allows us to instantiate an address with a raw publicKey. Do this first before
|
||||
// we checking the first byte, otherwise we may split an already-existent valid address
|
||||
if (value.length === 20) {
|
||||
return registry.createType('EthereumAccountId', value);
|
||||
} else if (value[0] === 0xff) {
|
||||
return registry.createType('EthereumAccountId', value.subarray(1));
|
||||
}
|
||||
|
||||
const [offset, length] = AccountIndex.readLength(value);
|
||||
|
||||
return registry.createType('AccountIndex', u8aToBn(value.subarray(offset, offset + length), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @name LookupSource
|
||||
* @description
|
||||
* A wrapper around an EthereumAccountId and/or AccountIndex that is encoded with a prefix.
|
||||
* Since we are dealing with underlying publicKeys (or shorter encoded addresses),
|
||||
* we extend from Base with an AccountId/AccountIndex wrapper. Basically the Address
|
||||
* is encoded as `[ <prefix-byte>, ...publicKey/...bytes ]` as per spec
|
||||
*/
|
||||
export default class LookupSource extends Base<EthereumAccountId | AccountIndex> {
|
||||
constructor (registry: Registry, value: AnyAddress = new Uint8Array()) {
|
||||
super(registry, LookupSource._decodeAddress(registry, value));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
private static _decodeAddress (registry: Registry, value: AnyAddress): EthereumAccountId | AccountIndex {
|
||||
if (value instanceof EthereumAccountId || value instanceof AccountIndex) {
|
||||
return value;
|
||||
} else if (value instanceof LookupSource) {
|
||||
return value._raw;
|
||||
} else if (isBn(value) || isNumber(value)) {
|
||||
return registry.createType('AccountIndex', value);
|
||||
} else if (Array.isArray(value) || isHex(value) || isU8a(value)) {
|
||||
return decodeU8a(registry, u8aToU8a(value));
|
||||
}
|
||||
|
||||
return decodeString(registry, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the value when encoded as a Uint8Array
|
||||
*/
|
||||
public get encodedLength (): number {
|
||||
const rawLength = this._rawLength;
|
||||
|
||||
return rawLength + (
|
||||
// for 1 byte AccountIndexes, we are not adding a specific prefix
|
||||
rawLength > 1
|
||||
? 1
|
||||
: 0
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description The length of the raw value, either AccountIndex or AccountId
|
||||
*/
|
||||
protected get _rawLength (): number {
|
||||
return this._raw instanceof AccountIndex
|
||||
? AccountIndex.calcLength(this._raw)
|
||||
: this._raw.encodedLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns a hex string representation of the value
|
||||
*/
|
||||
public toHex (): string {
|
||||
return u8aToHex(this.toU8a());
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Returns the base runtime type name for this instance
|
||||
*/
|
||||
public toRawType (): string {
|
||||
return 'Address';
|
||||
}
|
||||
|
||||
/**
|
||||
* @description Encodes the value as a Uint8Array as per the SCALE specifications
|
||||
* @param isBare true when the value has none of the type-specific prefixes (internal)
|
||||
*/
|
||||
public toU8a (isBare?: boolean): Uint8Array {
|
||||
const encoded = this._raw.toU8a().subarray(0, this._rawLength);
|
||||
|
||||
return isBare
|
||||
? encoded
|
||||
: u8aConcat(
|
||||
this._raw instanceof AccountIndex
|
||||
? AccountIndex.writeLength(encoded)
|
||||
: ACCOUNT_ID_PREFIX,
|
||||
encoded
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export { default as GenericEthereumAccountId } from './AccountId';
|
||||
export { default as GenericEthereumLookupSource } from './LookupSource';
|
||||
@@ -3,14 +3,12 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { SignOptions } from '@polkadot/keyring/types';
|
||||
import { IKeyringPair } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
import { IKeyringPair, Registry } from '../types';
|
||||
|
||||
// a helper function for both types of payloads, Raw and metadata-known
|
||||
export function sign (signerPair: IKeyringPair, u8a: Uint8Array, options?: SignOptions): Uint8Array {
|
||||
export function sign (registry: Registry, signerPair: IKeyringPair, u8a: Uint8Array, options?: SignOptions): Uint8Array {
|
||||
const encoded = u8a.length > 256
|
||||
? blake2AsU8a(u8a)
|
||||
? registry.hash(u8a)
|
||||
: u8a;
|
||||
|
||||
return signerPair.sign(encoded, options);
|
||||
|
||||
@@ -67,6 +67,6 @@ export default class ExtrinsicPayloadV1 extends Struct {
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a({ method: true }));
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants';
|
||||
@@ -142,10 +140,7 @@ export default class ExtrinsicSignatureV1 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -69,6 +69,6 @@ export default class ExtrinsicPayloadV2 extends Struct {
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a({ method: true }));
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ import { Address, Balance, Call, Index } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, SignatureOptions } from '../../types';
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
import { EMPTY_U8A, IMMORTAL_ERA } from '../constants';
|
||||
@@ -138,10 +136,7 @@ export default class ExtrinsicSignatureV2 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -88,6 +88,6 @@ export default class ExtrinsicPayloadV3 extends Struct {
|
||||
* @description Sign the payload with the keypair
|
||||
*/
|
||||
public sign (signerPair: IKeyringPair): Uint8Array {
|
||||
return sign(signerPair, this.toU8a({ method: true }));
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { Address, Call } from '../../interfaces/runtime';
|
||||
import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, SignatureOptions } from '../../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import { IMMORTAL_ERA } from '../constants';
|
||||
import ExtrinsicSignatureV2 from '../v2/ExtrinsicSignature';
|
||||
import ExtrinsicPayloadV3 from './ExtrinsicPayload';
|
||||
@@ -48,10 +46,7 @@ export default class ExtrinsicSignatureV3 extends ExtrinsicSignatureV2 {
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('Signature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -91,6 +91,6 @@ export default class ExtrinsicPayloadV4 extends Struct {
|
||||
// to have the length prefix included. This means that the data-as-signed is un-decodable,
|
||||
// but is also doesn't need the extra information, only the pure data (and is not decoded)
|
||||
// ... The same applies to V1..V3, if we have a V5, carry move this comment to latest
|
||||
return sign(signerPair, this.toU8a({ method: true }), { withType: true });
|
||||
return sign(this.registry, signerPair, this.toU8a({ method: true }), { withType: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { ExtrinsicPayloadValue, IExtrinsicSignature, IKeyringPair, Registry, Sig
|
||||
import { ExtrinsicSignatureOptions } from '../types';
|
||||
|
||||
import { u8aConcat } from '@polkadot/util';
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Compact from '../../codec/Compact';
|
||||
import Struct from '../../codec/Struct';
|
||||
@@ -142,10 +141,7 @@ export default class ExtrinsicSignatureV4 extends Struct implements IExtrinsicSi
|
||||
* @description Generate a payload and applies the signature from a keypair
|
||||
*/
|
||||
public sign (method: Call, account: IKeyringPair, options: SignatureOptions): IExtrinsicSignature {
|
||||
const address = account.publicKey.length > 32
|
||||
? blake2AsU8a(account.publicKey, 256)
|
||||
: account.publicKey;
|
||||
const signer = this.registry.createType('Address', address);
|
||||
const signer = this.registry.createType('Address', account.addressRaw);
|
||||
const payload = this.createPayload(method, options);
|
||||
const signature = this.registry.createType('MultiSignature', payload.sign(account));
|
||||
|
||||
|
||||
@@ -24,15 +24,7 @@ describe('Block', (): void => {
|
||||
).toEqual(
|
||||
// each of the containing structures have been stringified on their own
|
||||
JSON.stringify({
|
||||
header: JSON.stringify({
|
||||
parentHash: 'H256',
|
||||
number: 'Compact<u32>',
|
||||
stateRoot: 'H256',
|
||||
extrinsicsRoot: 'H256',
|
||||
digest: JSON.stringify({
|
||||
logs: 'Vec<{"_enum":{"Other":"Bytes","AuthoritiesChange":"Vec<AccountId>","ChangesTrieRoot":"H256","SealV0":"(u64,H512)","Consensus":"(u32,Bytes)","Seal":"(u32,Bytes)","PreRuntime":"(u32,Bytes)"}}>'
|
||||
})
|
||||
}),
|
||||
header: 'Header',
|
||||
extrinsics: 'Vec<Extrinsic>'
|
||||
})
|
||||
);
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { Digest, DigestItem, H256, Header } from '../interfaces/runtime';
|
||||
import { AnyNumber, AnyU8a, Registry } from '../types';
|
||||
|
||||
import { blake2AsU8a } from '@polkadot/util-crypto';
|
||||
|
||||
import Extrinsic from '../extrinsic/Extrinsic';
|
||||
import Struct from '../codec/Struct';
|
||||
import Vec from '../codec/Vec';
|
||||
@@ -42,7 +40,7 @@ export default class Block extends Struct {
|
||||
* @description Encodes a content [[Hash]] for the block
|
||||
*/
|
||||
public get contentHash (): H256 {
|
||||
return this.registry.createType('H256', blake2AsU8a(this.toU8a(), 256));
|
||||
return this.registry.createType('H256', this.registry.hash(this.toU8a()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+7
-7
@@ -5,12 +5,12 @@
|
||||
import { TypeRegistry } from '../create';
|
||||
import AccountId from './AccountId';
|
||||
import AccountIndex from './AccountIndex';
|
||||
import Address from './Address';
|
||||
import LookupSource from './LookupSource';
|
||||
|
||||
describe('Address', (): void => {
|
||||
describe('LookupSource', (): void => {
|
||||
const registry = new TypeRegistry();
|
||||
|
||||
const testDecode = (type: string, input: Address | AccountId | AccountIndex | number[] | Uint8Array, expected: string): void =>
|
||||
const testDecode = (type: string, input: LookupSource | AccountId | AccountIndex | number[] | Uint8Array, expected: string): void =>
|
||||
it(`can decode from ${type}`, (): void => {
|
||||
const a = registry.createType('Address', input);
|
||||
|
||||
@@ -21,19 +21,19 @@ describe('Address', (): void => {
|
||||
it('equals on AccountId', (): void => {
|
||||
const addr = '5DkQbYAExs3M2sZgT1Ec3mKfZnAQCL4Dt9beTCknkCUn5jzo';
|
||||
|
||||
expect(registry.createType('Address', addr).eq(addr)).toBe(true);
|
||||
expect(registry.createType('LookupSource', addr).eq(addr)).toBe(true);
|
||||
});
|
||||
|
||||
it('equals on AccountIndex', (): void => {
|
||||
// see the test below - these are equivalent (with different prefix encoding)
|
||||
expect(registry.createType('Address', '2jpAFn').eq('25GUyv')).toBe(true);
|
||||
expect(registry.createType('LookupSource', '2jpAFn').eq('25GUyv')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('decoding', (): void => {
|
||||
testDecode(
|
||||
'Address',
|
||||
registry.createType('Address', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'),
|
||||
registry.createType('LookupSource', '5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'),
|
||||
'5C62W7ELLAAfix9LYrcx5smtcffbhvThkM5x7xfMeYXCtGwF'
|
||||
);
|
||||
testDecode(
|
||||
@@ -43,7 +43,7 @@ describe('Address', (): void => {
|
||||
);
|
||||
testDecode(
|
||||
'AccountIndex (mixed prefixes)',
|
||||
registry.createType('Address', '2jpAFn'),
|
||||
registry.createType('LookupSource', '2jpAFn'),
|
||||
// NOTE Expected adress here is encoded with prefix 42, input above with 68
|
||||
'25GUyv'
|
||||
);
|
||||
@@ -12,7 +12,7 @@ import Base from '../codec/Base';
|
||||
import AccountId from './AccountId';
|
||||
import AccountIndex from './AccountIndex';
|
||||
|
||||
type AnyAddress = BN | Address | AccountId | AccountIndex | number[] | Uint8Array | number | string;
|
||||
type AnyAddress = BN | LookupSource | AccountId | AccountIndex | number[] | Uint8Array | number | string;
|
||||
|
||||
export const ACCOUNT_ID_PREFIX = new Uint8Array([0xff]);
|
||||
|
||||
@@ -41,23 +41,23 @@ function decodeU8a (registry: Registry, value: Uint8Array): AccountId | AccountI
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Address
|
||||
* @name LookupSource
|
||||
* @description
|
||||
* A wrapper around an AccountId and/or AccountIndex that is encoded with a prefix.
|
||||
* Since we are dealing with underlying publicKeys (or shorter encoded addresses),
|
||||
* we extend from Base with an AccountId/AccountIndex wrapper. Basically the Address
|
||||
* is encoded as `[ <prefix-byte>, ...publicKey/...bytes ]` as per spec
|
||||
*/
|
||||
export default class Address extends Base<AccountId | AccountIndex> {
|
||||
export default class LookupSource extends Base<AccountId | AccountIndex> {
|
||||
constructor (registry: Registry, value: AnyAddress = new Uint8Array()) {
|
||||
super(registry, Address._decodeAddress(registry, value));
|
||||
super(registry, LookupSource._decodeAddress(registry, value));
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
private static _decodeAddress (registry: Registry, value: AnyAddress): AccountId | AccountIndex {
|
||||
if (value instanceof AccountId || value instanceof AccountIndex) {
|
||||
return value;
|
||||
} else if (value instanceof Address) {
|
||||
} else if (value instanceof LookupSource) {
|
||||
return value._raw;
|
||||
} else if (isBn(value) || isNumber(value)) {
|
||||
return registry.createType('AccountIndex', value);
|
||||
@@ -2,11 +2,13 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
export * from '../ethereum';
|
||||
|
||||
export { default as GenericAccountId } from './AccountId';
|
||||
export { default as GenericAccountIndex } from './AccountIndex';
|
||||
export { default as GenericAddress } from './Address';
|
||||
export { default as GenericBlock } from './Block';
|
||||
export { default as GenericCall } from './Call';
|
||||
export { default as GenericConsensusEngineId } from './ConsensusEngineId';
|
||||
export { default as GenericEvent } from './Event';
|
||||
export { default as GenericLookupSource } from './LookupSource';
|
||||
export { default as GenericVote } from './Vote';
|
||||
|
||||
@@ -76,10 +76,21 @@ export default {
|
||||
gasLimit: 'u64',
|
||||
inputData: 'Bytes'
|
||||
},
|
||||
ContractExecResultSuccess: {
|
||||
ContractExecResultSuccessTo255: {
|
||||
status: 'u8',
|
||||
data: 'Raw'
|
||||
},
|
||||
ContractExecResultTo255: {
|
||||
_enum: {
|
||||
Success: 'ContractExecResultSuccessTo255',
|
||||
Error: 'Null'
|
||||
}
|
||||
},
|
||||
ContractExecResultSuccess: {
|
||||
flags: 'u32',
|
||||
data: 'Vec<u8>',
|
||||
gasConsumed: 'u64'
|
||||
},
|
||||
ContractExecResult: {
|
||||
_enum: {
|
||||
Success: 'ContractExecResultSuccess',
|
||||
|
||||
@@ -36,10 +36,24 @@ export interface ContractExecResult extends Enum {
|
||||
|
||||
/** @name ContractExecResultSuccess */
|
||||
export interface ContractExecResultSuccess extends Struct {
|
||||
readonly flags: u32;
|
||||
readonly data: Bytes;
|
||||
readonly gasConsumed: u64;
|
||||
}
|
||||
|
||||
/** @name ContractExecResultSuccessTo255 */
|
||||
export interface ContractExecResultSuccessTo255 extends Struct {
|
||||
readonly status: u8;
|
||||
readonly data: Raw;
|
||||
}
|
||||
|
||||
/** @name ContractExecResultTo255 */
|
||||
export interface ContractExecResultTo255 extends Enum {
|
||||
readonly isSuccess: boolean;
|
||||
readonly asSuccess: ContractExecResultSuccessTo255;
|
||||
readonly isError: boolean;
|
||||
}
|
||||
|
||||
/** @name ContractInfo */
|
||||
export interface ContractInfo extends Enum {
|
||||
readonly isAlive: boolean;
|
||||
|
||||
@@ -23,6 +23,7 @@ export { default as grandpa } from './grandpa/definitions';
|
||||
export { default as identity } from './identity/definitions';
|
||||
export { default as imOnline } from './imOnline/definitions';
|
||||
export { default as offences } from './offences/definitions';
|
||||
export { default as proxy } from './proxy/definitions';
|
||||
export { default as recovery } from './recovery/definitions';
|
||||
export { default as scheduler } from './scheduler/definitions';
|
||||
export { default as session } from './session/definitions';
|
||||
@@ -39,6 +40,11 @@ export { default as vesting } from './vesting/definitions';
|
||||
export { default as attestations } from './attestations/definitions';
|
||||
export { default as claims } from './claims/definitions';
|
||||
export { default as parachains } from './parachains/definitions';
|
||||
export { default as poll } from './poll/definitions';
|
||||
export { default as purchase } from './purchase/definitions';
|
||||
|
||||
// other useful types
|
||||
export { default as ethereum } from './ethereum/definitions';
|
||||
|
||||
// pull in metadata & rpc last, assuming that is uses info from above
|
||||
export { default as metadata } from './metadata/definitions';
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/types authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
// order important in structs... :)
|
||||
/* eslint-disable sort-keys */
|
||||
|
||||
import { Definitions } from '../../types';
|
||||
|
||||
export default {
|
||||
rpc: {},
|
||||
types: {
|
||||
EthereumAccountId: 'GenericEthereumAccountId',
|
||||
EthereumLookupSource: 'GenericEthereumLookupSource'
|
||||
}
|
||||
} as Definitions;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user