Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
878f631745 | ||
|
|
d7753839a2 | ||
|
|
fc74d88bbb | ||
|
|
47bbeee14b | ||
|
|
ba01620ba1 | ||
|
|
6e66387a8d | ||
|
|
c58687b3c6 | ||
|
|
2801088b0a | ||
|
|
fc5af92a03 | ||
|
|
8f8bb2aa23 | ||
|
|
3f69b3fc73 | ||
|
|
4ea170a83a | ||
|
|
26649c429a | ||
|
|
7c57778389 | ||
|
|
dbb5d66de3 | ||
|
|
6bc92a6d31 | ||
|
|
6462327ea5 | ||
|
|
3b4c2ac323 | ||
|
|
d0ecfdafc1 | ||
|
|
870bb8d3cb | ||
|
|
2fdb68d3bc | ||
|
|
6ef410e375 | ||
|
|
962c741139 | ||
|
|
598e69002a | ||
|
|
f6e50f14b5 | ||
|
|
caec49a8dc | ||
|
|
0865b91f88 | ||
|
|
6b45d5606d | ||
|
|
a22f66f044 | ||
|
|
41fd67c24e | ||
|
|
19e7d6dbdb | ||
|
|
8fea8872fc | ||
|
|
d17fc3b63b | ||
|
|
f8e012cf87 | ||
|
|
830af4a928 | ||
|
|
345c536380 | ||
|
|
d527a02d2f | ||
|
|
22aafbdd4c | ||
|
|
88e5b26532 | ||
|
|
a203168126 | ||
|
|
538544be84 | ||
|
|
264bbf12c9 | ||
|
|
5c144a8ae7 | ||
|
|
f28d648fac | ||
|
|
f695cd0835 | ||
|
|
44fdbdffd5 | ||
|
|
ee5ae49df7 | ||
|
|
febcabe109 | ||
|
|
367efda128 | ||
|
|
3583e758cd | ||
|
|
d6fe638c5b | ||
|
|
ea72e3eb5b | ||
|
|
45c0e16ecd | ||
|
|
5b1823f7eb | ||
|
|
6e998cce3d | ||
|
|
c46740e4e8 | ||
|
|
4e5b98725b | ||
|
|
fca973cd53 | ||
|
|
d1c9a507d9 | ||
|
|
2cfd2f4d20 | ||
|
|
d3b90c068f | ||
|
|
3127c00d05 | ||
|
|
3cdf3065d7 | ||
|
|
973b1fcffb | ||
|
|
4195833d6f | ||
|
|
8f4e62c278 | ||
|
|
2c294af116 | ||
|
|
0f1f3b88b2 | ||
|
|
56b7697dda | ||
|
|
86d7471c76 | ||
|
|
cb7400710b | ||
|
|
59796067e2 | ||
|
|
7920565b97 | ||
|
|
4f0069cac8 | ||
|
|
835070c44f | ||
|
|
5368733353 | ||
|
|
efda09f279 | ||
|
|
af48f19dfa | ||
|
|
a0dd50b3ba | ||
|
|
3e159891c0 | ||
|
|
4b36fa68a5 | ||
|
|
70c9cfa0f0 | ||
|
|
3ce67375e3 | ||
|
|
10d611ba17 | ||
|
|
00acff5956 | ||
|
|
9857abd061 | ||
|
|
e87c830990 | ||
|
|
71063c93d1 | ||
|
|
e037df89e3 | ||
|
|
564d63ce28 | ||
|
|
69db63b6f9 | ||
|
|
2bd81e9d05 | ||
|
|
d267895dd5 | ||
|
|
190e0fcdb1 | ||
|
|
5e83837c5b | ||
|
|
7f949874e6 | ||
|
|
b024d7f63c | ||
|
|
4bc76bb3e5 | ||
|
|
212b43dda2 | ||
|
|
0ba1b318a7 | ||
|
|
2e8e5a93ca | ||
|
|
6101f82000 | ||
|
|
662aef2033 | ||
|
|
0859c470be | ||
|
|
29fe22da43 | ||
|
|
7eef825b38 | ||
|
|
24808fb55d | ||
|
|
9c06ed7a1c | ||
|
|
9560259f55 | ||
|
|
6236838fc8 | ||
|
|
e14eddfee3 | ||
|
|
0927f9ba8c | ||
|
|
a8775fd69d | ||
|
|
363c502ae8 | ||
|
|
d6cc0c30b4 | ||
|
|
5e312973f3 | ||
|
|
17c6262a5e | ||
|
|
0932a9aa7b | ||
|
|
88b44befdf | ||
|
|
e4fb971bec | ||
|
|
5c7c406676 | ||
|
|
709e89b801 | ||
|
|
fd96255d05 | ||
|
|
c212db26b6 | ||
|
|
817aaccbb1 | ||
|
|
bfd5642d64 | ||
|
|
126871bd46 | ||
|
|
714234b7af | ||
|
|
a7a0965d73 | ||
|
|
9b1f9c214b | ||
|
|
ca17955d83 | ||
|
|
9b0d260b33 | ||
|
|
fed2913684 | ||
|
|
fc777377ef | ||
|
|
ce7968f870 | ||
|
|
07594a33b5 | ||
|
|
48620ea7a3 | ||
|
|
f86ace2680 | ||
|
|
0e22308954 | ||
|
|
ae21d13b23 | ||
|
|
b594158275 | ||
|
|
76da6a6af5 | ||
|
|
e1f510f5e9 | ||
|
|
db6c44615f | ||
|
|
4ce01fe16f | ||
|
|
c52576149a | ||
|
|
0b5e4fe1cc | ||
|
|
8404170240 | ||
|
|
2b6e66b906 | ||
|
|
b165c0fe8d | ||
|
|
c0751f1a67 | ||
|
|
2a95046fb2 | ||
|
|
e1828af4c4 | ||
|
|
a133fec533 | ||
|
|
c51f3d5d2a | ||
|
|
54bb965537 | ||
|
|
9ab662881f | ||
|
|
697781fb52 | ||
|
|
a60d80953b | ||
|
|
a7edf81279 | ||
|
|
3423fb1717 | ||
|
|
4ae4e4298c | ||
|
|
90a84baa52 | ||
|
|
a80df7d846 | ||
|
|
9961595634 | ||
|
|
e0ecaccb09 | ||
|
|
fd7c80bd8a | ||
|
|
44a81bc00c | ||
|
|
7d71726024 | ||
|
|
f603100b8b | ||
|
|
70ac38cfd2 | ||
|
|
0bf0d27a39 |
+9
-1
@@ -1,4 +1,4 @@
|
|||||||
32
|
33
|
||||||
1.4.2
|
1.4.2
|
||||||
1.6.2
|
1.6.2
|
||||||
1.11.2
|
1.11.2
|
||||||
@@ -26,3 +26,11 @@
|
|||||||
4.16.2
|
4.16.2
|
||||||
|
|
||||||
5.3.2
|
5.3.2
|
||||||
|
5.5.2
|
||||||
|
5.8.2
|
||||||
|
5.8.3
|
||||||
|
|
||||||
|
6.0.2
|
||||||
|
6.0.3
|
||||||
|
6.0.4
|
||||||
|
6.0.5
|
||||||
Vendored
-591
File diff suppressed because one or more lines are too long
+631
File diff suppressed because one or more lines are too long
+1
-1
@@ -10,4 +10,4 @@ plugins:
|
|||||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||||
spec: "@yarnpkg/plugin-version"
|
spec: "@yarnpkg/plugin-version"
|
||||||
|
|
||||||
yarnPath: .yarn/releases/yarn-3.0.0-rc.2.cjs
|
yarnPath: .yarn/releases/yarn-3.0.1.cjs
|
||||||
|
|||||||
+200
@@ -1,5 +1,205 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 6.1.1 Sep 27, 2021
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Adjust bridges `OutboundLaneData` type (Thanks to https://github.com/HackFisher)
|
||||||
|
- Fix README 404 (Thanks to https://github.com/nblogist)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Add `childstate_getStorageEntries` RPC
|
||||||
|
- Allow for scale-info v0 -> v1 conversion
|
||||||
|
|
||||||
|
|
||||||
|
## 6.0.5 Sep 20, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for all users on 6.0.4 using `api.query.*.*.at` calls
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Revert cross-registry (now-inactive) change introduced in 6.0.3
|
||||||
|
- Ensure `Option` is correctly imported for TS query generation
|
||||||
|
|
||||||
|
|
||||||
|
## 6.0.4 Sep 20, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for all users on 6.0.3 using `api.query.*.*.at` calls
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- `api.query.<module>.<method>.at` will now use `at.at(<hash>)`
|
||||||
|
- Use and expose `metadata/util/getSiName` to get human type names
|
||||||
|
|
||||||
|
|
||||||
|
## 6.0.3 Sep 19, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for all users on 6.0.2 using `api.query.*.*.at` calls
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Fix `api.query.<module>.<method>.at` queries
|
||||||
|
- Adjust typegen formatting for metadata documentation
|
||||||
|
|
||||||
|
|
||||||
|
## 6.0.2 Sep 18, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for all users on 6.0.1, especially those using `api.query.substrate.*` calls
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Fix `api.query.substrate.*` key generation
|
||||||
|
|
||||||
|
|
||||||
|
## 6.0.1 Sep 18, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for users of the latest Substrate/Polkadot with Metadata v14.
|
||||||
|
|
||||||
|
- **Important** The Metadata v14 change allows the metadata to expose the chain types. This has been a major overhaul of the metadata handling, hence the major version bump.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Allow for `.clone` on Http provider (Thanks to https://github.com/ianhe8x)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Allow for Metadata v14 parsing & usage
|
||||||
|
- Align `DigestItem` to latest Substrate
|
||||||
|
- Adjust Kusama `IdentityInfo` type for historic versions
|
||||||
|
- All `null` values in bundles min/max
|
||||||
|
- Bump static metadata for latest Substrate, Polkadot & Kusama
|
||||||
|
|
||||||
|
|
||||||
|
## 5.9.1 Sep 13, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for chains using Xcm.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Adjust Centrifuge `ProxyType` (Thanks to https://github.com/branan)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Additional types for parachain Disputes
|
||||||
|
- Adjust Xcm Error enum types
|
||||||
|
- Add Polkadot 9090 upgrade block
|
||||||
|
- Decoding enhancements with narrowing checks for TS
|
||||||
|
|
||||||
|
|
||||||
|
## 5.8.3 Sep 6, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjust Statemint, Rococo and Westend Xcm overrides
|
||||||
|
|
||||||
|
|
||||||
|
## 5.8.2 Sep 6, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low.
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Correct Xcm V1 `MultiLocation` definitions (Thanks to https://github.com/apopiak)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjust Kusama Xcm overrides
|
||||||
|
|
||||||
|
|
||||||
|
## 5.8.1 Sep 6, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Add `Auction` to Kusama `ProxyType` definition
|
||||||
|
- Adjust Xcm definitions with latest v1 & v2 types
|
||||||
|
- Support for `scale-info` 1.0 `Range` mapping
|
||||||
|
- Bump static metadata for latest Substrate, Polkadot & Kusama
|
||||||
|
|
||||||
|
|
||||||
|
## 5.7.1 Aug 29, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Optimize `Vec` construction (no re-create on new arrays)
|
||||||
|
- Adjust output for enums in `toHuman`
|
||||||
|
- Adjust aliases for new parachain module locations
|
||||||
|
- Support for versioned xcm types (Polkadot master)
|
||||||
|
- Add support for `Range` in `PortableRegistry` (used in Metadata 14)
|
||||||
|
- Adjust balances derive for non-existent instances
|
||||||
|
- Ensure Statemint (current) defaults to xcm v0
|
||||||
|
- Add Kusama 9090 upgrade block
|
||||||
|
|
||||||
|
|
||||||
|
## 5.6.1 Aug 23, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for users of Xcm, preparing for Kusama/Westend 9100
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Support 0...N-1 args on `keys/entries` (Thanks to https://github.com/hamidra)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Updated XCM types, `AssetId`, `MultiAssets`, `MultiAssetV1`, `AssetInstanceV1`, `XcmOrderV1`
|
||||||
|
- Rename `Null` entry in `MultiLocation` to `Here` (Xcm V1)
|
||||||
|
- Westend 9090 upgrade block
|
||||||
|
- Bump static Substrate, Kusama & Polkadot metadata
|
||||||
|
|
||||||
|
|
||||||
|
## 5.5.2 Aug 19, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Medium. Contains fixes for parachain types, affecting historic block retrieval on Kusama.
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Adjust `ValidDisputeStatementKind` enum to latest version
|
||||||
|
- Only enable API health keepalive on connections supporting subscriptions
|
||||||
|
|
||||||
|
|
||||||
|
## 5.5.1 Aug 15, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for users of TS (`createType` and `bigint` adjustments)
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Add `Range` & `RangeInclusive` types (Thanks to https://github.com/c410-f3r)
|
||||||
|
- Always use TS `bigint` type (Thanks to https://github.com/ntduan)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Loosen pedantic check not to fail on all-empty values
|
||||||
|
- Extend `createType` auto-TS decoration for `BreeMap`, `BTreeSet`, `HashMap`, `Range`
|
||||||
|
- Add Polkadot 9080 upgrade block
|
||||||
|
|
||||||
|
|
||||||
|
## 5.4.1 Aug 9, 2021
|
||||||
|
|
||||||
|
Upgrade priority: Low. Recommended for potential users of NMap.
|
||||||
|
|
||||||
|
- **Important** The `ClassOf` alias for `createClass` has been removed, use `createClass` (with new generics) directly
|
||||||
|
|
||||||
|
Contributed:
|
||||||
|
|
||||||
|
- Enable `.keys()/.entries()` on NMap (Thanks to https://github.com/hamidra)
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- `createType<T = Codec>('...': K)` now returns `Codec` when `K` is not known
|
||||||
|
- `createType` does basic TypeScript type matching on the input type
|
||||||
|
- Handle `BitSequence` in `PortableRegistry`
|
||||||
|
- Ensure API `isConnected` is set before connect/disconnect events are fired
|
||||||
|
- Move all static test support files into `@polkadot/types-support`
|
||||||
|
- Align static Metadata with latest Substrate, Polkadot & Kusama
|
||||||
|
- Adjust v14 Metadata definitions to latest version
|
||||||
|
|
||||||
|
|
||||||
## 5.3.2 Aug 3, 2021
|
## 5.3.2 Aug 3, 2021
|
||||||
|
|
||||||
Upgrade priority: Low. Recommended for users of bridges.
|
Upgrade priority: Low. Recommended for users of bridges.
|
||||||
|
|||||||
+2
-14
@@ -12,21 +12,9 @@ module.exports = {
|
|||||||
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
'@polkadot/metadata(.*)$': '<rootDir>/packages/metadata/src/$1',
|
||||||
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
'@polkadot/rpc-(core|provider)(.*)$': '<rootDir>/packages/rpc-$1/src/$2',
|
||||||
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
|
'@polkadot/typegen(.*)$': '<rootDir>/packages/typegen/src/$1',
|
||||||
'@polkadot/types-known(.*)$': '<rootDir>/packages/types-known/src/$1',
|
'@polkadot/types-(known|support)(.*)$': '<rootDir>/packages/types-$1/src/$2',
|
||||||
// eslint-disable-next-line sort-keys
|
// eslint-disable-next-line sort-keys
|
||||||
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
'@polkadot/types(.*)$': '<rootDir>/packages/types/src/$1'
|
||||||
},
|
},
|
||||||
modulePathIgnorePatterns: [
|
testTimeout: 30000
|
||||||
'<rootDir>/packages/api/build',
|
|
||||||
'<rootDir>/packages/api-contract/build',
|
|
||||||
'<rootDir>/packages/api-derive/build',
|
|
||||||
'<rootDir>/packages/metadata/build',
|
|
||||||
'<rootDir>/packages/rpc-core/build',
|
|
||||||
'<rootDir>/packages/rpc-provider/build',
|
|
||||||
'<rootDir>/packages/typegen/build',
|
|
||||||
'<rootDir>/packages/types/build',
|
|
||||||
'<rootDir>/packages/types-known/build'
|
|
||||||
],
|
|
||||||
testTimeout: 30000,
|
|
||||||
transformIgnorePatterns: ['/node_modules/(?!@polkadot|@babel/runtime/helpers/esm/)']
|
|
||||||
};
|
};
|
||||||
|
|||||||
+9
-8
@@ -8,7 +8,7 @@
|
|||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.4.3"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
"build": "yarn build:interfaces && polkadot-dev-build-ts",
|
||||||
@@ -26,14 +26,15 @@
|
|||||||
"test:watch": "polkadot-dev-run-test --watch"
|
"test:watch": "polkadot-dev-run-test --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.14.8",
|
"@babel/core": "^7.15.5",
|
||||||
"@babel/register": "^7.14.5",
|
"@babel/register": "^7.15.3",
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/dev": "^0.62.57",
|
"@polkadot/dev": "^0.62.68",
|
||||||
"@polkadot/ts": "^0.4.4",
|
"@polkadot/ts": "^0.4.8",
|
||||||
"@polkadot/typegen": "workspace:packages/typegen",
|
"@polkadot/typegen": "workspace:packages/typegen",
|
||||||
"@types/jest": "^26.0.24",
|
"@types/jest": "^27.0.2",
|
||||||
"copyfiles": "^2.4.1"
|
"copyfiles": "^2.4.1"
|
||||||
},
|
},
|
||||||
"version": "5.3.2"
|
"version": "6.1.1",
|
||||||
|
"packageManager": "yarn@3.0.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/api-contract",
|
"name": "@polkadot/api-contract",
|
||||||
"version": "5.3.2",
|
"version": "6.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Interfaces for interacting with contracts and contract ABIs",
|
"description": "Interfaces for interacting with contracts and contract ABIs",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -19,10 +19,10 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/api": "5.3.2",
|
"@polkadot/api": "6.1.1",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"@polkadot/util": "^7.1.1",
|
"@polkadot/util": "^7.4.1",
|
||||||
"rxjs": "^7.2.0"
|
"rxjs": "^7.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import type { Bytes } from '@polkadot/types';
|
import type { Bytes } from '@polkadot/types';
|
||||||
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
|
import type { ChainProperties, ContractConstructorSpec, ContractEventSpec, ContractMessageParamSpec, ContractMessageSpec, ContractProject } from '@polkadot/types/interfaces';
|
||||||
import type { AnyJson, Codec, CodecArg } from '@polkadot/types/types';
|
import type { AnyJson, Codec } from '@polkadot/types/types';
|
||||||
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
import type { AbiConstructor, AbiEvent, AbiMessage, AbiParam, DecodedEvent, DecodedMessage } from './types';
|
||||||
|
|
||||||
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
|
import { assert, assertReturn, compactAddLength, compactStripLength, isNumber, isObject, isString, logger, stringCamelCase, stringify, u8aConcat, u8aToHex } from '@polkadot/util';
|
||||||
@@ -154,7 +154,7 @@ export class Abi {
|
|||||||
index,
|
index,
|
||||||
method: stringCamelCase(identifier),
|
method: stringCamelCase(identifier),
|
||||||
selector: spec.selector,
|
selector: spec.selector,
|
||||||
toU8a: (params: CodecArg[]) =>
|
toU8a: (params: unknown[]) =>
|
||||||
this.#encodeArgs(spec, args, params)
|
this.#encodeArgs(spec, args, params)
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ export class Abi {
|
|||||||
return message.fromU8a(trimmed.subarray(4));
|
return message.fromU8a(trimmed.subarray(4));
|
||||||
}
|
}
|
||||||
|
|
||||||
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: CodecArg[]): Uint8Array => {
|
#encodeArgs = ({ name, selector }: ContractMessageSpec | ContractConstructorSpec, args: AbiParam[], data: unknown[]): Uint8Array => {
|
||||||
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
assert(data.length === args.length, () => `Expected ${args.length} arguments to contract message '${name.toString()}', found ${data.length}`);
|
||||||
|
|
||||||
return compactAddLength(
|
return compactAddLength(
|
||||||
|
|||||||
@@ -4,28 +4,36 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
|
import { TypeDefInfo } from '@polkadot/types/types';
|
||||||
|
|
||||||
import abis from '../test/contracts';
|
import abis from '../test/contracts';
|
||||||
import { Abi } from '.';
|
import { Abi } from '.';
|
||||||
|
|
||||||
|
function stringifyInfo (key: string, value: unknown): unknown {
|
||||||
|
return key === 'info'
|
||||||
|
? TypeDefInfo[value as number]
|
||||||
|
: value;
|
||||||
|
}
|
||||||
|
|
||||||
describe('MetaRegistry', (): void => {
|
describe('MetaRegistry', (): void => {
|
||||||
Object.keys(abis).forEach((abiName) => {
|
Object.keys(abis).forEach((abiName) => {
|
||||||
it(`initializes from a contract ABI (${abiName})`, (): void => {
|
it(`initializes from a contract ABI (${abiName})`, (): void => {
|
||||||
const abi = new Abi(abis[abiName]);
|
const abi = new Abi(abis[abiName]);
|
||||||
|
const json = JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo, 2);
|
||||||
try {
|
|
||||||
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
|
const cmpPath = path.join(__dirname, `../test/compare/${abiName}.test.json`);
|
||||||
|
|
||||||
if (!fs.existsSync(cmpPath)) {
|
try {
|
||||||
fs.writeFileSync(cmpPath, JSON.stringify(abi.registry.metaTypeDefs, null, 2), { flag: 'w' });
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
expect(abi.registry.metaTypeDefs).toEqual(require(cmpPath));
|
expect(JSON.parse(json)).toEqual(require(cmpPath));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(JSON.stringify(abi.registry.metaTypeDefs));
|
if (process.env.GITHUB_REPOSITORY) {
|
||||||
|
console.error(JSON.stringify(abi.registry.metaTypeDefs, stringifyInfo));
|
||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(cmpPath, json, { flag: 'w' });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||||
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
import type { AccountId, EventRecord, Hash } from '@polkadot/types/interfaces';
|
||||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||||
import type { MapConstructorExec } from './types';
|
import type { MapConstructorExec } from './types';
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ export class Blueprint<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
return this.#tx;
|
return this.#tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
#deploy = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, BlueprintSubmittableResult<ApiType>> => {
|
||||||
return this.api.tx.contracts
|
return this.api.tx.contracts
|
||||||
.instantiate(
|
.instantiate(
|
||||||
value,
|
value,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||||
import type { MapConstructorExec } from './types';
|
import type { MapConstructorExec } from './types';
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ export class Code<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
return this.#tx;
|
return this.#tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
#instantiate = (constructorOrId: AbiConstructor | string | number, { gasLimit = BN_ZERO, salt, value = BN_ZERO }: BlueprintOptions, params: unknown[]): SubmittableExtrinsic<ApiType, CodeSubmittableResult<ApiType>> => {
|
||||||
return this.api.tx.contracts
|
return this.api.tx.contracts
|
||||||
.instantiateWithCode(
|
.instantiateWithCode(
|
||||||
value,
|
value,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
|||||||
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
import type { ApiTypes, DecorateMethod } from '@polkadot/api/types';
|
||||||
import type { Bytes } from '@polkadot/types';
|
import type { Bytes } from '@polkadot/types';
|
||||||
import type { AccountId, EventRecord, Weight } from '@polkadot/types/interfaces';
|
import type { AccountId, EventRecord, Weight } from '@polkadot/types/interfaces';
|
||||||
import type { AnyJson, CodecArg, ISubmittableResult } from '@polkadot/types/types';
|
import type { AnyJson, ISubmittableResult } from '@polkadot/types/types';
|
||||||
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
import type { AbiMessage, ContractCallOutcome, ContractOptions, DecodedEvent } from '../types';
|
||||||
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
import type { ContractCallResult, ContractCallSend, ContractQuery, ContractTx, MapMessageQuery, MapMessageTx } from './types';
|
||||||
|
|
||||||
@@ -26,15 +26,15 @@ const ERROR_NO_CALL = 'Your node does not expose the contracts.call RPC. This is
|
|||||||
|
|
||||||
const l = logger('Contract');
|
const l = logger('Contract');
|
||||||
|
|
||||||
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: CodecArg[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
function createQuery <ApiType extends ApiTypes> (fn: (origin: string | AccountId | Uint8Array, options: ContractOptions, params: unknown[]) => ContractCallResult<ApiType, ContractCallOutcome>): ContractQuery<ApiType> {
|
||||||
return (origin: string | AccountId | Uint8Array, options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
return (origin: string | AccountId | Uint8Array, options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome> =>
|
||||||
isOptions(options)
|
isOptions(options)
|
||||||
? fn(origin, options, params)
|
? fn(origin, options, params)
|
||||||
: fn(origin, ...extractOptions(options, params));
|
: fn(origin, ...extractOptions(options, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
function createTx <ApiType extends ApiTypes> (fn: (options: ContractOptions, params: unknown[]) => SubmittableExtrinsic<ApiType>): ContractTx<ApiType> {
|
||||||
return (options: BigInt | string | number | BN | ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType> =>
|
return (options: bigint | string | number | BN | ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType> =>
|
||||||
isOptions(options)
|
isOptions(options)
|
||||||
? fn(options, params)
|
? fn(options, params)
|
||||||
: fn(...extractOptions(options, params));
|
: fn(...extractOptions(options, params));
|
||||||
@@ -90,7 +90,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
return this.#tx;
|
return this.#tx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#getGas = (_gasLimit: BigInt | BN | string | number, isCall = false): BN => {
|
#getGas = (_gasLimit: bigint | BN | string | number, isCall = false): BN => {
|
||||||
const gasLimit = bnToBn(_gasLimit);
|
const gasLimit = bnToBn(_gasLimit);
|
||||||
|
|
||||||
return gasLimit.lte(BN_ZERO)
|
return gasLimit.lte(BN_ZERO)
|
||||||
@@ -103,7 +103,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
: gasLimit;
|
: gasLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): SubmittableExtrinsic<ApiType> => {
|
#exec = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): SubmittableExtrinsic<ApiType> => {
|
||||||
return this.api.tx.contracts
|
return this.api.tx.contracts
|
||||||
.call(
|
.call(
|
||||||
this.address,
|
this.address,
|
||||||
@@ -129,7 +129,7 @@ export class Contract<ApiType extends ApiTypes> extends Base<ApiType> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: CodecArg[]): ContractCallSend<ApiType> => {
|
#read = (messageOrId: AbiMessage | string | number, { gasLimit = BN_ZERO, value = BN_ZERO }: ContractOptions, params: unknown[]): ContractCallSend<ApiType> => {
|
||||||
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
assert(this.hasRpcContractsCall, ERROR_NO_CALL);
|
||||||
|
|
||||||
const message = this.abi.findMessage(messageOrId);
|
const message = this.abi.findMessage(messageOrId);
|
||||||
|
|||||||
@@ -5,28 +5,27 @@ import type { Observable } from 'rxjs';
|
|||||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||||
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
import type { ApiTypes, ObsInnerType } from '@polkadot/api/types';
|
||||||
import type { AccountId } from '@polkadot/types/interfaces';
|
import type { AccountId } from '@polkadot/types/interfaces';
|
||||||
import type { CodecArg } from '@polkadot/types/types';
|
|
||||||
import type { BN } from '@polkadot/util';
|
import type { BN } from '@polkadot/util';
|
||||||
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
import type { AbiMessage, BlueprintOptions, ContractCallOutcome, ContractOptions } from '../types';
|
||||||
|
|
||||||
export interface BlueprintDeploy<ApiType extends ApiTypes> {
|
export interface BlueprintDeploy<ApiType extends ApiTypes> {
|
||||||
(options: BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
(options: BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||||
(value: BigInt | string | number | BN, gasLimit: BigInt | string | number | BN, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
(value: bigint | string | number | BN, gasLimit: bigint | string | number | BN, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractQuery<ApiType extends ApiTypes> {
|
export interface ContractQuery<ApiType extends ApiTypes> {
|
||||||
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
(origin: AccountId | string | Uint8Array, options: ContractOptions, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||||
(origin: AccountId | string | Uint8Array, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
(origin: AccountId | string | Uint8Array, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): ContractCallResult<ApiType, ContractCallOutcome>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractTx<ApiType extends ApiTypes> {
|
export interface ContractTx<ApiType extends ApiTypes> {
|
||||||
(options: ContractOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
(options: ContractOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||||
(value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): SubmittableExtrinsic<ApiType>;
|
(value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): SubmittableExtrinsic<ApiType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractGeneric<O, T> {
|
export interface ContractGeneric<O, T> {
|
||||||
(messageOrId: AbiMessage | string | number, options: O, ...params: CodecArg[]): T;
|
(messageOrId: AbiMessage | string | number, options: O, ...params: unknown[]): T;
|
||||||
(messageOrId: AbiMessage | string | number, value: BigInt | BN | string | number, gasLimit: BigInt | BN | string | number, ...params: CodecArg[]): T;
|
(messageOrId: AbiMessage | string | number, value: bigint | BN | string | number, gasLimit: bigint | BN | string | number, ...params: unknown[]): T;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
export type ContractCallResult<ApiType extends ApiTypes, T> = ApiType extends 'rxjs'
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
import type { SubmittableResult } from '@polkadot/api';
|
import type { SubmittableResult } from '@polkadot/api';
|
||||||
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
import type { SubmittableExtrinsic } from '@polkadot/api/submittable/types';
|
||||||
import type { ApiTypes } from '@polkadot/api/types';
|
import type { ApiTypes } from '@polkadot/api/types';
|
||||||
import type { CodecArg } from '@polkadot/types/types';
|
|
||||||
import type { BN } from '@polkadot/util';
|
import type { BN } from '@polkadot/util';
|
||||||
import type { AbiConstructor, BlueprintOptions } from '../types';
|
import type { AbiConstructor, BlueprintOptions } from '../types';
|
||||||
import type { BlueprintDeploy, ContractGeneric } from './types';
|
import type { BlueprintDeploy, ContractGeneric } from './types';
|
||||||
@@ -17,15 +16,15 @@ import { extractOptions, isOptions } from '../util';
|
|||||||
|
|
||||||
export const EMPTY_SALT = new Uint8Array();
|
export const EMPTY_SALT = new Uint8Array();
|
||||||
|
|
||||||
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: CodecArg[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
export function createBluePrintTx <ApiType extends ApiTypes, R extends SubmittableResult> (fn: (options: BlueprintOptions, params: unknown[]) => SubmittableExtrinsic<ApiType, R>): BlueprintDeploy<ApiType> {
|
||||||
return (options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): SubmittableExtrinsic<ApiType, R> =>
|
return (options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): SubmittableExtrinsic<ApiType, R> =>
|
||||||
isOptions(options)
|
isOptions(options)
|
||||||
? fn(options, params)
|
? fn(options, params)
|
||||||
: fn(...extractOptions(options, params));
|
: fn(...extractOptions(options, params));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: CodecArg[]) => T): ContractGeneric<BlueprintOptions, T> {
|
export function createBluePrintWithId <T> (fn: (constructorOrId: AbiConstructor | string | number, options: BlueprintOptions, params: unknown[]) => T): ContractGeneric<BlueprintOptions, T> {
|
||||||
return (constructorOrId: AbiConstructor | string | number, options: BigInt | string | number | BN | BlueprintOptions, ...params: CodecArg[]): T =>
|
return (constructorOrId: AbiConstructor | string | number, options: bigint | string | number | BN | BlueprintOptions, ...params: unknown[]): T =>
|
||||||
isOptions(options)
|
isOptions(options)
|
||||||
? fn(constructorOrId, options, params)
|
? fn(constructorOrId, options, params)
|
||||||
: fn(constructorOrId, ...extractOptions(options, params));
|
: fn(constructorOrId, ...extractOptions(options, params));
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Auto-generated by @polkadot/dev, do not edit
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api-contract', version: '5.3.2' };
|
export const packageInfo = { name: '@polkadot/api-contract', version: '6.1.1' };
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import type { ApiBase } from '@polkadot/api/base';
|
|||||||
import type { ApiTypes } from '@polkadot/api/types';
|
import type { ApiTypes } from '@polkadot/api/types';
|
||||||
import type { Text, u64 } from '@polkadot/types';
|
import type { Text, u64 } from '@polkadot/types';
|
||||||
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
import type { ContractExecResultResult, ContractSelector } from '@polkadot/types/interfaces';
|
||||||
import type { Codec, CodecArg, TypeDef } from '@polkadot/types/types';
|
import type { Codec, TypeDef } from '@polkadot/types/types';
|
||||||
import type { BN } from '@polkadot/util';
|
import type { BN } from '@polkadot/util';
|
||||||
import type { Abi } from '.';
|
import type { Abi } from '.';
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ export interface AbiMessage {
|
|||||||
method: string;
|
method: string;
|
||||||
returnType?: TypeDef | null;
|
returnType?: TypeDef | null;
|
||||||
selector: ContractSelector;
|
selector: ContractSelector;
|
||||||
toU8a: (params: CodecArg[]) => Uint8Array;
|
toU8a: (params: unknown[]) => Uint8Array;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AbiConstructor = AbiMessage;
|
export type AbiConstructor = AbiMessage;
|
||||||
@@ -71,12 +71,12 @@ export interface DecodedMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface BlueprintOptions {
|
export interface BlueprintOptions {
|
||||||
gasLimit?: BigInt | string | number | BN;
|
gasLimit?: bigint | string | number | BN;
|
||||||
salt?: Uint8Array | string | null;
|
salt?: Uint8Array | string | null;
|
||||||
value?: BigInt | string | number | BN;
|
value?: bigint | string | number | BN;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ContractOptions {
|
export interface ContractOptions {
|
||||||
gasLimit?: BigInt | BN | string | number;
|
gasLimit?: bigint | BN | string | number;
|
||||||
value?: BigInt | BN | string | number;
|
value?: bigint | BN | string | number;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
import type { SubmittableResult } from '@polkadot/api';
|
import type { SubmittableResult } from '@polkadot/api';
|
||||||
import type { EventRecord } from '@polkadot/types/interfaces';
|
import type { EventRecord } from '@polkadot/types/interfaces';
|
||||||
import type { CodecArg } from '@polkadot/types/types';
|
|
||||||
import type { BN } from '@polkadot/util';
|
import type { BN } from '@polkadot/util';
|
||||||
import type { BlueprintOptions, ContractOptions } from './types';
|
import type { BlueprintOptions, ContractOptions } from './types';
|
||||||
|
|
||||||
@@ -25,11 +24,11 @@ export function applyOnEvent <T> (result: SubmittableResult, types: ContractEven
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOptions <T> (options: BigInt | string | number | BN | T): options is T {
|
export function isOptions <T> (options: bigint | string | number | BN | T): options is T {
|
||||||
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
|
return !(isBn(options) || isBigInt(options) || isNumber(options) || isString(options));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extractOptions <T extends TOptions> (value: BigInt | string | number | BN, params: CodecArg[]): [T, CodecArg[]] {
|
export function extractOptions <T extends TOptions> (value: bigint | string | number | BN, params: unknown[]): [T, unknown[]] {
|
||||||
const gasLimit = params.shift() as BN;
|
const gasLimit = params.shift() as BN;
|
||||||
|
|
||||||
return [{ gasLimit, value } as T, params];
|
return [{ gasLimit, value } as T, params];
|
||||||
|
|||||||
@@ -2,30 +2,30 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32"
|
"type": "i32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Hash",
|
"displayName": "Hash",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "Hash"
|
"type": "Hash"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -2,20 +2,20 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Header",
|
"displayName": "Header",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "last_vacant"
|
"name": "last_vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len"
|
"name": "len"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len_entries"
|
"name": "len_entries"
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -33,15 +33,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -52,45 +52,45 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Hash",
|
"displayName": "Hash",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "Hash",
|
"type": "Hash",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Hash\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Hash",
|
"displayName": "Hash",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "Hash"
|
"type": "Hash"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -104,23 +104,23 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -128,7 +128,7 @@
|
|||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"name": "Ok",
|
"name": "Ok",
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
@@ -136,13 +136,13 @@
|
|||||||
"name": "Error",
|
"name": "Error",
|
||||||
"displayName": "Error",
|
"displayName": "Error",
|
||||||
"namespace": "dns::dns",
|
"namespace": "dns::dns",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 0
|
"discriminant": 0
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NameAlreadyExists",
|
"name": "NameAlreadyExists",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -150,7 +150,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 1
|
"discriminant": 1
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CallerIsNotOwner",
|
"name": "CallerIsNotOwner",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
}
|
}
|
||||||
@@ -158,24 +158,24 @@
|
|||||||
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
"type": "{\"_enum\":[\"NameAlreadyExists\",\"CallerIsNotOwner\"]}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 7,
|
"info": "Result",
|
||||||
"type": "Result<(), Error>"
|
"type": "Result<(), Error>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Error",
|
"displayName": "Error",
|
||||||
"namespace": "dns::dns",
|
"namespace": "dns::dns",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 0
|
"discriminant": 0
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NameAlreadyExists",
|
"name": "NameAlreadyExists",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -183,7 +183,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 1
|
"discriminant": 1
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CallerIsNotOwner",
|
"name": "CallerIsNotOwner",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
}
|
}
|
||||||
@@ -195,10 +195,10 @@
|
|||||||
"sub": {
|
"sub": {
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
"info": 5,
|
"info": "Option",
|
||||||
"type": "Option<AccountId>"
|
"type": "Option<AccountId>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,25 +1,25 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128"
|
"type": "u128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Header",
|
"displayName": "Header",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "last_vacant"
|
"name": "last_vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len"
|
"name": "len"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len_entries"
|
"name": "len_entries"
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -37,15 +37,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -56,45 +56,45 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -106,17 +106,17 @@
|
|||||||
"namespace": "ink_storage::collections::hashmap",
|
"namespace": "ink_storage::collections::hashmap",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128",
|
"type": "u128",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -126,15 +126,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -143,18 +143,18 @@
|
|||||||
"name": "Vacant"
|
"name": "Vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -162,29 +162,29 @@
|
|||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type": "(AccountId,AccountId)"
|
"type": "(AccountId,AccountId)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "bool"
|
"type": "bool"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -192,10 +192,10 @@
|
|||||||
"sub": {
|
"sub": {
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
"info": 5,
|
"info": "Option",
|
||||||
"type": "Option<AccountId>"
|
"type": "Option<AccountId>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -2,20 +2,20 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Header",
|
"displayName": "Header",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "last_vacant"
|
"name": "last_vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len"
|
"name": "len"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len_entries"
|
"name": "len_entries"
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -33,15 +33,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -50,26 +50,26 @@
|
|||||||
"name": "Vacant"
|
"name": "Vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -83,36 +83,36 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"AccountId\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -122,15 +122,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -141,12 +141,12 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -154,17 +154,17 @@
|
|||||||
"namespace": "ink_storage::collections::hashmap",
|
"namespace": "ink_storage::collections::hashmap",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -174,15 +174,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -191,18 +191,18 @@
|
|||||||
"name": "Vacant"
|
"name": "Vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -210,22 +210,22 @@
|
|||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -236,21 +236,21 @@
|
|||||||
"namespace": "ink_storage::collections::hashmap",
|
"namespace": "ink_storage::collections::hashmap",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "bool",
|
"type": "bool",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"bool\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "bool"
|
"type": "bool"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -258,10 +258,10 @@
|
|||||||
"sub": {
|
"sub": {
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
"info": 5,
|
"info": "Option",
|
||||||
"type": "Option<AccountId>"
|
"type": "Option<AccountId>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -269,7 +269,7 @@
|
|||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"name": "Ok",
|
"name": "Ok",
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
@@ -277,13 +277,13 @@
|
|||||||
"name": "Error",
|
"name": "Error",
|
||||||
"displayName": "Error",
|
"displayName": "Error",
|
||||||
"namespace": "erc721::erc721",
|
"namespace": "erc721::erc721",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 0
|
"discriminant": 0
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NotOwner",
|
"name": "NotOwner",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -291,7 +291,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 1
|
"discriminant": 1
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NotApproved",
|
"name": "NotApproved",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -299,7 +299,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 2
|
"discriminant": 2
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "TokenExists",
|
"name": "TokenExists",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -307,7 +307,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 3
|
"discriminant": 3
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "TokenNotFound",
|
"name": "TokenNotFound",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 4
|
"discriminant": 4
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CannotInsert",
|
"name": "CannotInsert",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -323,7 +323,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 5
|
"discriminant": 5
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CannotRemove",
|
"name": "CannotRemove",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -331,7 +331,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 6
|
"discriminant": 6
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CannotFetchValue",
|
"name": "CannotFetchValue",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -339,7 +339,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 7
|
"discriminant": 7
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NotAllowed",
|
"name": "NotAllowed",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
}
|
}
|
||||||
@@ -347,24 +347,24 @@
|
|||||||
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
"type": "{\"_enum\":[\"NotOwner\",\"NotApproved\",\"TokenExists\",\"TokenNotFound\",\"CannotInsert\",\"CannotRemove\",\"CannotFetchValue\",\"NotAllowed\"]}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 7,
|
"info": "Result",
|
||||||
"type": "Result<(), Error>"
|
"type": "Result<(), Error>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Error",
|
"displayName": "Error",
|
||||||
"namespace": "erc721::erc721",
|
"namespace": "erc721::erc721",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 0
|
"discriminant": 0
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NotOwner",
|
"name": "NotOwner",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -372,7 +372,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 1
|
"discriminant": 1
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NotApproved",
|
"name": "NotApproved",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -380,7 +380,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 2
|
"discriminant": 2
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "TokenExists",
|
"name": "TokenExists",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -388,7 +388,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 3
|
"discriminant": 3
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "TokenNotFound",
|
"name": "TokenNotFound",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -396,7 +396,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 4
|
"discriminant": 4
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CannotInsert",
|
"name": "CannotInsert",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -404,7 +404,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 5
|
"discriminant": 5
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CannotRemove",
|
"name": "CannotRemove",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -412,7 +412,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 6
|
"discriminant": 6
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "CannotFetchValue",
|
"name": "CannotFetchValue",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -420,7 +420,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 7
|
"discriminant": 7
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "NotAllowed",
|
"name": "NotAllowed",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "bool"
|
"type": "bool"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "bool"
|
"type": "bool"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32"
|
"type": "i32"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -2,20 +2,20 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Header",
|
"displayName": "Header",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "last_vacant"
|
"name": "last_vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len"
|
"name": "len"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len_entries"
|
"name": "len_entries"
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -33,15 +33,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -50,16 +50,16 @@
|
|||||||
"name": "Vacant"
|
"name": "Vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -67,20 +67,20 @@
|
|||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(u32,AccountId)\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -89,34 +89,34 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -128,22 +128,22 @@
|
|||||||
"namespace": "ink_storage::collections::hashmap",
|
"namespace": "ink_storage::collections::hashmap",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()",
|
"type": "()",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"()\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
@@ -154,15 +154,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -171,12 +171,12 @@
|
|||||||
"name": "Vacant"
|
"name": "Vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"u32\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -184,17 +184,17 @@
|
|||||||
"namespace": "ink_storage::collections::hashmap",
|
"namespace": "ink_storage::collections::hashmap",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"u32\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -204,15 +204,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -223,41 +223,41 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Transaction",
|
"displayName": "Transaction",
|
||||||
"namespace": "multisig_plain::multisig_plain",
|
"namespace": "multisig_plain::multisig_plain",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "callee"
|
"name": "callee"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 4,
|
"length": 4,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;4]",
|
"type": "[u8;4]",
|
||||||
"name": "selector"
|
"name": "selector"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "Vec<u8>",
|
"type": "Vec<u8>",
|
||||||
"name": "input"
|
"name": "input"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128",
|
"type": "u128",
|
||||||
"name": "transferred_value"
|
"name": "transferred_value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u64",
|
"type": "u64",
|
||||||
"name": "gas_limit"
|
"name": "gas_limit"
|
||||||
}
|
}
|
||||||
@@ -266,47 +266,47 @@
|
|||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"Transaction\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Transaction",
|
"displayName": "Transaction",
|
||||||
"namespace": "multisig_plain::multisig_plain",
|
"namespace": "multisig_plain::multisig_plain",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "callee"
|
"name": "callee"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 4,
|
"length": 4,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;4]",
|
"type": "[u8;4]",
|
||||||
"name": "selector"
|
"name": "selector"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "Vec<u8>",
|
"type": "Vec<u8>",
|
||||||
"name": "input"
|
"name": "input"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128",
|
"type": "u128",
|
||||||
"name": "transferred_value"
|
"name": "transferred_value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u64",
|
"type": "u64",
|
||||||
"name": "gas_limit"
|
"name": "gas_limit"
|
||||||
}
|
}
|
||||||
@@ -314,28 +314,28 @@
|
|||||||
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
|
"type": "{\"callee\":\"AccountId\",\"selector\":\"[u8;4]\",\"input\":\"Vec<u8>\",\"transferred_value\":\"u128\",\"gas_limit\":\"u64\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 4,
|
"length": 4,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;4]"
|
"type": "[u8;4]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "Vec<u8>"
|
"type": "Vec<u8>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128"
|
"type": "u128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u64"
|
"type": "u64"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -345,15 +345,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -364,44 +364,44 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
"type": "Vec<AccountId>"
|
"type": "Vec<AccountId>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "ConfirmationStatus",
|
"displayName": "ConfirmationStatus",
|
||||||
"namespace": "multisig_plain::multisig_plain",
|
"namespace": "multisig_plain::multisig_plain",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Confirmed",
|
"name": "Confirmed",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "ConfirmationsNeeded"
|
"name": "ConfirmationsNeeded"
|
||||||
}
|
}
|
||||||
@@ -414,16 +414,16 @@
|
|||||||
{
|
{
|
||||||
"displayName": "ConfirmationStatus",
|
"displayName": "ConfirmationStatus",
|
||||||
"namespace": "multisig_plain::multisig_plain",
|
"namespace": "multisig_plain::multisig_plain",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Confirmed",
|
"name": "Confirmed",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "ConfirmationsNeeded"
|
"name": "ConfirmationsNeeded"
|
||||||
}
|
}
|
||||||
@@ -435,18 +435,18 @@
|
|||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"name": "Ok",
|
"name": "Ok",
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Error",
|
"name": "Error",
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 7,
|
"info": "Result",
|
||||||
"type": "Result<(), ()>"
|
"type": "Result<(), ()>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -454,21 +454,21 @@
|
|||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"name": "Ok",
|
"name": "Ok",
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "Vec<u8>"
|
"type": "Vec<u8>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Error",
|
"name": "Error",
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 7,
|
"info": "Result",
|
||||||
"type": "Result<Vec<u8>, ()>"
|
"type": "Result<Vec<u8>, ()>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -478,37 +478,37 @@
|
|||||||
"name": "Ok",
|
"name": "Ok",
|
||||||
"displayName": "Option",
|
"displayName": "Option",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "Vec<u8>"
|
"type": "Vec<u8>"
|
||||||
},
|
},
|
||||||
"info": 5,
|
"info": "Option",
|
||||||
"type": "Option<Vec<u8>>"
|
"type": "Option<Vec<u8>>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Error",
|
"name": "Error",
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"type": "()"
|
"type": "()"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 7,
|
"info": "Result",
|
||||||
"type": "Result<Option<Vec<u8>>, ()>"
|
"type": "Result<Option<Vec<u8>>, ()>"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Option",
|
"displayName": "Option",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 11,
|
"info": "Vec",
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "Vec<u8>"
|
"type": "Vec<u8>"
|
||||||
},
|
},
|
||||||
"info": 5,
|
"info": "Option",
|
||||||
"type": "Option<Vec<u8>>"
|
"type": "Option<Vec<u8>>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u256"
|
"type": "u256"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,28 +1,28 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u256"
|
"type": "u256"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "Text"
|
"type": "Text"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32"
|
"type": "i32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Variant",
|
"displayName": "Variant",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "None",
|
"name": "None",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
@@ -25,13 +25,13 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Weekday",
|
"displayName": "Weekday",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 0
|
"discriminant": 0
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Monday",
|
"name": "Monday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 1
|
"discriminant": 1
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Tuesday",
|
"name": "Tuesday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 2
|
"discriminant": 2
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Wednesday",
|
"name": "Wednesday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 3
|
"discriminant": 3
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Thursday",
|
"name": "Thursday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 4
|
"discriminant": 4
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Friday",
|
"name": "Friday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 5
|
"discriminant": 5
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Saturday",
|
"name": "Saturday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -79,7 +79,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 6
|
"discriminant": 6
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Sunday",
|
"name": "Sunday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
}
|
}
|
||||||
@@ -90,15 +90,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "TupleMaybeSigned",
|
"displayName": "TupleMaybeSigned",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32",
|
"type": "i32",
|
||||||
"name": "Signed"
|
"name": "Signed"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "Unsigned"
|
"name": "Unsigned"
|
||||||
}
|
}
|
||||||
@@ -109,13 +109,13 @@
|
|||||||
{
|
{
|
||||||
"displayName": "NamedMaybeSigned",
|
"displayName": "NamedMaybeSigned",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32",
|
"type": "i32",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
}
|
}
|
||||||
@@ -124,10 +124,10 @@
|
|||||||
"type": "{\"value\":\"i32\"}"
|
"type": "{\"value\":\"i32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
}
|
}
|
||||||
@@ -142,47 +142,47 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Color",
|
"displayName": "Color",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Red",
|
"name": "Red",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Blue",
|
"name": "Blue",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Green",
|
"name": "Green",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Yellow",
|
"name": "Yellow",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "r"
|
"name": "r"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "g"
|
"name": "g"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "b"
|
"name": "b"
|
||||||
}
|
}
|
||||||
@@ -191,25 +191,25 @@
|
|||||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "r"
|
"name": "r"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "g"
|
"name": "g"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "b"
|
"name": "b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "a"
|
"name": "a"
|
||||||
}
|
}
|
||||||
@@ -227,13 +227,13 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Weekday",
|
"displayName": "Weekday",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 0
|
"discriminant": 0
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Monday",
|
"name": "Monday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 1
|
"discriminant": 1
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Tuesday",
|
"name": "Tuesday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -249,7 +249,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 2
|
"discriminant": 2
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Wednesday",
|
"name": "Wednesday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -257,7 +257,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 3
|
"discriminant": 3
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Thursday",
|
"name": "Thursday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -265,7 +265,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 4
|
"discriminant": 4
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Friday",
|
"name": "Friday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -273,7 +273,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 5
|
"discriminant": 5
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Saturday",
|
"name": "Saturday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
},
|
},
|
||||||
@@ -281,7 +281,7 @@
|
|||||||
"ext": {
|
"ext": {
|
||||||
"discriminant": 6
|
"discriminant": 6
|
||||||
},
|
},
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"name": "Sunday",
|
"name": "Sunday",
|
||||||
"type": "Null"
|
"type": "Null"
|
||||||
}
|
}
|
||||||
@@ -291,15 +291,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "TupleMaybeSigned",
|
"displayName": "TupleMaybeSigned",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32",
|
"type": "i32",
|
||||||
"name": "Signed"
|
"name": "Signed"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "Unsigned"
|
"name": "Unsigned"
|
||||||
}
|
}
|
||||||
@@ -309,13 +309,13 @@
|
|||||||
{
|
{
|
||||||
"displayName": "NamedMaybeSigned",
|
"displayName": "NamedMaybeSigned",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "i32",
|
"type": "i32",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
}
|
}
|
||||||
@@ -324,10 +324,10 @@
|
|||||||
"type": "{\"value\":\"i32\"}"
|
"type": "{\"value\":\"i32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
}
|
}
|
||||||
@@ -341,47 +341,47 @@
|
|||||||
{
|
{
|
||||||
"displayName": "Color",
|
"displayName": "Color",
|
||||||
"namespace": "enum_example::enum_example",
|
"namespace": "enum_example::enum_example",
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Red",
|
"name": "Red",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Blue",
|
"name": "Blue",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Green",
|
"name": "Green",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [],
|
"sub": [],
|
||||||
"name": "Yellow",
|
"name": "Yellow",
|
||||||
"type": "()"
|
"type": "()"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "r"
|
"name": "r"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "g"
|
"name": "g"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "b"
|
"name": "b"
|
||||||
}
|
}
|
||||||
@@ -390,25 +390,25 @@
|
|||||||
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
"type": "{\"r\":\"u8\",\"g\":\"u8\",\"b\":\"u8\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "r"
|
"name": "r"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "g"
|
"name": "g"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "b"
|
"name": "b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8",
|
"type": "u8",
|
||||||
"name": "a"
|
"name": "a"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128"
|
"type": "u128"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "Header",
|
"displayName": "Header",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "last_vacant"
|
"name": "last_vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len"
|
"name": "len"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "len_entries"
|
"name": "len_entries"
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
"type": "{\"last_vacant\":\"u32\",\"len\":\"u32\",\"len_entries\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32"
|
"type": "u32"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -37,15 +37,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -56,45 +56,45 @@
|
|||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId",
|
"type": "AccountId",
|
||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"AccountId\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 12,
|
"info": "VecFixed",
|
||||||
"length": 32,
|
"length": 32,
|
||||||
"sub": {
|
"sub": {
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
"type": "[u8;32]"
|
"type": "[u8;32]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u8"
|
"type": "u8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -106,17 +106,17 @@
|
|||||||
"namespace": "ink_storage::collections::hashmap",
|
"namespace": "ink_storage::collections::hashmap",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u128",
|
"type": "u128",
|
||||||
"name": "value"
|
"name": "value"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "key_index"
|
"name": "key_index"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
"type": "{\"value\":\"u128\",\"key_index\":\"u32\"}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -126,15 +126,15 @@
|
|||||||
{
|
{
|
||||||
"displayName": "VacantEntry",
|
"displayName": "VacantEntry",
|
||||||
"namespace": "ink_storage::collections::stash",
|
"namespace": "ink_storage::collections::stash",
|
||||||
"info": 9,
|
"info": "Struct",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "next"
|
"name": "next"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "u32",
|
"type": "u32",
|
||||||
"name": "prev"
|
"name": "prev"
|
||||||
}
|
}
|
||||||
@@ -143,18 +143,18 @@
|
|||||||
"name": "Vacant"
|
"name": "Vacant"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -162,33 +162,33 @@
|
|||||||
"name": "Occupied"
|
"name": "Occupied"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"info": 3,
|
"info": "Enum",
|
||||||
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
"type": "{\"_enum\":{\"Vacant\":\"VacantEntry\",\"Occupied\":\"(AccountId,AccountId)\"}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 10,
|
"info": "Tuple",
|
||||||
"sub": [
|
"sub": [
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"type": "(AccountId,AccountId)"
|
"type": "(AccountId,AccountId)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "Text"
|
"type": "Text"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "bool"
|
"type": "bool"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -196,10 +196,10 @@
|
|||||||
"sub": {
|
"sub": {
|
||||||
"displayName": "AccountId",
|
"displayName": "AccountId",
|
||||||
"namespace": "ink_env::types",
|
"namespace": "ink_env::types",
|
||||||
"info": 6,
|
"info": "Plain",
|
||||||
"type": "AccountId"
|
"type": "AccountId"
|
||||||
},
|
},
|
||||||
"info": 5,
|
"info": "Option",
|
||||||
"type": "Option<AccountId>"
|
"type": "Option<AccountId>"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/api-derive",
|
"name": "@polkadot/api-derive",
|
||||||
"version": "5.3.2",
|
"version": "6.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
"description": "Common functions used across Polkadot, derived from RPC calls and storage queries.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -19,16 +19,16 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/api": "5.3.2",
|
"@polkadot/api": "6.1.1",
|
||||||
"@polkadot/rpc-core": "5.3.2",
|
"@polkadot/rpc-core": "6.1.1",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"@polkadot/util": "^7.1.1",
|
"@polkadot/util": "^7.4.1",
|
||||||
"@polkadot/util-crypto": "^7.1.1",
|
"@polkadot/util-crypto": "^7.4.1",
|
||||||
"rxjs": "^7.2.0"
|
"rxjs": "^7.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^7.1.1",
|
"@polkadot/keyring": "^7.4.1",
|
||||||
"@polkadot/rpc-provider": "5.3.2"
|
"@polkadot/rpc-provider": "6.1.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,14 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Observable } from 'rxjs';
|
import type { Observable } from 'rxjs';
|
||||||
import type { ApiInterfaceRx, QueryableStorageMultiArg } from '@polkadot/api/types';
|
import type { ApiInterfaceRx, QueryableStorageEntry } from '@polkadot/api/types';
|
||||||
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
import type { AccountData, AccountId, AccountIndex, AccountInfo, Address, Balance, Index } from '@polkadot/types/interfaces';
|
||||||
import type { ITuple } from '@polkadot/types/types';
|
import type { ITuple } from '@polkadot/types/types';
|
||||||
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
|
import type { DeriveBalancesAccount, DeriveBalancesAccountData } from '../types';
|
||||||
|
|
||||||
import { combineLatest, map, of, switchMap } from 'rxjs';
|
import { combineLatest, map, of, switchMap } from 'rxjs';
|
||||||
|
|
||||||
import { assert, isFunction } from '@polkadot/util';
|
import { isFunction } from '@polkadot/util';
|
||||||
|
|
||||||
import { memo } from '../util';
|
import { memo } from '../util';
|
||||||
|
|
||||||
@@ -39,15 +39,11 @@ function getBalance (api: ApiInterfaceRx, [freeBalance, reservedBalance, frozenF
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, balances]]: [AccountId, Result]): DeriveBalancesAccount {
|
function calcBalances (api: ApiInterfaceRx, [accountId, [accountNonce, [primary, ...additional]]]: [AccountId, Result]): DeriveBalancesAccount {
|
||||||
const primary = balances[0];
|
|
||||||
|
|
||||||
assert(primary, 'No balances retrieved for account');
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accountId,
|
accountId,
|
||||||
accountNonce,
|
accountNonce,
|
||||||
additional: balances.filter((_, index) => index !== 0).map((b) => getBalance(api, b)),
|
additional: additional.map((b) => getBalance(api, b)),
|
||||||
...getBalance(api, primary)
|
...getBalance(api, primary)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -66,34 +62,44 @@ function queryBalancesFree (api: ApiInterfaceRx, accountId: AccountId): Observab
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function querySystemNonce (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
function queryNonceOnly (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||||
return api.query.system.accountNonce<Index>(accountId).pipe(
|
const fill = (nonce: Index): Result => [
|
||||||
map((accountNonce): Result => [
|
nonce,
|
||||||
accountNonce,
|
|
||||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||||
])
|
];
|
||||||
);
|
|
||||||
|
return isFunction(api.query.system.account)
|
||||||
|
? api.query.system.account(accountId).pipe(
|
||||||
|
map(({ nonce }) => fill(nonce))
|
||||||
|
)
|
||||||
|
: isFunction(api.query.system.accountNonce)
|
||||||
|
? api.query.system.accountNonce<Index>(accountId).pipe(
|
||||||
|
map((nonce) => fill(nonce))
|
||||||
|
)
|
||||||
|
: of(fill(api.registry.createType('Index')));
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
function queryBalancesAccount (api: ApiInterfaceRx, accountId: AccountId, modules: string[] = ['balances']): Observable<Result> {
|
||||||
const balances = modules.map(
|
const balances = modules
|
||||||
(m): QueryableStorageMultiArg<'rxjs'> => [
|
.map((m): QueryableStorageEntry<'rxjs'> => (api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m]?.account)
|
||||||
(api.derive as DeriveCustomAccount)[m]?.customAccount || api.query[m].account,
|
.filter((q) => isFunction(q))
|
||||||
accountId
|
.map((q): [QueryableStorageEntry<'rxjs'>, AccountId] => [q, accountId]);
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
const extract = (data: AccountData[]) =>
|
const extract = (nonce: Index, data: AccountData[]): Result => [
|
||||||
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen]);
|
nonce,
|
||||||
|
data.map(({ feeFrozen, free, miscFrozen, reserved }): BalanceResult => [free, reserved, feeFrozen, miscFrozen])
|
||||||
|
];
|
||||||
|
|
||||||
// NOTE this is for the first case where we do have instances specified
|
// NOTE this is for the first case where we do have instances specified
|
||||||
return isFunction(api.query.system.account)
|
return balances.length
|
||||||
|
? isFunction(api.query.system.account)
|
||||||
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
? api.queryMulti<[AccountInfo, ...(AccountData[])]>([[api.query.system.account, accountId], ...balances]).pipe(
|
||||||
map(([{ nonce }, ...balances]): Result => [nonce, extract(balances)])
|
map(([{ nonce }, ...balances]) => extract(nonce, balances))
|
||||||
)
|
)
|
||||||
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
: api.queryMulti<[Index, ...(AccountData[])]>([[api.query.system.accountNonce, accountId], ...balances]).pipe(
|
||||||
map(([nonce, ...balances]): Result => [nonce, extract(balances)])
|
map(([nonce, ...balances]) => extract(nonce, balances))
|
||||||
);
|
)
|
||||||
|
: queryNonceOnly(api, accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observable<Result> {
|
||||||
@@ -140,10 +146,6 @@ function querySystemAccount (api: ApiInterfaceRx, accountId: AccountId): Observa
|
|||||||
*/
|
*/
|
||||||
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
export function account (instanceId: string, api: ApiInterfaceRx): (address: AccountIndex | AccountId | Address | string) => Observable<DeriveBalancesAccount> {
|
||||||
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
const balanceInstances = api.registry.getModuleInstances(api.runtimeVersion.specName.toString(), 'balances');
|
||||||
const empty: Result = [
|
|
||||||
api.registry.createType('Index'),
|
|
||||||
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
|
||||||
];
|
|
||||||
|
|
||||||
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
return memo(instanceId, (address: AccountIndex | AccountId | Address | string): Observable<DeriveBalancesAccount> =>
|
||||||
api.derive.accounts.accountId(address).pipe(
|
api.derive.accounts.accountId(address).pipe(
|
||||||
@@ -159,11 +161,12 @@ export function account (instanceId: string, api: ApiInterfaceRx): (address: Acc
|
|||||||
? queryBalancesAccount(api, accountId)
|
? queryBalancesAccount(api, accountId)
|
||||||
: isFunction(api.query.balances?.freeBalance)
|
: isFunction(api.query.balances?.freeBalance)
|
||||||
? queryBalancesFree(api, accountId)
|
? queryBalancesFree(api, accountId)
|
||||||
: isFunction(api.query.system?.accountNonce)
|
: queryNonceOnly(api, accountId)
|
||||||
? querySystemNonce(api, accountId)
|
|
||||||
: of(empty)
|
|
||||||
])
|
])
|
||||||
: of([api.registry.createType('AccountId'), empty])
|
: of([api.registry.createType('AccountId'), [
|
||||||
|
api.registry.createType('Index'),
|
||||||
|
[[zeroBalance(api), zeroBalance(api), zeroBalance(api), zeroBalance(api)]]
|
||||||
|
]])
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
map((result): DeriveBalancesAccount => calcBalances(api, result))
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ function calcBalances (api: ApiInterfaceRx, [data, bestNumber, [vesting, allLock
|
|||||||
// Calculate the vesting balances,
|
// Calculate the vesting balances,
|
||||||
// - offset = balance locked at startingBlock
|
// - offset = balance locked at startingBlock
|
||||||
// - perBlock is the unlock amount
|
// - perBlock is the unlock amount
|
||||||
const { locked: vestingTotal, perBlock, startingBlock } = vesting || api.registry.createType('VestingInfo');
|
const emptyVest = api.registry.createType('VestingInfo');
|
||||||
|
const { locked: vestingTotal, perBlock, startingBlock } = vesting || emptyVest;
|
||||||
const isStarted = bestNumber.gt(startingBlock);
|
const isStarted = bestNumber.gt(startingBlock);
|
||||||
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
const vestedNow = isStarted ? perBlock.mul(bestNumber.sub(startingBlock)) : new BN(0);
|
||||||
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
const vestedBalance = vestedNow.gt(vestingTotal) ? vestingTotal : api.registry.createType('Balance', vestedNow);
|
||||||
@@ -117,33 +118,29 @@ const isNonNullable = <T>(nullable: T): nullable is NonNullable<T> => !!nullable
|
|||||||
|
|
||||||
// current (balances, vesting)
|
// current (balances, vesting)
|
||||||
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
function queryCurrent (api: ApiInterfaceRx, accountId: AccountId, balanceInstances: string[] = ['balances']): Observable<ResultBalance> {
|
||||||
const lockCalls = balanceInstances.map(
|
const calls = balanceInstances.map((m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
|
||||||
(m): ApiInterfaceRx['query']['balances']['locks'] | undefined =>
|
|
||||||
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
|
(api.derive as DeriveCustomLocks)[m]?.customLocks || api.query[m as 'balances']?.locks
|
||||||
);
|
);
|
||||||
|
const lockEmpty = calls.map((c) => !c);
|
||||||
const lockEmpty = lockCalls.map((c) => !c);
|
const queries = calls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
||||||
const lockQueries = lockCalls.filter(isNonNullable).map((c): QueryableStorageMultiArg<'rxjs'> => [c, accountId]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
api.query.vesting?.vesting
|
api.query.vesting?.vesting
|
||||||
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([
|
? api.queryMulti<[Option<VestingInfo>, ...BalanceLocks]>([[api.query.vesting.vesting, accountId], ...queries])
|
||||||
[api.query.vesting.vesting, accountId],
|
|
||||||
...lockQueries
|
|
||||||
])
|
|
||||||
// TODO We need to check module instances here as well, not only the balances module
|
// TODO We need to check module instances here as well, not only the balances module
|
||||||
: lockQueries.length
|
: queries.length
|
||||||
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(lockQueries).pipe(
|
? api.queryMulti<[...(Vec<BalanceLock>)[]]>(queries).pipe(
|
||||||
map((locks): [Option<VestingInfo>, ...BalanceLocks] =>
|
map((r): [Option<VestingInfo>, ...BalanceLocks] => [api.registry.createType('Option<VestingInfo>'), ...r])
|
||||||
[api.registry.createType('Option<VestingInfo>'), ...locks]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
|
: of([api.registry.createType('Option<VestingInfo>')] as [Option<VestingInfo>])
|
||||||
).pipe(
|
).pipe(
|
||||||
map(([optVesting, ...locks]): ResultBalance => {
|
map(([opt, ...locks]): ResultBalance => {
|
||||||
let offset = -1;
|
let offset = -1;
|
||||||
|
|
||||||
return [optVesting.unwrapOr(null), lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])];
|
return [
|
||||||
|
opt.unwrapOr(null),
|
||||||
|
lockEmpty.map((e) => e ? api.registry.createType('Vec<BalanceLock>') : locks[++offset])
|
||||||
|
];
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function queryScheduler (api: ApiInterfaceRx): Observable<DeriveDispatch[]> {
|
|||||||
const id = scheduled.maybeId.unwrap().toHex();
|
const id = scheduled.maybeId.unwrap().toHex();
|
||||||
|
|
||||||
if (id.startsWith(DEMOCRACY_ID)) {
|
if (id.startsWith(DEMOCRACY_ID)) {
|
||||||
const [, index] = api.registry.createType('(u64, ReferendumIndex)' as any, id) as ITuple<[u64, ReferendumIndex]>;
|
const [, index] = api.registry.createType<ITuple<[u64, ReferendumIndex]>>('(u64, ReferendumIndex)', id);
|
||||||
const imageHash = scheduled.call.args[0] as Hash;
|
const imageHash = scheduled.call.args[0] as Hash;
|
||||||
|
|
||||||
result.push({ at, imageHash, index });
|
result.push({ at, imageHash, index });
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
|||||||
import { ExactDerive } from '.';
|
import { ExactDerive } from '.';
|
||||||
|
|
||||||
const testFunction = (api: ApiRx): any => {
|
const testFunction = (api: ApiRx): any => {
|
||||||
return <
|
return <S extends keyof ExactDerive, M extends keyof (typeof api.derive[S])>(section: S, method: M, inputs: any[]): void => {
|
||||||
Section extends keyof ExactDerive,
|
|
||||||
Method extends keyof (typeof api.derive[Section])
|
|
||||||
>(section: Section, method: Method, inputs: any[]): void => {
|
|
||||||
describe(`derive.${section}.${method}`, (): void => {
|
describe(`derive.${section}.${method}`, (): void => {
|
||||||
it('should be a function', (): void => {
|
it('should be a function', (): void => {
|
||||||
expect(typeof api.derive[section][method]).toBe('function');
|
expect(typeof api.derive[section][method]).toBe('function');
|
||||||
@@ -81,7 +78,8 @@ describe('derive', (): void => {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
provider: new MockProvider(registry),
|
provider: new MockProvider(registry),
|
||||||
registry
|
registry,
|
||||||
|
throwOnConnect: true
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeAll((done): void => {
|
beforeAll((done): void => {
|
||||||
@@ -96,7 +94,7 @@ describe('derive', (): void => {
|
|||||||
testFunction(api)('balances', 'fees', ['a', 'b']);
|
testFunction(api)('balances', 'fees', ['a', 'b']);
|
||||||
|
|
||||||
// new
|
// new
|
||||||
testFunction(api)('custom' as any, 'test', [1, 2, 3]);
|
testFunction(api)('custom', 'test', [1, 2, 3]);
|
||||||
|
|
||||||
// existing
|
// existing
|
||||||
testFunction(api)('chain', 'bestNumber', []);
|
testFunction(api)('chain', 'bestNumber', []);
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Auto-generated by @polkadot/dev, do not edit
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api-derive', version: '5.3.2' };
|
export const packageInfo = { name: '@polkadot/api-derive', version: '6.1.1' };
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
// Copyright 2017-2021 @polkadot/api-derive authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Option, u32 } from '@polkadot/types';
|
import type { Option, u32, u64 } from '@polkadot/types';
|
||||||
import type { BlockNumber, EraIndex, Moment, SessionIndex } from '@polkadot/types/interfaces';
|
import type { BlockNumber, EraIndex, Moment, SessionIndex } from '@polkadot/types/interfaces';
|
||||||
|
|
||||||
export interface DeriveSessionIndexes {
|
export interface DeriveSessionIndexes {
|
||||||
@@ -15,7 +15,7 @@ export interface DeriveSessionIndexes {
|
|||||||
export interface DeriveSessionInfo extends DeriveSessionIndexes {
|
export interface DeriveSessionInfo extends DeriveSessionIndexes {
|
||||||
eraLength: BlockNumber;
|
eraLength: BlockNumber;
|
||||||
isEpoch: boolean;
|
isEpoch: boolean;
|
||||||
sessionLength: BlockNumber;
|
sessionLength: u64;
|
||||||
sessionsPerEra: SessionIndex;
|
sessionsPerEra: SessionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import { ApiPromise, WsProvider } from '@polkadot/api';
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
||||||
import { Metadata, TypeRegistry } from '@polkadot/types';
|
import { Metadata, TypeRegistry } from '@polkadot/types';
|
||||||
import metaStatic from '@polkadot/types/metadata/static-substrate';
|
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||||
|
|
||||||
export function createApiWithAugmentations (): ApiPromise {
|
export function createApiWithAugmentations (): ApiPromise {
|
||||||
const registry = new TypeRegistry();
|
const registry = new TypeRegistry();
|
||||||
|
|||||||
@@ -7,13 +7,13 @@ The API wrappers provide a standard interface for use -
|
|||||||
- A static `.create(<optional ApiOptions>)` that returns an API instance when connected, decorated and ready-to use. ApiOptions can include an optional WsProvider and optional custom type definitions `{ provider: <Optional WsProvider>, types: <Optional RegistryTypes> }`.
|
- A static `.create(<optional ApiOptions>)` that returns an API instance when connected, decorated and ready-to use. ApiOptions can include an optional WsProvider and optional custom type definitions `{ provider: <Optional WsProvider>, types: <Optional RegistryTypes> }`.
|
||||||
- The above is just a wrapper for `new Api(<optional ApiOptions>) `, exposing the `isReady` getter
|
- The above is just a wrapper for `new Api(<optional ApiOptions>) `, exposing the `isReady` getter
|
||||||
- `api.rpc.<section>.<method>` provides access to actual RPC calls, be it for queries, submission or retrieving chain information
|
- `api.rpc.<section>.<method>` provides access to actual RPC calls, be it for queries, submission or retrieving chain information
|
||||||
- [RPC (node interface)](https://polkadot.js.org/docs/substrate/rpc.html)
|
- [RPC (node interface)](https://polkadot.js.org/docs/substrate/rpc)
|
||||||
- `api.query.<section>.<method>` provides access to chain state queries. These are dynamically populated based on what the runtime provides
|
- `api.query.<section>.<method>` provides access to chain state queries. These are dynamically populated based on what the runtime provides
|
||||||
- [Storage chain state (runtime node interface)](https://polkadot.js.org/docs/substrate/storage.html)
|
- [Storage chain state (runtime node interface)](https://polkadot.js.org/docs/substrate/storage)
|
||||||
- `api.tx.<section>.<method>` provides the ability to create a transaction, like chain state, this list is populated from a runtime query
|
- `api.tx.<section>.<method>` provides the ability to create a transaction, like chain state, this list is populated from a runtime query
|
||||||
- [Extrinsics (runtime node interface)](https://polkadot.js.org/docs/substrate/extrinsics.html)
|
- [Extrinsics (runtime node interface)](https://polkadot.js.org/docs/substrate/extrinsics)
|
||||||
- `api.consts.<section>.<constant>` provides access to the module constants (parameter types).
|
- `api.consts.<section>.<constant>` provides access to the module constants (parameter types).
|
||||||
- [Constants (runtime node interface)](https://polkadot.js.org/docs/substrate/constants.html)
|
- [Constants (runtime node interface)](https://polkadot.js.org/docs/substrate/constants)
|
||||||
|
|
||||||
## API Selection
|
## API Selection
|
||||||
|
|
||||||
|
|||||||
+11
-11
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/api",
|
"name": "@polkadot/api",
|
||||||
"version": "5.3.2",
|
"version": "6.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
"description": "Promise and RxJS wrappers around the Polkadot JS RPC",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -19,16 +19,16 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/api-derive": "5.3.2",
|
"@polkadot/api-derive": "6.1.1",
|
||||||
"@polkadot/keyring": "^7.1.1",
|
"@polkadot/keyring": "^7.4.1",
|
||||||
"@polkadot/rpc-core": "5.3.2",
|
"@polkadot/rpc-core": "6.1.1",
|
||||||
"@polkadot/rpc-provider": "5.3.2",
|
"@polkadot/rpc-provider": "6.1.1",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"@polkadot/types-known": "5.3.2",
|
"@polkadot/types-known": "6.1.1",
|
||||||
"@polkadot/util": "^7.1.1",
|
"@polkadot/util": "^7.4.1",
|
||||||
"@polkadot/util-crypto": "^7.1.1",
|
"@polkadot/util-crypto": "^7.4.1",
|
||||||
"eventemitter3": "^4.0.7",
|
"eventemitter3": "^4.0.7",
|
||||||
"rxjs": "^7.2.0"
|
"rxjs": "^7.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+143
-176
@@ -1,17 +1,11 @@
|
|||||||
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
|
||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import type { Vec, bool, u16, u32, u64 } from '@polkadot/types';
|
|
||||||
import type { Codec } from '@polkadot/types/types';
|
|
||||||
import type { Schedule } from '@polkadot/types/interfaces/contracts';
|
|
||||||
import type { Balance, BalanceOf, BlockNumber, LockIdentifier, Moment, PalletId, Perbill, Percent, Permill, RuntimeDbWeight, TransactionPriority, Weight } from '@polkadot/types/interfaces/runtime';
|
|
||||||
import type { SessionIndex } from '@polkadot/types/interfaces/session';
|
|
||||||
import type { EraIndex } from '@polkadot/types/interfaces/staking';
|
|
||||||
import type { RuntimeVersion } from '@polkadot/types/interfaces/state';
|
|
||||||
import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
|
|
||||||
import type { BlockLength, BlockWeights } from '@polkadot/types/interfaces/system';
|
|
||||||
import type { DepositBalanceOf } from '@polkadot/types/interfaces/uniques';
|
|
||||||
import type { ApiTypes } from '@polkadot/api/types';
|
import type { ApiTypes } from '@polkadot/api/types';
|
||||||
|
import type { U8aFixed, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types';
|
||||||
|
import type { Perbill, Percent, Permill } from '@polkadot/types/interfaces/runtime';
|
||||||
|
import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, PalletContractsSchedule, SpVersionRuntimeVersion } from '@polkadot/types/lookup';
|
||||||
|
import type { Codec } from '@polkadot/types/types';
|
||||||
|
|
||||||
declare module '@polkadot/api/types/consts' {
|
declare module '@polkadot/api/types/consts' {
|
||||||
export interface AugmentedConsts<ApiType> {
|
export interface AugmentedConsts<ApiType> {
|
||||||
@@ -19,20 +13,20 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The amount of funds that must be reserved when creating a new approval.
|
* The amount of funds that must be reserved when creating a new approval.
|
||||||
**/
|
**/
|
||||||
approvalDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
approvalDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The basic amount of funds that must be reserved for an asset.
|
* The basic amount of funds that must be reserved for an asset.
|
||||||
**/
|
**/
|
||||||
assetDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
assetDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The basic amount of funds that must be reserved when adding metadata to your asset.
|
* The basic amount of funds that must be reserved when adding metadata to your asset.
|
||||||
**/
|
**/
|
||||||
metadataDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
|
metadataDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The additional funds that must be reserved for the number of bytes you store in your
|
* The additional funds that must be reserved for the number of bytes you store in your
|
||||||
* metadata.
|
* metadata.
|
||||||
**/
|
**/
|
||||||
metadataDepositPerByte: DepositBalanceOf & AugmentedConst<ApiType>;
|
metadataDepositPerByte: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum length of a name or symbol stored on-chain.
|
* The maximum length of a name or symbol stored on-chain.
|
||||||
**/
|
**/
|
||||||
@@ -48,7 +42,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* This means that we will deal with uncle-parents that are
|
* This means that we will deal with uncle-parents that are
|
||||||
* `UncleGenerations + 1` before `now`.
|
* `UncleGenerations + 1` before `now`.
|
||||||
**/
|
**/
|
||||||
uncleGenerations: BlockNumber & AugmentedConst<ApiType>;
|
uncleGenerations: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -68,7 +62,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* duration and the security parameter `c` (where `1 - c` represents
|
* duration and the security parameter `c` (where `1 - c` represents
|
||||||
* the probability of a slot being empty).
|
* the probability of a slot being empty).
|
||||||
**/
|
**/
|
||||||
expectedBlockTime: Moment & AugmentedConst<ApiType>;
|
expectedBlockTime: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -78,7 +72,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The minimum amount required to keep an account open.
|
* The minimum amount required to keep an account open.
|
||||||
**/
|
**/
|
||||||
existentialDeposit: Balance & AugmentedConst<ApiType>;
|
existentialDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum number of locks that should exist on an account.
|
* The maximum number of locks that should exist on an account.
|
||||||
* Not strictly enforced, but used for weight estimation.
|
* Not strictly enforced, but used for weight estimation.
|
||||||
@@ -101,23 +95,23 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The amount held on deposit for placing a bounty proposal.
|
* The amount held on deposit for placing a bounty proposal.
|
||||||
**/
|
**/
|
||||||
bountyDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
bountyDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The delay period for which a bounty beneficiary need to wait before claim the payout.
|
* The delay period for which a bounty beneficiary need to wait before claim the payout.
|
||||||
**/
|
**/
|
||||||
bountyDepositPayoutDelay: BlockNumber & AugmentedConst<ApiType>;
|
bountyDepositPayoutDelay: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Bounty duration in blocks.
|
* Bounty duration in blocks.
|
||||||
**/
|
**/
|
||||||
bountyUpdatePeriod: BlockNumber & AugmentedConst<ApiType>;
|
bountyUpdatePeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Minimum value for a bounty.
|
* Minimum value for a bounty.
|
||||||
**/
|
**/
|
||||||
bountyValueMinimum: BalanceOf & AugmentedConst<ApiType>;
|
bountyValueMinimum: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount held on deposit per byte within bounty description.
|
* The amount held on deposit per byte within bounty description.
|
||||||
**/
|
**/
|
||||||
dataDepositPerByte: BalanceOf & AugmentedConst<ApiType>;
|
dataDepositPerByte: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Maximum acceptable reason length.
|
* Maximum acceptable reason length.
|
||||||
**/
|
**/
|
||||||
@@ -128,6 +122,13 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
};
|
};
|
||||||
contracts: {
|
contracts: {
|
||||||
|
/**
|
||||||
|
* The deposit that must be placed into the contract's account to instantiate it.
|
||||||
|
* This is in **addition** to the [`pallet_balances::Pallet::ExistenialDeposit`].
|
||||||
|
* The minimum balance for a contract's account can be queried using
|
||||||
|
* [`Pallet::subsistence_threshold`].
|
||||||
|
**/
|
||||||
|
contractDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum number of tries that can be queued for deletion.
|
* The maximum number of tries that can be queued for deletion.
|
||||||
**/
|
**/
|
||||||
@@ -135,61 +136,11 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The maximum amount of weight that can be consumed per block for lazy trie removal.
|
* The maximum amount of weight that can be consumed per block for lazy trie removal.
|
||||||
**/
|
**/
|
||||||
deletionWeightLimit: Weight & AugmentedConst<ApiType>;
|
deletionWeightLimit: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
|
||||||
* The balance every contract needs to deposit to stay alive indefinitely.
|
|
||||||
*
|
|
||||||
* This is different from the [`Self::TombstoneDeposit`] because this only needs to be
|
|
||||||
* deposited while the contract is alive. Costs for additional storage are added to
|
|
||||||
* this base cost.
|
|
||||||
*
|
|
||||||
* This is a simple way to ensure that contracts with empty storage eventually get deleted by
|
|
||||||
* making them pay rent. This creates an incentive to remove them early in order to save rent.
|
|
||||||
**/
|
|
||||||
depositPerContract: BalanceOf & AugmentedConst<ApiType>;
|
|
||||||
/**
|
|
||||||
* The balance a contract needs to deposit per storage byte to stay alive indefinitely.
|
|
||||||
*
|
|
||||||
* Let's suppose the deposit is 1,000 BU (balance units)/byte and the rent is 1 BU/byte/day,
|
|
||||||
* then a contract with 1,000,000 BU that uses 1,000 bytes of storage would pay no rent.
|
|
||||||
* But if the balance reduced to 500,000 BU and the storage stayed the same at 1,000,
|
|
||||||
* then it would pay 500 BU/day.
|
|
||||||
**/
|
|
||||||
depositPerStorageByte: BalanceOf & AugmentedConst<ApiType>;
|
|
||||||
/**
|
|
||||||
* The balance a contract needs to deposit per storage item to stay alive indefinitely.
|
|
||||||
*
|
|
||||||
* It works the same as [`Self::DepositPerStorageByte`] but for storage items.
|
|
||||||
**/
|
|
||||||
depositPerStorageItem: BalanceOf & AugmentedConst<ApiType>;
|
|
||||||
/**
|
|
||||||
* The fraction of the deposit that should be used as rent per block.
|
|
||||||
*
|
|
||||||
* When a contract hasn't enough balance deposited to stay alive indefinitely it needs
|
|
||||||
* to pay per block for the storage it consumes that is not covered by the deposit.
|
|
||||||
* This determines how high this rent payment is per block as a fraction of the deposit.
|
|
||||||
**/
|
|
||||||
rentFraction: Perbill & AugmentedConst<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Cost schedule and limits.
|
* Cost schedule and limits.
|
||||||
**/
|
**/
|
||||||
schedule: Schedule & AugmentedConst<ApiType>;
|
schedule: PalletContractsSchedule & AugmentedConst<ApiType>;
|
||||||
/**
|
|
||||||
* Number of block delay an extrinsic claim surcharge has.
|
|
||||||
*
|
|
||||||
* When claim surcharge is called by an extrinsic the rent is checked
|
|
||||||
* for current_block - delay
|
|
||||||
**/
|
|
||||||
signedClaimHandicap: BlockNumber & AugmentedConst<ApiType>;
|
|
||||||
/**
|
|
||||||
* Reward that is received by the party whose touch has led
|
|
||||||
* to removal of a contract.
|
|
||||||
**/
|
|
||||||
surchargeReward: BalanceOf & AugmentedConst<ApiType>;
|
|
||||||
/**
|
|
||||||
* The minimum amount required to generate a tombstone.
|
|
||||||
**/
|
|
||||||
tombstoneDeposit: BalanceOf & AugmentedConst<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -199,29 +150,29 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
* Period in blocks where an external proposal may not be re-submitted after being vetoed.
|
||||||
**/
|
**/
|
||||||
cooloffPeriod: BlockNumber & AugmentedConst<ApiType>;
|
cooloffPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The minimum period of locking and the period between a proposal being approved and enacted.
|
* The period between a proposal being approved and enacted.
|
||||||
*
|
*
|
||||||
* It should generally be a little more than the unstake period to ensure that
|
* It should generally be a little more than the unstake period to ensure that
|
||||||
* voting stakers have an opportunity to remove themselves from the system in the case where
|
* voting stakers have an opportunity to remove themselves from the system in the case
|
||||||
* they are on the losing side of a vote.
|
* where they are on the losing side of a vote.
|
||||||
**/
|
**/
|
||||||
enactmentPeriod: BlockNumber & AugmentedConst<ApiType>;
|
enactmentPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Minimum voting period allowed for a fast-track referendum.
|
* Minimum voting period allowed for a fast-track referendum.
|
||||||
**/
|
**/
|
||||||
fastTrackVotingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
fastTrackVotingPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Indicator for whether an emergency origin is even allowed to happen. Some chains may want
|
* Indicator for whether an emergency origin is even allowed to happen. Some chains may
|
||||||
* to set this permanently to `false`, others may want to condition it on things such as
|
* want to set this permanently to `false`, others may want to condition it on things such
|
||||||
* an upgrade having happened recently.
|
* as an upgrade having happened recently.
|
||||||
**/
|
**/
|
||||||
instantAllowed: bool & AugmentedConst<ApiType>;
|
instantAllowed: bool & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* How often (in blocks) new public referenda are launched.
|
* How often (in blocks) new public referenda are launched.
|
||||||
**/
|
**/
|
||||||
launchPeriod: BlockNumber & AugmentedConst<ApiType>;
|
launchPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum number of public proposals that can exist at any time.
|
* The maximum number of public proposals that can exist at any time.
|
||||||
**/
|
**/
|
||||||
@@ -236,26 +187,28 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The minimum amount to be used as a deposit for a public referendum proposal.
|
* The minimum amount to be used as a deposit for a public referendum proposal.
|
||||||
**/
|
**/
|
||||||
minimumDeposit: BalanceOf & AugmentedConst<ApiType>;
|
minimumDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of balance that must be deposited per byte of preimage stored.
|
* The amount of balance that must be deposited per byte of preimage stored.
|
||||||
**/
|
**/
|
||||||
preimageByteDeposit: BalanceOf & AugmentedConst<ApiType>;
|
preimageByteDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* The minimum period of vote locking.
|
||||||
|
*
|
||||||
|
* It should be no shorter than enactment period to ensure that in the case of an approval,
|
||||||
|
* those successful voters are locked into the consequences that their votes entail.
|
||||||
|
**/
|
||||||
|
voteLockingPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* How often (in blocks) to check for new votes.
|
* How often (in blocks) to check for new votes.
|
||||||
**/
|
**/
|
||||||
votingPeriod: BlockNumber & AugmentedConst<ApiType>;
|
votingPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
};
|
};
|
||||||
electionProviderMultiPhase: {
|
electionProviderMultiPhase: {
|
||||||
/**
|
|
||||||
* Maximum number of iteration of balancing that will be executed in the embedded miner of
|
|
||||||
* the pallet.
|
|
||||||
**/
|
|
||||||
minerMaxIterations: u32 & AugmentedConst<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Maximum length (bytes) that the mined solution should consume.
|
* Maximum length (bytes) that the mined solution should consume.
|
||||||
*
|
*
|
||||||
@@ -269,30 +222,30 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* The miner will ensure that the total weight of the unsigned solution will not exceed
|
* The miner will ensure that the total weight of the unsigned solution will not exceed
|
||||||
* this value, based on [`WeightInfo::submit_unsigned`].
|
* this value, based on [`WeightInfo::submit_unsigned`].
|
||||||
**/
|
**/
|
||||||
minerMaxWeight: Weight & AugmentedConst<ApiType>;
|
minerMaxWeight: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The priority of the unsigned transaction submitted in the unsigned-phase
|
* The priority of the unsigned transaction submitted in the unsigned-phase
|
||||||
**/
|
**/
|
||||||
minerTxPriority: TransactionPriority & AugmentedConst<ApiType>;
|
minerTxPriority: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The repeat threshold of the offchain worker.
|
* The repeat threshold of the offchain worker.
|
||||||
*
|
*
|
||||||
* For example, if it is 5, that means that at least 5 blocks will elapse between attempts
|
* For example, if it is 5, that means that at least 5 blocks will elapse between attempts
|
||||||
* to submit the worker's solution.
|
* to submit the worker's solution.
|
||||||
**/
|
**/
|
||||||
offchainRepeat: BlockNumber & AugmentedConst<ApiType>;
|
offchainRepeat: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Base deposit for a signed solution.
|
* Base deposit for a signed solution.
|
||||||
**/
|
**/
|
||||||
signedDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
signedDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Per-byte deposit for a signed solution.
|
* Per-byte deposit for a signed solution.
|
||||||
**/
|
**/
|
||||||
signedDepositByte: BalanceOf & AugmentedConst<ApiType>;
|
signedDepositByte: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Per-weight deposit for a signed solution.
|
* Per-weight deposit for a signed solution.
|
||||||
**/
|
**/
|
||||||
signedDepositWeight: BalanceOf & AugmentedConst<ApiType>;
|
signedDepositWeight: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Maximum number of signed submissions that can be queued.
|
* Maximum number of signed submissions that can be queued.
|
||||||
*
|
*
|
||||||
@@ -308,15 +261,15 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
*
|
*
|
||||||
* This should probably be similar to [`Config::MinerMaxWeight`].
|
* This should probably be similar to [`Config::MinerMaxWeight`].
|
||||||
**/
|
**/
|
||||||
signedMaxWeight: Weight & AugmentedConst<ApiType>;
|
signedMaxWeight: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Duration of the signed phase.
|
* Duration of the signed phase.
|
||||||
**/
|
**/
|
||||||
signedPhase: BlockNumber & AugmentedConst<ApiType>;
|
signedPhase: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Base reward for a signed solution
|
* Base reward for a signed solution
|
||||||
**/
|
**/
|
||||||
signedRewardBase: BalanceOf & AugmentedConst<ApiType>;
|
signedRewardBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The minimum amount of improvement to the solution score that defines a solution as
|
* The minimum amount of improvement to the solution score that defines a solution as
|
||||||
* "better" (in any phase).
|
* "better" (in any phase).
|
||||||
@@ -325,7 +278,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Duration of the unsigned phase.
|
* Duration of the unsigned phase.
|
||||||
**/
|
**/
|
||||||
unsignedPhase: BlockNumber & AugmentedConst<ApiType>;
|
unsignedPhase: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -335,7 +288,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* How much should be locked up in order to submit one's candidacy.
|
* How much should be locked up in order to submit one's candidacy.
|
||||||
**/
|
**/
|
||||||
candidacyBond: BalanceOf & AugmentedConst<ApiType>;
|
candidacyBond: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Number of members to elect.
|
* Number of members to elect.
|
||||||
**/
|
**/
|
||||||
@@ -347,24 +300,24 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Identifier for the elections-phragmen pallet's lock
|
* Identifier for the elections-phragmen pallet's lock
|
||||||
**/
|
**/
|
||||||
palletId: LockIdentifier & AugmentedConst<ApiType>;
|
palletId: U8aFixed & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* How long each seat is kept. This defines the next block number at which an election
|
* How long each seat is kept. This defines the next block number at which an election
|
||||||
* round will happen. If set to zero, no elections are ever triggered and the module will
|
* round will happen. If set to zero, no elections are ever triggered and the module will
|
||||||
* be in passive mode.
|
* be in passive mode.
|
||||||
**/
|
**/
|
||||||
termDuration: BlockNumber & AugmentedConst<ApiType>;
|
termDuration: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Base deposit associated with voting.
|
* Base deposit associated with voting.
|
||||||
*
|
*
|
||||||
* This should be sensibly high to economically ensure the pallet cannot be attacked by
|
* This should be sensibly high to economically ensure the pallet cannot be attacked by
|
||||||
* creating a gigantic number of votes.
|
* creating a gigantic number of votes.
|
||||||
**/
|
**/
|
||||||
votingBondBase: BalanceOf & AugmentedConst<ApiType>;
|
votingBondBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of bond that need to be locked for each vote (32 bytes).
|
* The amount of bond that need to be locked for each vote (32 bytes).
|
||||||
**/
|
**/
|
||||||
votingBondFactor: BalanceOf & AugmentedConst<ApiType>;
|
votingBondFactor: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -381,7 +334,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* The issuance to ignore. This is subtracted from the `Currency`'s `total_issuance` to get
|
* The issuance to ignore. This is subtracted from the `Currency`'s `total_issuance` to get
|
||||||
* the issuance by which we inflate or deflate the gilt.
|
* the issuance by which we inflate or deflate the gilt.
|
||||||
**/
|
**/
|
||||||
ignoredIssuance: BalanceOf & AugmentedConst<ApiType>;
|
ignoredIssuance: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The number of blocks between consecutive attempts to issue more gilts in an effort to
|
* The number of blocks between consecutive attempts to issue more gilts in an effort to
|
||||||
* get to the target amount to be frozen.
|
* get to the target amount to be frozen.
|
||||||
@@ -389,7 +342,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* A larger value results in fewer storage hits each block, but a slower period to get to
|
* A larger value results in fewer storage hits each block, but a slower period to get to
|
||||||
* the target.
|
* the target.
|
||||||
**/
|
**/
|
||||||
intakePeriod: BlockNumber & AugmentedConst<ApiType>;
|
intakePeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum amount of bids that can be turned into issued gilts each block. A larger
|
* The maximum amount of bids that can be turned into issued gilts each block. A larger
|
||||||
* value here means less of the block available for transactions should there be a glut of
|
* value here means less of the block available for transactions should there be a glut of
|
||||||
@@ -408,12 +361,12 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* It should be at least big enough to ensure that there is no possible storage spam attack
|
* It should be at least big enough to ensure that there is no possible storage spam attack
|
||||||
* or queue-filling attack.
|
* or queue-filling attack.
|
||||||
**/
|
**/
|
||||||
minFreeze: BalanceOf & AugmentedConst<ApiType>;
|
minFreeze: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The base period for the duration queues. This is the common multiple across all
|
* The base period for the duration queues. This is the common multiple across all
|
||||||
* supported freezing durations that can be bid upon.
|
* supported freezing durations that can be bid upon.
|
||||||
**/
|
**/
|
||||||
period: BlockNumber & AugmentedConst<ApiType>;
|
period: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Number of duration queues in total. This sets the maximum duration supported, which is
|
* Number of duration queues in total. This sets the maximum duration supported, which is
|
||||||
* this value multiplied by `Period`.
|
* this value multiplied by `Period`.
|
||||||
@@ -428,11 +381,11 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The amount held on deposit for a registered identity
|
* The amount held on deposit for a registered identity
|
||||||
**/
|
**/
|
||||||
basicDeposit: BalanceOf & AugmentedConst<ApiType>;
|
basicDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount held on deposit per additional field for a registered identity.
|
* The amount held on deposit per additional field for a registered identity.
|
||||||
**/
|
**/
|
||||||
fieldDeposit: BalanceOf & AugmentedConst<ApiType>;
|
fieldDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O
|
* Maximum number of additional fields that may be stored in an ID. Needed to bound the I/O
|
||||||
* required to access an identity, but can be pretty high.
|
* required to access an identity, but can be pretty high.
|
||||||
@@ -449,10 +402,10 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
maxSubAccounts: u32 & AugmentedConst<ApiType>;
|
maxSubAccounts: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount held on deposit for a registered subaccount. This should account for the fact
|
* The amount held on deposit for a registered subaccount. This should account for the fact
|
||||||
* that one storage item's value will increase by the size of an account ID, and there will be
|
* that one storage item's value will increase by the size of an account ID, and there will
|
||||||
* another trie item whose value is the size of an account ID plus 32 bytes.
|
* be another trie item whose value is the size of an account ID plus 32 bytes.
|
||||||
**/
|
**/
|
||||||
subAccountDeposit: BalanceOf & AugmentedConst<ApiType>;
|
subAccountDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -465,7 +418,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* This is exposed so that it can be tuned for particular runtime, when
|
* This is exposed so that it can be tuned for particular runtime, when
|
||||||
* multiple pallets send unsigned transactions.
|
* multiple pallets send unsigned transactions.
|
||||||
**/
|
**/
|
||||||
unsignedPriority: TransactionPriority & AugmentedConst<ApiType>;
|
unsignedPriority: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -475,7 +428,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The deposit needed for reserving an index.
|
* The deposit needed for reserving an index.
|
||||||
**/
|
**/
|
||||||
deposit: BalanceOf & AugmentedConst<ApiType>;
|
deposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -495,7 +448,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The Lottery's pallet id
|
* The Lottery's pallet id
|
||||||
**/
|
**/
|
||||||
palletId: PalletId & AugmentedConst<ApiType>;
|
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -503,20 +456,20 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
};
|
};
|
||||||
multisig: {
|
multisig: {
|
||||||
/**
|
/**
|
||||||
* The base amount of currency needed to reserve for creating a multisig execution or to store
|
* The base amount of currency needed to reserve for creating a multisig execution or to
|
||||||
* a dispatch call for later.
|
* store a dispatch call for later.
|
||||||
*
|
*
|
||||||
* This is held for an additional storage item whose value size is
|
* This is held for an additional storage item whose value size is
|
||||||
* `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is
|
* `4 + sizeof((BlockNumber, Balance, AccountId))` bytes and whose key size is
|
||||||
* `32 + sizeof(AccountId)` bytes.
|
* `32 + sizeof(AccountId)` bytes.
|
||||||
**/
|
**/
|
||||||
depositBase: BalanceOf & AugmentedConst<ApiType>;
|
depositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of currency needed per unit threshold when creating a multisig execution.
|
* The amount of currency needed per unit threshold when creating a multisig execution.
|
||||||
*
|
*
|
||||||
* This is held for adding 32 bytes more into a pre-existing storage value.
|
* This is held for adding 32 bytes more into a pre-existing storage value.
|
||||||
**/
|
**/
|
||||||
depositFactor: BalanceOf & AugmentedConst<ApiType>;
|
depositFactor: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum amount of signatories allowed in the multisig.
|
* The maximum amount of signatories allowed in the multisig.
|
||||||
**/
|
**/
|
||||||
@@ -530,16 +483,17 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The base amount of currency needed to reserve for creating an announcement.
|
* The base amount of currency needed to reserve for creating an announcement.
|
||||||
*
|
*
|
||||||
* This is held when a new storage item holding a `Balance` is created (typically 16 bytes).
|
* This is held when a new storage item holding a `Balance` is created (typically 16
|
||||||
|
* bytes).
|
||||||
**/
|
**/
|
||||||
announcementDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
announcementDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of currency needed per announcement made.
|
* The amount of currency needed per announcement made.
|
||||||
*
|
*
|
||||||
* This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes)
|
* This is held for adding an `AccountId`, `Hash` and `BlockNumber` (typically 68 bytes)
|
||||||
* into a pre-existing storage value.
|
* into a pre-existing storage value.
|
||||||
**/
|
**/
|
||||||
announcementDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
announcementDepositFactor: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum amount of time-delayed announcements that are allowed to be pending.
|
* The maximum amount of time-delayed announcements that are allowed to be pending.
|
||||||
**/
|
**/
|
||||||
@@ -554,15 +508,15 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* This is held for an additional storage item whose value size is
|
* This is held for an additional storage item whose value size is
|
||||||
* `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes.
|
* `sizeof(Balance)` bytes and whose key size is `sizeof(AccountId)` bytes.
|
||||||
**/
|
**/
|
||||||
proxyDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
proxyDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of currency needed per proxy added.
|
* The amount of currency needed per proxy added.
|
||||||
*
|
*
|
||||||
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a pre-existing
|
* This is held for adding 32 bytes plus an instance of `ProxyType` more into a
|
||||||
* storage value. Thus, when configuring `ProxyDepositFactor` one should take into account
|
* pre-existing storage value. Thus, when configuring `ProxyDepositFactor` one should take
|
||||||
* `32 + proxy_type.encode().len()` bytes of data.
|
* into account `32 + proxy_type.encode().len()` bytes of data.
|
||||||
**/
|
**/
|
||||||
proxyDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
proxyDepositFactor: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -575,13 +529,15 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* This is held for an additional storage item whose value size is
|
* This is held for an additional storage item whose value size is
|
||||||
* `2 + sizeof(BlockNumber, Balance)` bytes.
|
* `2 + sizeof(BlockNumber, Balance)` bytes.
|
||||||
**/
|
**/
|
||||||
configDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
configDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of currency needed per additional user when creating a recovery configuration.
|
* The amount of currency needed per additional user when creating a recovery
|
||||||
|
* configuration.
|
||||||
*
|
*
|
||||||
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage value.
|
* This is held for adding `sizeof(AccountId)` bytes more into a pre-existing storage
|
||||||
|
* value.
|
||||||
**/
|
**/
|
||||||
friendDepositFactor: BalanceOf & AugmentedConst<ApiType>;
|
friendDepositFactor: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum amount of friends allowed in a recovery configuration.
|
* The maximum amount of friends allowed in a recovery configuration.
|
||||||
**/
|
**/
|
||||||
@@ -595,7 +551,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
* `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable
|
* `sizeof(BlockNumber, Balance + T * AccountId)` bytes. Where T is a configurable
|
||||||
* threshold.
|
* threshold.
|
||||||
**/
|
**/
|
||||||
recoveryDeposit: BalanceOf & AugmentedConst<ApiType>;
|
recoveryDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -603,10 +559,10 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
};
|
};
|
||||||
scheduler: {
|
scheduler: {
|
||||||
/**
|
/**
|
||||||
* The maximum weight that may be scheduled per block for any dispatchables of less priority
|
* The maximum weight that may be scheduled per block for any dispatchables of less
|
||||||
* than `schedule::HARD_DEADLINE`.
|
* priority than `schedule::HARD_DEADLINE`.
|
||||||
**/
|
**/
|
||||||
maximumWeight: Weight & AugmentedConst<ApiType>;
|
maximumWeight: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum number of scheduled calls in the queue for a single block.
|
* The maximum number of scheduled calls in the queue for a single block.
|
||||||
* Not strictly enforced, but used for weight estimation.
|
* Not strictly enforced, but used for weight estimation.
|
||||||
@@ -621,11 +577,11 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The minimum amount of a deposit required for a bid to be made.
|
* The minimum amount of a deposit required for a bid to be made.
|
||||||
**/
|
**/
|
||||||
candidateDeposit: BalanceOf & AugmentedConst<ApiType>;
|
candidateDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The number of blocks between membership challenges.
|
* The number of blocks between membership challenges.
|
||||||
**/
|
**/
|
||||||
challengePeriod: BlockNumber & AugmentedConst<ApiType>;
|
challengePeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Maximum candidate intake per round.
|
* Maximum candidate intake per round.
|
||||||
**/
|
**/
|
||||||
@@ -638,20 +594,20 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The societies's module id
|
* The societies's module id
|
||||||
**/
|
**/
|
||||||
palletId: PalletId & AugmentedConst<ApiType>;
|
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of incentive paid within each period. Doesn't include VoterTip.
|
* The amount of incentive paid within each period. Doesn't include VoterTip.
|
||||||
**/
|
**/
|
||||||
periodSpend: BalanceOf & AugmentedConst<ApiType>;
|
periodSpend: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The number of blocks between candidate/membership rotation periods.
|
* The number of blocks between candidate/membership rotation periods.
|
||||||
**/
|
**/
|
||||||
rotationPeriod: BlockNumber & AugmentedConst<ApiType>;
|
rotationPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of the unpaid reward that gets deducted in the case that either a skeptic
|
* The amount of the unpaid reward that gets deducted in the case that either a skeptic
|
||||||
* doesn't vote or someone votes in the wrong way.
|
* doesn't vote or someone votes in the wrong way.
|
||||||
**/
|
**/
|
||||||
wrongSideDeduction: BalanceOf & AugmentedConst<ApiType>;
|
wrongSideDeduction: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -661,26 +617,26 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Number of eras that staked funds must remain bonded for.
|
* Number of eras that staked funds must remain bonded for.
|
||||||
**/
|
**/
|
||||||
bondingDuration: EraIndex & AugmentedConst<ApiType>;
|
bondingDuration: u32 & AugmentedConst<ApiType>;
|
||||||
maxNominations: u32 & AugmentedConst<ApiType>;
|
maxNominations: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum number of nominators rewarded for each validator.
|
* The maximum number of nominators rewarded for each validator.
|
||||||
*
|
*
|
||||||
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can claim
|
* For each validator only the `$MaxNominatorRewardedPerValidator` biggest stakers can
|
||||||
* their reward. This used to limit the i/o cost for the nominator payout.
|
* claim their reward. This used to limit the i/o cost for the nominator payout.
|
||||||
**/
|
**/
|
||||||
maxNominatorRewardedPerValidator: u32 & AugmentedConst<ApiType>;
|
maxNominatorRewardedPerValidator: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Number of sessions per era.
|
* Number of sessions per era.
|
||||||
**/
|
**/
|
||||||
sessionsPerEra: SessionIndex & AugmentedConst<ApiType>;
|
sessionsPerEra: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Number of eras that slashes are deferred by, after computation.
|
* Number of eras that slashes are deferred by, after computation.
|
||||||
*
|
*
|
||||||
* This should be less than the bonding duration. Set to 0 if slashes
|
* This should be less than the bonding duration. Set to 0 if slashes
|
||||||
* should be applied immediately, without opportunity for intervention.
|
* should be applied immediately, without opportunity for intervention.
|
||||||
**/
|
**/
|
||||||
slashDeferDuration: EraIndex & AugmentedConst<ApiType>;
|
slashDeferDuration: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -690,19 +646,19 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
* Maximum number of block number to block hash mappings to keep (oldest pruned first).
|
||||||
**/
|
**/
|
||||||
blockHashCount: BlockNumber & AugmentedConst<ApiType>;
|
blockHashCount: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum length of a block (in bytes).
|
* The maximum length of a block (in bytes).
|
||||||
**/
|
**/
|
||||||
blockLength: BlockLength & AugmentedConst<ApiType>;
|
blockLength: FrameSystemLimitsBlockLength & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Block & extrinsics weights: base values and limits.
|
* Block & extrinsics weights: base values and limits.
|
||||||
**/
|
**/
|
||||||
blockWeights: BlockWeights & AugmentedConst<ApiType>;
|
blockWeights: FrameSystemLimitsBlockWeights & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The weight of runtime database operations the runtime can invoke.
|
* The weight of runtime database operations the runtime can invoke.
|
||||||
**/
|
**/
|
||||||
dbWeight: RuntimeDbWeight & AugmentedConst<ApiType>;
|
dbWeight: FrameSupportWeightsRuntimeDbWeight & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The designated SS85 prefix of this chain.
|
* The designated SS85 prefix of this chain.
|
||||||
*
|
*
|
||||||
@@ -714,7 +670,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Get the chain's current version.
|
* Get the chain's current version.
|
||||||
**/
|
**/
|
||||||
version: RuntimeVersion & AugmentedConst<ApiType>;
|
version: SpVersionRuntimeVersion & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -722,12 +678,12 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
};
|
};
|
||||||
timestamp: {
|
timestamp: {
|
||||||
/**
|
/**
|
||||||
* The minimum period between blocks. Beware that this is different to the *expected* period
|
* The minimum period between blocks. Beware that this is different to the *expected*
|
||||||
* that the block production apparatus provides. Your chosen consensus system will generally
|
* period that the block production apparatus provides. Your chosen consensus system will
|
||||||
* work with this to determine a sensible block time. e.g. For Aura, it will be double this
|
* generally work with this to determine a sensible block time. e.g. For Aura, it will be
|
||||||
* period on default settings.
|
* double this period on default settings.
|
||||||
**/
|
**/
|
||||||
minimumPeriod: Moment & AugmentedConst<ApiType>;
|
minimumPeriod: u64 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -735,9 +691,9 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
};
|
};
|
||||||
tips: {
|
tips: {
|
||||||
/**
|
/**
|
||||||
* The amount held on deposit per byte within the tip report reason.
|
* The amount held on deposit per byte within the tip report reason or bounty description.
|
||||||
**/
|
**/
|
||||||
dataDepositPerByte: BalanceOf & AugmentedConst<ApiType>;
|
dataDepositPerByte: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Maximum acceptable reason length.
|
* Maximum acceptable reason length.
|
||||||
**/
|
**/
|
||||||
@@ -745,15 +701,15 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The period for which a tip remains open after is has achieved threshold tippers.
|
* The period for which a tip remains open after is has achieved threshold tippers.
|
||||||
**/
|
**/
|
||||||
tipCountdown: BlockNumber & AugmentedConst<ApiType>;
|
tipCountdown: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount of the final tip which goes to the original reporter of the tip.
|
* The percent of the final tip which goes to the original reporter of the tip.
|
||||||
**/
|
**/
|
||||||
tipFindersFee: Percent & AugmentedConst<ApiType>;
|
tipFindersFee: Percent & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The amount held on deposit for placing a tip report.
|
* The amount held on deposit for placing a tip report.
|
||||||
**/
|
**/
|
||||||
tipReportDepositBase: BalanceOf & AugmentedConst<ApiType>;
|
tipReportDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -763,11 +719,11 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The fee to be paid for making a transaction; the per-byte portion.
|
* The fee to be paid for making a transaction; the per-byte portion.
|
||||||
**/
|
**/
|
||||||
transactionByteFee: BalanceOf & AugmentedConst<ApiType>;
|
transactionByteFee: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The polynomial that is applied in order to derive fee from weight.
|
* The polynomial that is applied in order to derive fee from weight.
|
||||||
**/
|
**/
|
||||||
weightToFee: Vec<WeightToFeeCoefficient> & AugmentedConst<ApiType>;
|
weightToFee: Vec<FrameSupportWeightsWeightToFeeCoefficient> & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -785,7 +741,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The treasury's pallet id, used for deriving its sovereign account ID.
|
* The treasury's pallet id, used for deriving its sovereign account ID.
|
||||||
**/
|
**/
|
||||||
palletId: PalletId & AugmentedConst<ApiType>;
|
palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Fraction of a proposal's value that should be bonded in order to place the proposal.
|
* Fraction of a proposal's value that should be bonded in order to place the proposal.
|
||||||
* An accepted proposal gets these back. A rejected proposal does not.
|
* An accepted proposal gets these back. A rejected proposal does not.
|
||||||
@@ -794,11 +750,11 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* Minimum amount of funds that should be placed in a deposit for making a proposal.
|
* Minimum amount of funds that should be placed in a deposit for making a proposal.
|
||||||
**/
|
**/
|
||||||
proposalBondMinimum: BalanceOf & AugmentedConst<ApiType>;
|
proposalBondMinimum: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Period between successive spends.
|
* Period between successive spends.
|
||||||
**/
|
**/
|
||||||
spendPeriod: BlockNumber & AugmentedConst<ApiType>;
|
spendPeriod: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
@@ -808,20 +764,20 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The basic amount of funds that must be reserved when adding an attribute to an asset.
|
* The basic amount of funds that must be reserved when adding an attribute to an asset.
|
||||||
**/
|
**/
|
||||||
attributeDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
|
attributeDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The basic amount of funds that must be reserved for an asset class.
|
* The basic amount of funds that must be reserved for an asset class.
|
||||||
**/
|
**/
|
||||||
classDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
classDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The additional funds that must be reserved for the number of bytes store in metadata,
|
* The additional funds that must be reserved for the number of bytes store in metadata,
|
||||||
* either "normal" metadata or attribute metadata.
|
* either "normal" metadata or attribute metadata.
|
||||||
**/
|
**/
|
||||||
depositPerByte: DepositBalanceOf & AugmentedConst<ApiType>;
|
depositPerByte: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The basic amount of funds that must be reserved for an asset instance.
|
* The basic amount of funds that must be reserved for an asset instance.
|
||||||
**/
|
**/
|
||||||
instanceDeposit: DepositBalanceOf & AugmentedConst<ApiType>;
|
instanceDeposit: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum length of an attribute key.
|
* The maximum length of an attribute key.
|
||||||
**/
|
**/
|
||||||
@@ -829,7 +785,7 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
/**
|
/**
|
||||||
* The basic amount of funds that must be reserved when adding metadata to your asset.
|
* The basic amount of funds that must be reserved when adding metadata to your asset.
|
||||||
**/
|
**/
|
||||||
metadataDepositBase: DepositBalanceOf & AugmentedConst<ApiType>;
|
metadataDepositBase: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The maximum length of data stored on-chain.
|
* The maximum length of data stored on-chain.
|
||||||
**/
|
**/
|
||||||
@@ -843,11 +799,22 @@ declare module '@polkadot/api/types/consts' {
|
|||||||
**/
|
**/
|
||||||
[key: string]: Codec;
|
[key: string]: Codec;
|
||||||
};
|
};
|
||||||
|
utility: {
|
||||||
|
/**
|
||||||
|
* The limit on the number of batched calls.
|
||||||
|
**/
|
||||||
|
batchedCallsLimit: u32 & AugmentedConst<ApiType>;
|
||||||
|
/**
|
||||||
|
* Generic const
|
||||||
|
**/
|
||||||
|
[key: string]: Codec;
|
||||||
|
};
|
||||||
vesting: {
|
vesting: {
|
||||||
|
maxVestingSchedules: u32 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The minimum amount transferred to call `vested_transfer`.
|
* The minimum amount transferred to call `vested_transfer`.
|
||||||
**/
|
**/
|
||||||
minVestedTransfer: BalanceOf & AugmentedConst<ApiType>;
|
minVestedTransfer: u128 & AugmentedConst<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic const
|
* Generic const
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
NoPermission: AugmentedError<ApiType>;
|
NoPermission: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* No provider reference exists to allow a non-zero balance of a non-self-sufficient asset.
|
* No provider reference exists to allow a non-zero balance of a non-self-sufficient
|
||||||
|
* asset.
|
||||||
**/
|
**/
|
||||||
NoProvider: AugmentedError<ApiType>;
|
NoProvider: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -195,9 +196,8 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
contracts: {
|
contracts: {
|
||||||
/**
|
/**
|
||||||
* Performing the requested transfer would have brought the contract below
|
* Performing the requested transfer would have brought the contract below
|
||||||
* the subsistence threshold. No transfer is allowed to do this in order to allow
|
* the subsistence threshold. No transfer is allowed to do this. Use `seal_terminate`
|
||||||
* for a tombstone to be created. Use `seal_terminate` to remove a contract without
|
* to recover a deposit.
|
||||||
* leaving a tombstone behind.
|
|
||||||
**/
|
**/
|
||||||
BelowSubsistenceThreshold: AugmentedError<ApiType>;
|
BelowSubsistenceThreshold: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -209,20 +209,6 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* current schedule.
|
* current schedule.
|
||||||
**/
|
**/
|
||||||
CodeTooLarge: AugmentedError<ApiType>;
|
CodeTooLarge: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* A tombstone exist at the specified address.
|
|
||||||
*
|
|
||||||
* Tombstone cannot be called. Anyone can use `seal_restore_to` in order to revive
|
|
||||||
* the contract, though.
|
|
||||||
**/
|
|
||||||
ContractIsTombstone: AugmentedError<ApiType>;
|
|
||||||
/**
|
|
||||||
* A contract could not be evicted because it has enough balance to pay rent.
|
|
||||||
*
|
|
||||||
* This can be returned from [`Pallet::claim_surcharge`] because the target
|
|
||||||
* contract has enough balance to pay for its rent.
|
|
||||||
**/
|
|
||||||
ContractNotEvictable: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* No contract was found at the specified address.
|
* No contract was found at the specified address.
|
||||||
**/
|
**/
|
||||||
@@ -242,7 +228,7 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
/**
|
/**
|
||||||
* Removal of a contract failed because the deletion queue is full.
|
* Removal of a contract failed because the deletion queue is full.
|
||||||
*
|
*
|
||||||
* This can happen when either calling [`Pallet::claim_surcharge`] or `seal_terminate`.
|
* This can happen when calling `seal_terminate`.
|
||||||
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
|
* The queue is filled by deleting contracts and emptied by a fixed amount each block.
|
||||||
* Trying again during another block is the only way to resolve this issue.
|
* Trying again during another block is the only way to resolve this issue.
|
||||||
**/
|
**/
|
||||||
@@ -259,30 +245,10 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* `seal_call` forwarded this contracts input. It therefore is no longer available.
|
* `seal_call` forwarded this contracts input. It therefore is no longer available.
|
||||||
**/
|
**/
|
||||||
InputForwarded: AugmentedError<ApiType>;
|
InputForwarded: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* An origin TrieId written in the current block.
|
|
||||||
**/
|
|
||||||
InvalidContractOrigin: AugmentedError<ApiType>;
|
|
||||||
/**
|
|
||||||
* Cannot restore to nonexisting or alive contract.
|
|
||||||
**/
|
|
||||||
InvalidDestinationContract: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* A new schedule must have a greater version than the current one.
|
* A new schedule must have a greater version than the current one.
|
||||||
**/
|
**/
|
||||||
InvalidScheduleVersion: AugmentedError<ApiType>;
|
InvalidScheduleVersion: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* Cannot restore from nonexisting or tombstone contract.
|
|
||||||
**/
|
|
||||||
InvalidSourceContract: AugmentedError<ApiType>;
|
|
||||||
/**
|
|
||||||
* An origin must be signed or inherent and auxiliary sender only provided on inherent.
|
|
||||||
**/
|
|
||||||
InvalidSurchargeClaim: AugmentedError<ApiType>;
|
|
||||||
/**
|
|
||||||
* Tombstones don't match.
|
|
||||||
**/
|
|
||||||
InvalidTombstone: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Performing a call was denied because the calling depth reached the limit
|
* Performing a call was denied because the calling depth reached the limit
|
||||||
* of what is specified in the schedule.
|
* of what is specified in the schedule.
|
||||||
@@ -319,15 +285,6 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* A call tried to invoke a contract that is flagged as non-reentrant.
|
* A call tried to invoke a contract that is flagged as non-reentrant.
|
||||||
**/
|
**/
|
||||||
ReentranceDenied: AugmentedError<ApiType>;
|
ReentranceDenied: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The called contract does not have enough balance to pay for its storage.
|
|
||||||
*
|
|
||||||
* The contract ran out of balance and is therefore eligible for eviction into a
|
|
||||||
* tombstone. Anyone can evict the contract by submitting a `claim_surcharge`
|
|
||||||
* extrinsic. Alternatively, a plain balance transfer can be used in order to
|
|
||||||
* increase the contracts funds so that it can be called again.
|
|
||||||
**/
|
|
||||||
RentNotPaid: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* A storage modification exhausted the 32bit type that holds the storage size.
|
* A storage modification exhausted the 32bit type that holds the storage size.
|
||||||
*
|
*
|
||||||
@@ -338,12 +295,12 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
/**
|
/**
|
||||||
* A contract self destructed in its constructor.
|
* A contract self destructed in its constructor.
|
||||||
*
|
*
|
||||||
* This can be triggered by a call to `seal_terminate` or `seal_restore_to`.
|
* This can be triggered by a call to `seal_terminate`.
|
||||||
**/
|
**/
|
||||||
TerminatedInConstructor: AugmentedError<ApiType>;
|
TerminatedInConstructor: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Termination of a contract is not allowed while the contract is already
|
* Termination of a contract is not allowed while the contract is already
|
||||||
* on the call stack. Can be triggered by `seal_terminate` or `seal_restore_to.
|
* on the call stack. Can be triggered by `seal_terminate`.
|
||||||
**/
|
**/
|
||||||
TerminatedWhileReentrant: AugmentedError<ApiType>;
|
TerminatedWhileReentrant: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -424,10 +381,6 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Identity may not veto a proposal twice
|
* Identity may not veto a proposal twice
|
||||||
**/
|
**/
|
||||||
AlreadyVetoed: AugmentedError<ApiType>;
|
AlreadyVetoed: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* Unknown index
|
|
||||||
**/
|
|
||||||
BadIndex: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Preimage already noted
|
* Preimage already noted
|
||||||
**/
|
**/
|
||||||
@@ -452,10 +405,6 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* Invalid hash
|
* Invalid hash
|
||||||
**/
|
**/
|
||||||
InvalidHash: AugmentedError<ApiType>;
|
InvalidHash: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The provided witness data is wrong.
|
|
||||||
**/
|
|
||||||
InvalidWitness: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Maximum number of votes reached.
|
* Maximum number of votes reached.
|
||||||
**/
|
**/
|
||||||
@@ -476,26 +425,14 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
* No external proposal
|
* No external proposal
|
||||||
**/
|
**/
|
||||||
NoProposal: AugmentedError<ApiType>;
|
NoProposal: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* Not delegated
|
|
||||||
**/
|
|
||||||
NotDelegated: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* The account is not currently delegating.
|
* The account is not currently delegating.
|
||||||
**/
|
**/
|
||||||
NotDelegating: AugmentedError<ApiType>;
|
NotDelegating: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The lock on the account to be unlocked has not yet expired.
|
|
||||||
**/
|
|
||||||
NotExpired: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Not imminent
|
* Not imminent
|
||||||
**/
|
**/
|
||||||
NotImminent: AugmentedError<ApiType>;
|
NotImminent: AugmentedError<ApiType>;
|
||||||
/**
|
|
||||||
* The target account does not have a lock.
|
|
||||||
**/
|
|
||||||
NotLocked: AugmentedError<ApiType>;
|
|
||||||
/**
|
/**
|
||||||
* Next external proposal not simple majority
|
* Next external proposal not simple majority
|
||||||
**/
|
**/
|
||||||
@@ -680,8 +617,8 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
AmountTooSmall: AugmentedError<ApiType>;
|
AmountTooSmall: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The queue for the bid's duration is full and the amount bid is too low to get in through
|
* The queue for the bid's duration is full and the amount bid is too low to get in
|
||||||
* replacing an existing bid.
|
* through replacing an existing bid.
|
||||||
**/
|
**/
|
||||||
BidTooLow: AugmentedError<ApiType>;
|
BidTooLow: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -1271,8 +1208,8 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
NoUnlockChunk: AugmentedError<ApiType>;
|
NoUnlockChunk: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* There are too many nominators in the system. Governance needs to adjust the staking settings
|
* There are too many nominators in the system. Governance needs to adjust the staking
|
||||||
* to keep things safe for the runtime.
|
* settings to keep things safe for the runtime.
|
||||||
**/
|
**/
|
||||||
TooManyNominators: AugmentedError<ApiType>;
|
TooManyNominators: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -1280,8 +1217,8 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
TooManyTargets: AugmentedError<ApiType>;
|
TooManyTargets: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* There are too many validators in the system. Governance needs to adjust the staking settings
|
* There are too many validators in the system. Governance needs to adjust the staking
|
||||||
* to keep things safe for the runtime.
|
* settings to keep things safe for the runtime.
|
||||||
**/
|
**/
|
||||||
TooManyValidators: AugmentedError<ApiType>;
|
TooManyValidators: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
@@ -1541,19 +1478,38 @@ declare module '@polkadot/api/types/errors' {
|
|||||||
**/
|
**/
|
||||||
[key: string]: AugmentedError<ApiType>;
|
[key: string]: AugmentedError<ApiType>;
|
||||||
};
|
};
|
||||||
|
utility: {
|
||||||
|
/**
|
||||||
|
* Too many calls batched.
|
||||||
|
**/
|
||||||
|
TooManyCalls: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Generic error
|
||||||
|
**/
|
||||||
|
[key: string]: AugmentedError<ApiType>;
|
||||||
|
};
|
||||||
vesting: {
|
vesting: {
|
||||||
/**
|
/**
|
||||||
* Amount being transferred is too low to create a vesting schedule.
|
* Amount being transferred is too low to create a vesting schedule.
|
||||||
**/
|
**/
|
||||||
AmountLow: AugmentedError<ApiType>;
|
AmountLow: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* An existing vesting schedule already exists for this account that cannot be clobbered.
|
* The account already has `MaxVestingSchedules` count of schedules and thus
|
||||||
|
* cannot add another one. Consider merging existing schedules in order to add another.
|
||||||
**/
|
**/
|
||||||
ExistingVestingSchedule: AugmentedError<ApiType>;
|
AtMaxVestingSchedules: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* Failed to create a new schedule because some parameter was invalid.
|
||||||
|
**/
|
||||||
|
InvalidScheduleParams: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* The account given is not vesting.
|
* The account given is not vesting.
|
||||||
**/
|
**/
|
||||||
NotVesting: AugmentedError<ApiType>;
|
NotVesting: AugmentedError<ApiType>;
|
||||||
|
/**
|
||||||
|
* An index was out of bounds of the vesting schedules.
|
||||||
|
**/
|
||||||
|
ScheduleIndexOutOfBounds: AugmentedError<ApiType>;
|
||||||
/**
|
/**
|
||||||
* Generic error
|
* Generic error
|
||||||
**/
|
**/
|
||||||
|
|||||||
+213
-245
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import '@polkadot/types/augment';
|
||||||
import './consts';
|
import './consts';
|
||||||
import './errors';
|
import './errors';
|
||||||
import './events';
|
import './events';
|
||||||
|
|||||||
+207
-223
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
|
|
||||||
import type { Bytes, HashMap, Json, Metadata, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u32, u64 } from '@polkadot/types';
|
import type { Bytes, HashMap, Json, Metadata, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u32, u64 } from '@polkadot/types';
|
||||||
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
|
|
||||||
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
|
import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
|
||||||
import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
|
import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
|
||||||
import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
|
import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
|
||||||
@@ -21,6 +20,7 @@ import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
|
|||||||
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
|
||||||
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
|
import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
|
||||||
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
|
import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
|
||||||
|
import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
|
||||||
|
|
||||||
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
declare module '@polkadot/rpc-core/types.jsonrpc' {
|
||||||
export interface RpcInterface {
|
export interface RpcInterface {
|
||||||
@@ -113,6 +113,10 @@ declare module '@polkadot/rpc-core/types.jsonrpc' {
|
|||||||
* Returns a child storage entry at a specific block state
|
* Returns a child storage entry at a specific block state
|
||||||
**/
|
**/
|
||||||
getStorage: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<StorageData>>>;
|
getStorage: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<StorageData>>>;
|
||||||
|
/**
|
||||||
|
* Returns child storage entries for multiple keys at a specific block state
|
||||||
|
**/
|
||||||
|
getStorageEntries: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: Hash | string | Uint8Array) => Observable<Vec<Option<StorageData>>>>;
|
||||||
/**
|
/**
|
||||||
* Returns the hash of a child storage entry at a block state
|
* Returns the hash of a child storage entry at a block state
|
||||||
**/
|
**/
|
||||||
|
|||||||
+357
-342
File diff suppressed because it is too large
Load Diff
@@ -7,12 +7,12 @@ import type { Option, Raw, StorageKey, Text, u64 } from '@polkadot/types';
|
|||||||
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
import type { Call, Hash, RuntimeVersion } from '@polkadot/types/interfaces';
|
||||||
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
import type { DecoratedMeta } from '@polkadot/types/metadata/decorate/types';
|
||||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||||
import type { AnyFunction, AnyTuple, CallFunction, Codec, CodecArg as Arg, DefinitionRpc, DefinitionRpcSub, IMethod, InterfaceTypes, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
|
import type { AnyFunction, AnyTuple, CallFunction, Codec, DefinitionRpc, DefinitionRpcSub, DetectCodec, IMethod, IStorageKey, Registry, RegistryTypes } from '@polkadot/types/types';
|
||||||
import type { SubmittableExtrinsic } from '../submittable/types';
|
import type { SubmittableExtrinsic } from '../submittable/types';
|
||||||
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorage, QueryableStorageAt, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
import type { ApiDecoration, ApiInterfaceRx, ApiOptions, ApiTypes, DecoratedErrors, DecoratedEvents, DecoratedRpc, DecoratedRpcSection, DecorateMethod, PaginationOptions, QueryableConsts, QueryableModuleStorage, QueryableModuleStorageAt, QueryableStorage, QueryableStorageAt, QueryableStorageEntry, QueryableStorageEntryAt, QueryableStorageMulti, QueryableStorageMultiArg, SubmittableExtrinsicFunction, SubmittableExtrinsics, SubmittableModuleExtrinsics } from '../types';
|
||||||
import type { VersionedRegistry } from './types';
|
import type { VersionedRegistry } from './types';
|
||||||
|
|
||||||
import { BehaviorSubject, combineLatest, map, of, switchMap, tap, toArray } from 'rxjs';
|
import { BehaviorSubject, combineLatest, from, map, of, switchMap, tap, toArray } from 'rxjs';
|
||||||
|
|
||||||
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
|
import { decorateDerive, ExactDerive } from '@polkadot/api-derive';
|
||||||
import { memo, RpcCore } from '@polkadot/rpc-core';
|
import { memo, RpcCore } from '@polkadot/rpc-core';
|
||||||
@@ -154,6 +154,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
|
this._rx.hasSubscriptions = this._rpcCore.provider.hasSubscriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract at (blockHash: Uint8Array | string): Promise<ApiDecoration<ApiType>>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Return the current used registry
|
* @description Return the current used registry
|
||||||
*/
|
*/
|
||||||
@@ -164,7 +166,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
/**
|
/**
|
||||||
* @description Creates an instance of a type as registered
|
* @description Creates an instance of a type as registered
|
||||||
*/
|
*/
|
||||||
public createType <K extends keyof InterfaceTypes> (type: K, ...params: unknown[]): InterfaceTypes[K] {
|
public createType <T extends Codec = Codec, K extends string = string> (type: K, ...params: unknown[]): DetectCodec<T, K> {
|
||||||
return this.#registry.createType(type, ...params);
|
return this.#registry.createType(type, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +197,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
consts: {},
|
consts: {},
|
||||||
errors: {},
|
errors: {},
|
||||||
events: {},
|
events: {},
|
||||||
|
query: {},
|
||||||
|
rx: {
|
||||||
query: {}
|
query: {}
|
||||||
|
}
|
||||||
} as ApiDecoration<ApiType>;
|
} as ApiDecoration<ApiType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,8 +216,12 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
const storage = blockHash
|
const storage = blockHash
|
||||||
? this._decorateStorageAt(registry.decoratedMeta, this._decorateMethod, blockHash)
|
? this._decorateStorageAt(registry.decoratedMeta, this._decorateMethod, blockHash)
|
||||||
: this._decorateStorage(registry.decoratedMeta, this._decorateMethod);
|
: this._decorateStorage(registry.decoratedMeta, this._decorateMethod);
|
||||||
|
const storageRx = blockHash
|
||||||
|
? this._decorateStorageAt(registry.decoratedMeta, this._rxDecorateMethod, blockHash)
|
||||||
|
: this._decorateStorage(registry.decoratedMeta, this._rxDecorateMethod);
|
||||||
|
|
||||||
augmentObject('query', storage, decoratedApi.query, fromEmpty);
|
augmentObject('query', storage, decoratedApi.query, fromEmpty);
|
||||||
|
augmentObject('query', storageRx, decoratedApi.rx.query, fromEmpty);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
decoratedApi,
|
decoratedApi,
|
||||||
@@ -227,7 +236,10 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
consts: {},
|
consts: {},
|
||||||
errors: {},
|
errors: {},
|
||||||
events: {},
|
events: {},
|
||||||
|
query: {},
|
||||||
|
rx: {
|
||||||
query: {}
|
query: {}
|
||||||
|
}
|
||||||
} as ApiDecoration<ApiType>;
|
} as ApiDecoration<ApiType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +249,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
this._errors = decoratedApi.errors;
|
this._errors = decoratedApi.errors;
|
||||||
this._events = decoratedApi.events;
|
this._events = decoratedApi.events;
|
||||||
this._query = decoratedApi.query;
|
this._query = decoratedApi.query;
|
||||||
|
this._rx.query = decoratedApi.rx.query;
|
||||||
|
|
||||||
if (fromEmpty || !this._extrinsics) {
|
if (fromEmpty || !this._extrinsics) {
|
||||||
this._extrinsics = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
|
this._extrinsics = this._decorateExtrinsics(decoratedMeta, this._decorateMethod);
|
||||||
@@ -246,8 +259,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
augmentObject(null, this._decorateExtrinsics(decoratedMeta, this._rxDecorateMethod), this._rx.tx, false);
|
augmentObject(null, this._decorateExtrinsics(decoratedMeta, this._rxDecorateMethod), this._rx.tx, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rx
|
|
||||||
augmentObject(null, this._decorateStorage(decoratedMeta, this._rxDecorateMethod), this._rx.query, fromEmpty);
|
|
||||||
augmentObject(null, decoratedMeta.consts, this._rx.consts, fromEmpty);
|
augmentObject(null, decoratedMeta.consts, this._rx.consts, fromEmpty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,10 +369,12 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
(this.hasSubscriptions
|
(this.hasSubscriptions
|
||||||
? this._rpcCore.state.subscribeStorage
|
? this._rpcCore.state.subscribeStorage
|
||||||
: this._rpcCore.state.queryStorageAt)(
|
: this._rpcCore.state.queryStorageAt)(
|
||||||
calls.map((arg: QueryableStorageMultiArg<ApiType>) =>
|
calls.map((args: QueryableStorageMultiArg<ApiType>) =>
|
||||||
Array.isArray(arg)
|
Array.isArray(args)
|
||||||
? [arg[0].creator, ...arg.slice(1)]
|
? args[0].creator.meta.type.asMap.hashers.length === 1
|
||||||
: [arg.creator])));
|
? [args[0].creator, args.slice(1)]
|
||||||
|
: [args[0].creator, ...args.slice(1)]
|
||||||
|
: [args.creator])));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _decorateExtrinsics<ApiType extends ApiTypes> ({ tx }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>): SubmittableExtrinsics<ApiType> {
|
protected _decorateExtrinsics<ApiType extends ApiTypes> ({ tx }: DecoratedMeta, decorateMethod: DecorateMethod<ApiType>): SubmittableExtrinsics<ApiType> {
|
||||||
@@ -379,7 +392,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _decorateExtrinsicEntry<ApiType extends ApiTypes> (method: CallFunction, creator: (value: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>): SubmittableExtrinsicFunction<ApiType> {
|
private _decorateExtrinsicEntry<ApiType extends ApiTypes> (method: CallFunction, creator: (value: Call | Uint8Array | string) => SubmittableExtrinsic<ApiType>): SubmittableExtrinsicFunction<ApiType> {
|
||||||
const decorated = (...params: Arg[]): SubmittableExtrinsic<ApiType> =>
|
const decorated = (...params: unknown[]): SubmittableExtrinsic<ApiType> =>
|
||||||
creator(method(...params));
|
creator(method(...params));
|
||||||
|
|
||||||
// pass through the `.is`
|
// pass through the `.is`
|
||||||
@@ -416,7 +429,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
|
|
||||||
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
private _decorateStorageEntry<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): QueryableStorageEntry<ApiType> {
|
||||||
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
// get the storage arguments, with DoubleMap as an array entry, otherwise spread
|
||||||
const getArgs = (args: unknown[]): unknown[] => extractStorageArgs(this.#registry, creator, args);
|
const getArgs = (args: unknown[]) => extractStorageArgs(this.#registry, creator, args);
|
||||||
|
|
||||||
// Disable this where it occurs for each field we are decorating
|
// Disable this where it occurs for each field we are decorating
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||||
@@ -425,48 +438,45 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
|
|
||||||
decorated.creator = creator;
|
decorated.creator = creator;
|
||||||
|
|
||||||
decorated.at = decorateMethod((hash: Hash, ...args: Arg[]): Observable<Codec> =>
|
decorated.at = decorateMethod((hash: Hash, ...args: unknown[]): Observable<Codec> =>
|
||||||
this._rpcCore.state.getStorage(getArgs(args), hash));
|
from(this.at(hash)).pipe(
|
||||||
|
switchMap((api): Observable<Codec> => {
|
||||||
|
assert(api.rx.query[creator.section] && api.rx.query[creator.section][creator.method], () => `query.${creator.section}.${creator.method} is not available in this version of the metadata`);
|
||||||
|
|
||||||
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
|
return api.rx.query[creator.section][creator.method](...args);
|
||||||
|
})
|
||||||
|
));
|
||||||
|
|
||||||
|
decorated.hash = decorateMethod((...args: unknown[]): Observable<Hash> =>
|
||||||
this._rpcCore.state.getStorageHash(getArgs(args)));
|
this._rpcCore.state.getStorageHash(getArgs(args)));
|
||||||
|
|
||||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||||
key.section === creator.section &&
|
key.section === creator.section &&
|
||||||
key.method === creator.method;
|
key.method === creator.method;
|
||||||
|
|
||||||
decorated.key = (...args: Arg[]): string =>
|
decorated.key = (...args: unknown[]): string =>
|
||||||
u8aToHex(compactStripLength(creator(
|
u8aToHex(compactStripLength(creator(...args))[1]);
|
||||||
creator.meta.type.isPlain
|
|
||||||
? undefined
|
|
||||||
: creator.meta.type.isMap
|
|
||||||
? args[0]
|
|
||||||
: creator.meta.type.isDoubleMap
|
|
||||||
? [args[0], args[1]]
|
|
||||||
: args
|
|
||||||
))[1]);
|
|
||||||
|
|
||||||
decorated.keyPrefix = (...keys: Arg[]): string =>
|
decorated.keyPrefix = (...args: unknown[]): string =>
|
||||||
u8aToHex(creator.keyPrefix(...keys));
|
u8aToHex(creator.keyPrefix(...args));
|
||||||
|
|
||||||
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: Arg[]): Observable<[Hash, Codec][]> =>
|
decorated.range = decorateMethod((range: [Hash, Hash?], ...args: unknown[]): Observable<[Hash, Codec][]> =>
|
||||||
this._decorateStorageRange(decorated, args, range));
|
this._decorateStorageRange(decorated, args, range));
|
||||||
|
|
||||||
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
|
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
|
||||||
this._rpcCore.state.getStorageSize(getArgs(args)));
|
this._rpcCore.state.getStorageSize(getArgs(args)));
|
||||||
|
|
||||||
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<u64> =>
|
decorated.sizeAt = decorateMethod((hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<u64> =>
|
||||||
this._rpcCore.state.getStorageSize(getArgs(args), hash));
|
this._rpcCore.state.getStorageSize(getArgs(args), hash));
|
||||||
|
|
||||||
// FIXME NMap support
|
|
||||||
// .keys() & .entries() only available on map types
|
// .keys() & .entries() only available on map types
|
||||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
|
if (creator.iterKey && creator.meta.type.isMap) {
|
||||||
decorated.entries = decorateMethod(
|
decorated.entries = decorateMethod(
|
||||||
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
memo(this.#instanceId, (...args: unknown[]): Observable<[StorageKey, Codec][]> =>
|
||||||
this._retrieveMapEntries(creator, null, args)));
|
this._retrieveMapEntries(creator, null, args)));
|
||||||
|
|
||||||
decorated.entriesAt = decorateMethod(
|
decorated.entriesAt = decorateMethod(
|
||||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<[StorageKey, Codec][]> =>
|
||||||
this._retrieveMapEntries(creator, hash, args)));
|
this._retrieveMapEntries(creator, hash, args)));
|
||||||
|
|
||||||
decorated.entriesPaged = decorateMethod(
|
decorated.entriesPaged = decorateMethod(
|
||||||
@@ -474,11 +484,11 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
this._retrieveMapEntriesPaged(creator, opts)));
|
this._retrieveMapEntriesPaged(creator, opts)));
|
||||||
|
|
||||||
decorated.keys = decorateMethod(
|
decorated.keys = decorateMethod(
|
||||||
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
|
memo(this.#instanceId, (...args: unknown[]): Observable<StorageKey[]> =>
|
||||||
this._retrieveMapKeys(creator, null, args)));
|
this._retrieveMapKeys(creator, null, args)));
|
||||||
|
|
||||||
decorated.keysAt = decorateMethod(
|
decorated.keysAt = decorateMethod(
|
||||||
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: Arg[]): Observable<StorageKey[]> =>
|
memo(this.#instanceId, (hash: Hash | Uint8Array | string, ...args: unknown[]): Observable<StorageKey[]> =>
|
||||||
this._retrieveMapKeys(creator, hash, args)));
|
this._retrieveMapKeys(creator, hash, args)));
|
||||||
|
|
||||||
decorated.keysPaged = decorateMethod(
|
decorated.keysPaged = decorateMethod(
|
||||||
@@ -486,10 +496,13 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
this._retrieveMapKeysPaged(creator, opts)));
|
this._retrieveMapKeysPaged(creator, opts)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.supportMulti) {
|
if (this.supportMulti && creator.meta.type.isMap) {
|
||||||
// When using double map storage function, user need to pass double map key as an array
|
// When using double map storage function, user need to pass double map key as an array
|
||||||
decorated.multi = decorateMethod((args: (Arg | Arg[])[]): Observable<Codec[]> =>
|
decorated.multi = decorateMethod((args: unknown[]): Observable<Codec[]> =>
|
||||||
this._retrieveMulti(args.map((arg) => [creator, arg])));
|
creator.meta.type.asMap.hashers.length === 1
|
||||||
|
? this._retrieveMulti(args.map((a) => [creator, [a]]))
|
||||||
|
: this._retrieveMulti(args.map((a) => [creator, a as unknown[]]))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
/* eslint-enable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||||
@@ -504,44 +517,40 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
// Disable this where it occurs for each field we are decorating
|
// Disable this where it occurs for each field we are decorating
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment */
|
||||||
|
|
||||||
const decorated = decorateMethod((...args: Arg[]): Observable<Codec> =>
|
const decorated = decorateMethod((...args: unknown[]): Observable<Codec> =>
|
||||||
this._rpcCore.state.getStorage(getArgs(args), blockHash));
|
this._rpcCore.state.getStorage(getArgs(args), blockHash));
|
||||||
|
|
||||||
decorated.creator = creator;
|
decorated.creator = creator;
|
||||||
|
|
||||||
decorated.hash = decorateMethod((...args: Arg[]): Observable<Hash> =>
|
decorated.hash = decorateMethod((...args: unknown[]): Observable<Hash> =>
|
||||||
this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
|
this._rpcCore.state.getStorageHash(getArgs(args), blockHash));
|
||||||
|
|
||||||
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
decorated.is = <A extends AnyTuple> (key: IStorageKey<AnyTuple>): key is IStorageKey<A> =>
|
||||||
key.section === creator.section &&
|
key.section === creator.section &&
|
||||||
key.method === creator.method;
|
key.method === creator.method;
|
||||||
|
|
||||||
decorated.key = (...args: Arg[]): string =>
|
decorated.key = (...args: unknown[]): string =>
|
||||||
u8aToHex(compactStripLength(creator(
|
u8aToHex(compactStripLength(creator(
|
||||||
creator.meta.type.isPlain
|
creator.meta.type.isPlain
|
||||||
? undefined
|
? undefined
|
||||||
: creator.meta.type.isMap
|
|
||||||
? args[0]
|
|
||||||
: creator.meta.type.isDoubleMap
|
|
||||||
? [args[0], args[1]]
|
|
||||||
: args
|
: args
|
||||||
))[1]);
|
))[1]);
|
||||||
|
|
||||||
decorated.keyPrefix = (...keys: Arg[]): string =>
|
decorated.keyPrefix = (...keys: unknown[]): string =>
|
||||||
u8aToHex(creator.keyPrefix(...keys));
|
u8aToHex(creator.keyPrefix(...keys));
|
||||||
|
|
||||||
decorated.size = decorateMethod((...args: Arg[]): Observable<u64> =>
|
decorated.size = decorateMethod((...args: unknown[]): Observable<u64> =>
|
||||||
this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
|
this._rpcCore.state.getStorageSize(getArgs(args), blockHash));
|
||||||
|
|
||||||
// FIXME NMap support
|
// FIXME NMap support
|
||||||
// .keys() & .entries() only available on map types
|
// .keys() & .entries() only available on map types
|
||||||
if (creator.iterKey && (creator.meta.type.isMap || creator.meta.type.isDoubleMap)) {
|
if (creator.iterKey && creator.meta.type.isMap) {
|
||||||
decorated.entries = decorateMethod(
|
decorated.entries = decorateMethod(
|
||||||
memo(this.#instanceId, (...args: Arg[]): Observable<[StorageKey, Codec][]> =>
|
memo(this.#instanceId, (...args: unknown[]): Observable<[StorageKey, Codec][]> =>
|
||||||
this._retrieveMapEntries(creator, blockHash, args)));
|
this._retrieveMapEntries(creator, blockHash, args)));
|
||||||
|
|
||||||
decorated.keys = decorateMethod(
|
decorated.keys = decorateMethod(
|
||||||
memo(this.#instanceId, (...args: Arg[]): Observable<StorageKey[]> =>
|
memo(this.#instanceId, (...args: unknown[]): Observable<StorageKey[]> =>
|
||||||
this._retrieveMapKeys(creator, blockHash, args)));
|
this._retrieveMapKeys(creator, blockHash, args)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +562,6 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
// Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
|
// Decorate the base storage call. In the case or rxjs or promise-without-callback (await)
|
||||||
// we make a subscription, alternatively we push this through a single-shot query
|
// we make a subscription, alternatively we push this through a single-shot query
|
||||||
private _decorateStorageCall<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
|
private _decorateStorageCall<ApiType extends ApiTypes> (creator: StorageEntry, decorateMethod: DecorateMethod<ApiType>): ReturnType<DecorateMethod<ApiType>> {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
||||||
return decorateMethod((...args: unknown[]): Observable<Codec> => {
|
return decorateMethod((...args: unknown[]): Observable<Codec> => {
|
||||||
return this.hasSubscriptions
|
return this.hasSubscriptions
|
||||||
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(this.#registry, creator, args)]).pipe(
|
? this._rpcCore.state.subscribeStorage<[Codec]>([extractStorageArgs(this.#registry, creator, args)]).pipe(
|
||||||
@@ -566,7 +574,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: Arg[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
private _decorateStorageRange<ApiType extends ApiTypes> (decorated: QueryableStorageEntry<ApiType>, args: unknown[], range: [Hash, Hash?]): Observable<[Hash, Codec][]> {
|
||||||
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
const outputType = unwrapStorageType(this.#registry, decorated.creator.meta.type, decorated.creator.meta.modifier.isOptional);
|
||||||
|
|
||||||
return this._rpcCore.state
|
return this._rpcCore.state
|
||||||
@@ -580,7 +588,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
// retrieve a set of values for a specific set of keys - here we chunk the keys into PAGE_SIZE sizes
|
||||||
private _retrieveMulti (keys: [StorageEntry, Arg | Arg[]][]): Observable<Codec[]> {
|
private _retrieveMulti (keys: [StorageEntry, unknown[]][]): Observable<Codec[]> {
|
||||||
if (!keys.length) {
|
if (!keys.length) {
|
||||||
return of([]);
|
return of([]);
|
||||||
}
|
}
|
||||||
@@ -596,8 +604,8 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<StorageKey[]> {
|
private _retrieveMapKeys ({ iterKey, meta, method, section }: StorageEntry, at: Hash | Uint8Array | string | null, args: unknown[]): Observable<StorageKey[]> {
|
||||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
assert(iterKey && meta.type.isMap, 'keys can only be retrieved on maps');
|
||||||
|
|
||||||
const headKey = iterKey(...args).toHex();
|
const headKey = iterKey(...args).toHex();
|
||||||
const startSubject = new BehaviorSubject<string>(headKey);
|
const startSubject = new BehaviorSubject<string>(headKey);
|
||||||
@@ -621,7 +629,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _retrieveMapKeysPaged ({ iterKey, meta, method, section }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
|
private _retrieveMapKeysPaged ({ iterKey, meta, method, section }: StorageEntry, opts: PaginationOptions): Observable<StorageKey[]> {
|
||||||
assert(iterKey && (meta.type.isMap || meta.type.isDoubleMap || meta.type.isNMap), 'keys can only be retrieved on maps, linked maps and double maps');
|
assert(iterKey && meta.type.isMap, 'keys can only be retrieved on maps');
|
||||||
|
|
||||||
const headKey = iterKey(...opts.args).toHex();
|
const headKey = iterKey(...opts.args).toHex();
|
||||||
|
|
||||||
@@ -630,7 +638,7 @@ export abstract class Decorate<ApiType extends ApiTypes> extends Events {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: Arg[]): Observable<[StorageKey, Codec][]> {
|
private _retrieveMapEntries (entry: StorageEntry, at: Hash | Uint8Array | string | null, args: unknown[]): Observable<[StorageKey, Codec][]> {
|
||||||
const query = at
|
const query = at
|
||||||
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
|
? (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset, at)
|
||||||
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
|
: (keyset: StorageKey[]) => this._rpcCore.state.queryStorageAt(keyset);
|
||||||
|
|||||||
@@ -182,8 +182,8 @@ export abstract class Getters<ApiType extends ApiTypes> extends Init<ApiType> im
|
|||||||
/**
|
/**
|
||||||
* @description The underlying Rx API interface
|
* @description The underlying Rx API interface
|
||||||
*/
|
*/
|
||||||
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc'> {
|
public get rx (): Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'> {
|
||||||
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc'>);
|
return assertResult(this._rx as Pick<ApiInterfaceRx, 'tx' | 'rpc' | 'query'>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -332,6 +332,15 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _subscribeHealth (): void {
|
||||||
|
// Only enable the health keepalive on WS, not needed on HTTP
|
||||||
|
this.#healthTimer = this.hasSubscriptions
|
||||||
|
? setInterval((): void => {
|
||||||
|
firstValueFrom(this._rpcCore.system.health()).catch(() => undefined);
|
||||||
|
}, KEEPALIVE_INTERVAL)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
private _unsubscribeHealth (): void {
|
private _unsubscribeHealth (): void {
|
||||||
if (this.#healthTimer) {
|
if (this.#healthTimer) {
|
||||||
clearInterval(this.#healthTimer);
|
clearInterval(this.#healthTimer);
|
||||||
@@ -352,8 +361,8 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onProviderConnect = async (): Promise<void> => {
|
#onProviderConnect = async (): Promise<void> => {
|
||||||
this.emit('connected');
|
|
||||||
this._isConnected.next(true);
|
this._isConnected.next(true);
|
||||||
|
this.emit('connected');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [hasMeta, cryptoReady] = await Promise.all([
|
const [hasMeta, cryptoReady] = await Promise.all([
|
||||||
@@ -363,15 +372,13 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
: cryptoWaitReady()
|
: cryptoWaitReady()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
this._subscribeHealth();
|
||||||
|
|
||||||
if (hasMeta && !this._isReady && cryptoReady) {
|
if (hasMeta && !this._isReady && cryptoReady) {
|
||||||
this._isReady = true;
|
this._isReady = true;
|
||||||
|
|
||||||
this.emit('ready', this);
|
this.emit('ready', this);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.#healthTimer = setInterval((): void => {
|
|
||||||
firstValueFrom(this._rpcCore.system.health()).catch(() => undefined);
|
|
||||||
}, KEEPALIVE_INTERVAL);
|
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
|
const error = new Error(`FATAL: Unable to initialize the API: ${(_error as Error).message}`);
|
||||||
|
|
||||||
@@ -382,10 +389,9 @@ export abstract class Init<ApiType extends ApiTypes> extends Decorate<ApiType> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onProviderDisconnect = (): void => {
|
#onProviderDisconnect = (): void => {
|
||||||
this.emit('disconnected');
|
|
||||||
this._isConnected.next(false);
|
this._isConnected.next(false);
|
||||||
|
|
||||||
this._unsubscribeHealth();
|
this._unsubscribeHealth();
|
||||||
|
this.emit('disconnected');
|
||||||
};
|
};
|
||||||
|
|
||||||
#onProviderError = (error: Error): void => {
|
#onProviderError = (error: Error): void => {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ function consts (api: ApiPromise): void {
|
|||||||
console.log(
|
console.log(
|
||||||
api.consts.foo.bar,
|
api.consts.foo.bar,
|
||||||
api.consts.balances.existentialDeposit.toNumber(),
|
api.consts.balances.existentialDeposit.toNumber(),
|
||||||
api.consts.balances.existentialDeposit.meta.docs.map((s): string => s.toString()).join('')
|
api.consts.balances.existentialDeposit.meta.docs.map((s) => s.toString()).join(''),
|
||||||
|
api.consts.system.blockWeights.maxBlock.divn(123).toNumber()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +191,7 @@ function types (api: ApiPromise): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
async function tx (api: ApiPromise, pairs: TestKeyringMap): Promise<void> {
|
||||||
// transfer, also allows for BigInt inputs here
|
// transfer, also allows for bigint inputs here
|
||||||
const transfer = api.tx.balances.transfer(pairs.bob.address, 123456789n);
|
const transfer = api.tx.balances.transfer(pairs.bob.address, 123456789n);
|
||||||
|
|
||||||
console.log('transfer casted', transfer as IMethod<AnyTuple>, transfer as IExtrinsic<AnyTuple>);
|
console.log('transfer casted', transfer as IMethod<AnyTuple>, transfer as IExtrinsic<AnyTuple>);
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Auto-generated by @polkadot/dev, do not edit
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/api', version: '5.3.2' };
|
export const packageInfo = { name: '@polkadot/api', version: '6.1.1' };
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ describe('ApiPromise', (): void => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const signer = new SingleAccountSigner(registry, aliceEd);
|
const signer = new SingleAccountSigner(registry, aliceEd);
|
||||||
const api = await ApiPromise.create({ provider, registry, signer });
|
const api = await ApiPromise.create({ provider, registry, signer, throwOnConnect: true });
|
||||||
const transfer = api.tx.balances.transfer(keyring.getPair('0xe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e').address, 321564789876512345n);
|
const transfer = api.tx.balances.transfer(keyring.getPair('0xe659a7a1628cdd93febc04a4e0646ea20e9f5f0ce097d9a05290d4a9e054df4e').address, 321564789876512345n);
|
||||||
|
|
||||||
return { api, transfer: await transfer.signAsync(aliceEd.address, {}) };
|
return { api, transfer: await transfer.signAsync(aliceEd.address, {}) };
|
||||||
@@ -59,7 +59,7 @@ describe('ApiPromise', (): void => {
|
|||||||
const rpcData = await provider.send<string>('state_getMetadata', []);
|
const rpcData = await provider.send<string>('state_getMetadata', []);
|
||||||
const genesisHash = registry.createType('Hash', await provider.send('chain_getBlockHash', [])).toHex();
|
const genesisHash = registry.createType('Hash', await provider.send('chain_getBlockHash', [])).toHex();
|
||||||
const specVersion = 0;
|
const specVersion = 0;
|
||||||
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry });
|
const api = await ApiPromise.create({ metadata: { [`${genesisHash}-${specVersion}`]: rpcData }, provider, registry, throwOnConnect: true });
|
||||||
|
|
||||||
expect(api.genesisHash).toBeDefined();
|
expect(api.genesisHash).toBeDefined();
|
||||||
expect(api.runtimeMetadata).toBeDefined();
|
expect(api.runtimeMetadata).toBeDefined();
|
||||||
@@ -74,7 +74,7 @@ describe('ApiPromise', (): void => {
|
|||||||
|
|
||||||
it('Create API instance without metadata and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
|
it('Create API instance without metadata and makes the runtime, rpc, state & extrinsics available', async (): Promise<void> => {
|
||||||
const metadata = {};
|
const metadata = {};
|
||||||
const api = await ApiPromise.create({ metadata, provider, registry });
|
const api = await ApiPromise.create({ metadata, provider, registry, throwOnConnect: true });
|
||||||
|
|
||||||
expect(api.genesisHash).toBeDefined();
|
expect(api.genesisHash).toBeDefined();
|
||||||
expect(api.runtimeMetadata).toBeDefined();
|
expect(api.runtimeMetadata).toBeDefined();
|
||||||
@@ -98,17 +98,15 @@ describe('ApiPromise', (): void => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const api = new ErrorApiPromise();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await api.isReadyOrError;
|
const api = await ErrorApiPromise.create({ provider, throwOnConnect: true });
|
||||||
|
|
||||||
|
await api.disconnect();
|
||||||
|
|
||||||
fail('Expected an error but none occurred.');
|
fail('Expected an error but none occurred.');
|
||||||
} catch {
|
} catch {
|
||||||
// Pass
|
// Pass
|
||||||
}
|
}
|
||||||
|
|
||||||
await api.disconnect();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -118,7 +116,7 @@ describe('ApiPromise', (): void => {
|
|||||||
const SIG = '0x659effefbbe5ab4d7136ebb5084b959eb424e32b862307371be4721ac2c46334245af4f1476c36c5e5aff04396c2fdd2ce561ec90382821d4aa071b559b1db0f';
|
const SIG = '0x659effefbbe5ab4d7136ebb5084b959eb424e32b862307371be4721ac2c46334245af4f1476c36c5e5aff04396c2fdd2ce561ec90382821d4aa071b559b1db0f';
|
||||||
|
|
||||||
it('signs data using a specified keyring', async (): Promise<void> => {
|
it('signs data using a specified keyring', async (): Promise<void> => {
|
||||||
const api = await ApiPromise.create({ provider, registry });
|
const api = await ApiPromise.create({ provider, registry, throwOnConnect: true });
|
||||||
const sig = await api.sign(aliceEd, TEST);
|
const sig = await api.sign(aliceEd, TEST);
|
||||||
|
|
||||||
expect(sig).toEqual(SIG);
|
expect(sig).toEqual(SIG);
|
||||||
@@ -127,11 +125,7 @@ describe('ApiPromise', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('signs data using an external signer', async (): Promise<void> => {
|
it('signs data using an external signer', async (): Promise<void> => {
|
||||||
const api = await ApiPromise.create({
|
const api = await ApiPromise.create({ provider, registry, signer: new SingleAccountSigner(registry, aliceEd), throwOnConnect: true });
|
||||||
provider,
|
|
||||||
registry,
|
|
||||||
signer: new SingleAccountSigner(registry, aliceEd)
|
|
||||||
});
|
|
||||||
const sig = await api.sign(ADDR, TEST);
|
const sig = await api.sign(ADDR, TEST);
|
||||||
|
|
||||||
expect(sig).toEqual(SIG);
|
expect(sig).toEqual(SIG);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Observable } from 'rxjs';
|
import type { Observable } from 'rxjs';
|
||||||
import type { AnyFunction, Callback, Codec, CodecArg } from '@polkadot/types/types';
|
import type { AnyFunction, Callback, Codec } from '@polkadot/types/types';
|
||||||
|
|
||||||
export type Push<T extends readonly unknown[], V> = [...T, V]
|
export type Push<T extends readonly unknown[], V> = [...T, V]
|
||||||
|
|
||||||
@@ -57,9 +57,8 @@ export interface DecorateMethodOptions {
|
|||||||
|
|
||||||
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
|
export type DecorateFn <T extends Codec> = (...args: any[]) => Observable<T>;
|
||||||
|
|
||||||
// FIXME We need a solution for NMap
|
export interface PaginationOptions<A = unknown> {
|
||||||
export interface PaginationOptions<ArgType = CodecArg> {
|
args: A[];
|
||||||
args: ArgType[];
|
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
startKey?: string;
|
startKey?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// Copyright 2017-2021 @polkadot/api authors & contributors
|
// Copyright 2017-2021 @polkadot/api authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { ModuleConstantMetadataLatest } from '@polkadot/types/interfaces';
|
import type { PalletConstantMetadataLatest } from '@polkadot/types/interfaces';
|
||||||
import type { Codec } from '@polkadot/types/types';
|
import type { Codec } from '@polkadot/types/types';
|
||||||
import type { ApiTypes } from './base';
|
import type { ApiTypes } from './base';
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ export interface AugmentedConsts<ApiType extends ApiTypes> { }
|
|||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export interface AugmentedConst<ApiType extends ApiTypes> {
|
export interface AugmentedConst<ApiType extends ApiTypes> {
|
||||||
meta: ModuleConstantMetadataLatest;
|
meta: PalletConstantMetadataLatest;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryableModuleConsts {
|
export interface QueryableModuleConsts {
|
||||||
|
|||||||
@@ -112,4 +112,7 @@ export interface ApiDecoration<ApiType extends ApiTypes> {
|
|||||||
errors: DecoratedErrors<ApiType>;
|
errors: DecoratedErrors<ApiType>;
|
||||||
events: DecoratedEvents<ApiType>;
|
events: DecoratedEvents<ApiType>;
|
||||||
query: QueryableStorage<ApiType>;
|
query: QueryableStorage<ApiType>;
|
||||||
|
rx: {
|
||||||
|
query: QueryableStorage<'rxjs'>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,34 +5,34 @@ import type { Observable } from 'rxjs';
|
|||||||
import type { StorageKey, u64 } from '@polkadot/types';
|
import type { StorageKey, u64 } from '@polkadot/types';
|
||||||
import type { Hash } from '@polkadot/types/interfaces';
|
import type { Hash } from '@polkadot/types/interfaces';
|
||||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||||
import type { AnyFunction, AnyTuple, Callback, Codec, CodecArg, IStorageKey } from '@polkadot/types/types';
|
import type { AnyFunction, AnyTuple, Callback, Codec, IStorageKey } from '@polkadot/types/types';
|
||||||
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
|
import type { ApiTypes, DropLast, MethodResult, ObsInnerType, PaginationOptions, PromiseOrObs, UnsubscribePromise } from './base';
|
||||||
|
|
||||||
interface StorageEntryObservableMulti {
|
interface StorageEntryObservableMulti {
|
||||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Observable<T[]>;
|
<T extends Codec>(args: (unknown[] | unknown)[]): Observable<T[]>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface StorageEntryPromiseMulti {
|
interface StorageEntryPromiseMulti {
|
||||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[]): Promise<T[]>;
|
<T extends Codec>(args: (unknown[] | unknown)[]): Promise<T[]>;
|
||||||
<T extends Codec>(args: (CodecArg[] | CodecArg)[], callback: Callback<T[]>): UnsubscribePromise;
|
<T extends Codec>(args: (unknown[] | unknown)[], callback: Callback<T[]>): UnsubscribePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageEntryPromiseOverloads {
|
export interface StorageEntryPromiseOverloads {
|
||||||
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
|
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
|
||||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
|
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
|
||||||
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
|
<T extends Codec>(callback: Callback<T>): UnsubscribePromise;
|
||||||
<T extends Codec>(arg: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
<T extends Codec>(arg: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
<T extends Codec>(arg1: unknown, arg2: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||||
<T extends Codec>(arg1: CodecArg, arg2: CodecArg, arg3: CodecArg, callback: Callback<T>): UnsubscribePromise;
|
<T extends Codec>(arg1: unknown, arg2: unknown, arg3: unknown, callback: Callback<T>): UnsubscribePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface StorageEntryPromiseOverloadsAt {
|
export interface StorageEntryPromiseOverloadsAt {
|
||||||
(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<Codec>;
|
(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<Codec>;
|
||||||
<T extends Codec>(arg1?: CodecArg, arg2?: CodecArg, arg3?: CodecArg): Promise<T>;
|
<T extends Codec>(arg1?: unknown, arg2?: unknown, arg3?: unknown): Promise<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the most generic typings we can have for a storage entry function
|
// This is the most generic typings we can have for a storage entry function
|
||||||
type GenericStorageEntryFunction = (...args: CodecArg[]) => Observable<Codec>
|
type GenericStorageEntryFunction = (...args: unknown[]) => Observable<Codec>
|
||||||
|
|
||||||
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
export type QueryableStorageEntry<ApiType extends ApiTypes, A extends AnyTuple = AnyTuple> =
|
||||||
ApiType extends 'rxjs'
|
ApiType extends 'rxjs'
|
||||||
@@ -92,7 +92,7 @@ export interface QueryableModuleStorageAt<ApiType extends ApiTypes> {
|
|||||||
|
|
||||||
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
export type QueryableStorageMultiArg<ApiType extends ApiTypes> =
|
||||||
QueryableStorageEntry<ApiType> |
|
QueryableStorageEntry<ApiType> |
|
||||||
[QueryableStorageEntry<ApiType>, ...CodecArg[]];
|
[QueryableStorageEntry<ApiType>, ...unknown[]];
|
||||||
|
|
||||||
export interface QueryableStorageMultiBase<ApiType extends ApiTypes> {
|
export interface QueryableStorageMultiBase<ApiType extends ApiTypes> {
|
||||||
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
|
<T extends Codec[]>(calls: QueryableStorageMultiArg<ApiType>[]): Observable<T>;
|
||||||
|
|||||||
@@ -1,59 +1,53 @@
|
|||||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Storage } from '@polkadot/types/metadata/decorate/types';
|
|
||||||
|
|
||||||
import { decorateStorage, Metadata, TypeRegistry } from '@polkadot/types';
|
import { decorateStorage, Metadata, TypeRegistry } from '@polkadot/types';
|
||||||
import metaStatic from '@polkadot/types/metadata/static-substrate';
|
import metaStatic from '@polkadot/types-support/metadata/static-substrate';
|
||||||
|
|
||||||
import { extractStorageArgs } from './validate';
|
import { extractStorageArgs } from './validate';
|
||||||
|
|
||||||
describe('extractStorageArgs', (): void => {
|
describe('extractStorageArgs', (): void => {
|
||||||
const registry = new TypeRegistry();
|
const registry = new TypeRegistry();
|
||||||
let storage: Storage;
|
|
||||||
|
|
||||||
beforeEach((): void => {
|
|
||||||
const metadata = new Metadata(registry, metaStatic);
|
const metadata = new Metadata(registry, metaStatic);
|
||||||
|
|
||||||
storage = decorateStorage(registry, metadata.asLatest, metadata.version);
|
registry.setMetadata(metadata);
|
||||||
});
|
|
||||||
|
const storage = decorateStorage(registry, metadata.asLatest, metadata.version);
|
||||||
|
|
||||||
it('validates no-arg plain', (): void => {
|
it('validates no-arg plain', (): void => {
|
||||||
expect(
|
expect(
|
||||||
extractStorageArgs(registry, storage.timestamp.now, [])
|
extractStorageArgs(registry, storage.timestamp.now, [])
|
||||||
).toEqual([storage.timestamp.now]);
|
).toEqual([storage.timestamp.now, []]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates no-arg plain (with undefined, undefined)', (): void => {
|
it('validates no-arg plain (with undefined, undefined)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
extractStorageArgs(registry, storage.timestamp.now, [undefined, undefined])
|
extractStorageArgs(registry, storage.timestamp.now, [undefined, undefined])
|
||||||
).toEqual([storage.timestamp.now]);
|
).toEqual([storage.timestamp.now, []]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates no-arg plain (failing when there are args)', (): void => {
|
it('validates no-arg plain (failing when there are args)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): unknown => extractStorageArgs(registry, storage.timestamp.now, [123, 456])
|
() => extractStorageArgs(registry, storage.timestamp.now, [123, 456])
|
||||||
).toThrow('timestamp.now() does not take any arguments, 2 found');
|
).toThrow('timestamp.now() does not take any arguments, 2 found');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates map, 1 arg', (): void => {
|
it('validates map, 1 arg', (): void => {
|
||||||
expect(
|
expect(
|
||||||
extractStorageArgs(registry, storage.staking.payee, ['abc'])
|
extractStorageArgs(registry, storage.staking.payee, ['abc'])
|
||||||
).toEqual([storage.staking.payee, 'abc']);
|
).toEqual([storage.staking.payee, ['abc']]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates map, 1 arg (failing with no args)', (): void => {
|
it('validates map, 1 arg (failing with no args)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any =>
|
() => extractStorageArgs(registry, storage.staking.payee, [])
|
||||||
extractStorageArgs(registry, storage.staking.payee, [])
|
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 0 found');
|
||||||
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 0 found');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates map, 1 arg (failing with no args)', (): void => {
|
it('validates map, 1 arg (failing with no args)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any =>
|
() => extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
|
||||||
extractStorageArgs(registry, storage.staking.payee, ['abc', 'def'])
|
).toThrow('staking.payee(AccountId32) is a map, requiring 1 arguments, 2 found');
|
||||||
).toThrow('staking.payee(AccountId) is a map, requiring 1 argument, 2 found');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates doublemap, 2 args', (): void => {
|
it('validates doublemap, 2 args', (): void => {
|
||||||
@@ -64,35 +58,13 @@ describe('extractStorageArgs', (): void => {
|
|||||||
|
|
||||||
it('validates doublemap, 2 args (failing with no args)', (): void => {
|
it('validates doublemap, 2 args (failing with no args)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any =>
|
() => extractStorageArgs(registry, storage.staking.erasStakers, [])
|
||||||
extractStorageArgs(registry, storage.staking.erasStakers, [])
|
).toThrow('staking.erasStakers(u32, AccountId32) is a map, requiring 2 arguments, 0 found');
|
||||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 0 found');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
|
it('validates doublemap, 2 args (failing with 1 arg)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
(): any =>
|
() => extractStorageArgs(registry, storage.staking.erasStakers, [123])
|
||||||
extractStorageArgs(registry, storage.staking.erasStakers, [123])
|
).toThrow('staking.erasStakers(u32, AccountId32) is a map, requiring 2 arguments, 1 found');
|
||||||
).toThrow('staking.erasStakers(EraIndex, AccountId) is a double map, requiring 2 arguments, 1 found');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Linked maps have been removed
|
|
||||||
it.skip('validates linked map, no args', (): void => {
|
|
||||||
expect(
|
|
||||||
extractStorageArgs(registry, storage.staking.validators, [])
|
|
||||||
).toEqual([storage.staking.validators]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it.skip('validates linked map, single arg', (): void => {
|
|
||||||
expect(
|
|
||||||
extractStorageArgs(registry, storage.staking.validators, [123])
|
|
||||||
).toEqual([storage.staking.validators, 123]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it.skip('validates linked map (failing with extra args)', (): void => {
|
|
||||||
expect(
|
|
||||||
(): any[] =>
|
|
||||||
extractStorageArgs(registry, storage.staking.validators, [123, 456])
|
|
||||||
).toThrow('staking.validators(AccountId) is a linked map, requiring either 0 arguments (retrieving all) or 1 argument, 2 found');
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,60 +1,32 @@
|
|||||||
// Copyright 2017-2019 @polkadot/api authors & contributors
|
// Copyright 2017-2019 @polkadot/api authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { Type } from '@polkadot/types';
|
import type { SiLookupTypeId } from '@polkadot/types/interfaces';
|
||||||
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
import type { StorageEntry } from '@polkadot/types/primitive/types';
|
||||||
import type { Registry } from '@polkadot/types/types';
|
import type { Registry } from '@polkadot/types/types';
|
||||||
|
|
||||||
import { assert, isUndefined } from '@polkadot/util';
|
import { assert, isUndefined } from '@polkadot/util';
|
||||||
|
|
||||||
function sig (_: Registry, { method, section }: StorageEntry, args: Type[]): string {
|
function sig ({ lookup }: Registry, { method, section }: StorageEntry, args: SiLookupTypeId[]): string {
|
||||||
return `${section}.${method}(${args.join(', ')})`;
|
return `${section}.${method}(${args.map((a) => lookup.getTypeDef(a).type).join(', ')})`;
|
||||||
}
|
|
||||||
|
|
||||||
function doDoubleMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, [any, any]] {
|
|
||||||
const { key1, key2 } = creator.meta.type.asDoubleMap;
|
|
||||||
|
|
||||||
assert(args.length === 2, () => `${sig(registry, creator, [key1, key2])} is a double map, requiring 2 arguments, ${args.length} found`);
|
|
||||||
|
|
||||||
// pass as tuple
|
|
||||||
return [creator, args as [any, any]];
|
|
||||||
}
|
|
||||||
|
|
||||||
function doMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry] | [StorageEntry, any] {
|
|
||||||
const { key } = creator.meta.type.asMap;
|
|
||||||
|
|
||||||
assert(args.length === 1, () => `${sig(registry, creator, [key])} is a map, requiring 1 argument, ${args.length} found`);
|
|
||||||
|
|
||||||
// expand
|
|
||||||
return args.length
|
|
||||||
? [creator, args[0]]
|
|
||||||
: [creator];
|
|
||||||
}
|
|
||||||
|
|
||||||
function doNMap (registry: Registry, creator: StorageEntry, args: unknown[]): [StorageEntry, any[]] {
|
|
||||||
const { keyVec } = creator.meta.type.asNMap;
|
|
||||||
|
|
||||||
assert(args.length === keyVec.length, () => `${sig(registry, creator, keyVec)} is a multi map, requiring ${keyVec.length} arguments, ${args.length} found`);
|
|
||||||
|
|
||||||
// pass as tuple
|
|
||||||
return [creator, args];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// sets up the arguments in the form of [creator, args] ready to be used in a storage
|
// sets up the arguments in the form of [creator, args] ready to be used in a storage
|
||||||
// call. Additionally, it verifies that the correct number of arguments have been passed
|
// call. Additionally, it verifies that the correct number of arguments have been passed
|
||||||
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, any[]] | [StorageEntry] | [StorageEntry, any] {
|
export function extractStorageArgs (registry: Registry, creator: StorageEntry, _args: unknown[]): [StorageEntry, unknown[]] {
|
||||||
const args = _args.filter((arg) => !isUndefined(arg));
|
const args = _args.filter((arg) => !isUndefined(arg));
|
||||||
|
|
||||||
if (creator.meta.type.isDoubleMap) {
|
if (creator.meta.type.isPlain) {
|
||||||
return doDoubleMap(registry, creator, args);
|
|
||||||
} else if (creator.meta.type.isMap) {
|
|
||||||
return doMap(registry, creator, args);
|
|
||||||
} else if (creator.meta.type.isNMap) {
|
|
||||||
return doNMap(registry, creator, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(args.length === 0, () => `${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
|
assert(args.length === 0, () => `${sig(registry, creator, [])} does not take any arguments, ${args.length} found`);
|
||||||
|
} else {
|
||||||
|
const { hashers, key } = creator.meta.type.asMap;
|
||||||
|
const keys = hashers.length === 1
|
||||||
|
? [key]
|
||||||
|
: registry.lookup.getSiType(key).def.asTuple.map((t) => t);
|
||||||
|
|
||||||
// no args
|
assert(args.length === keys.length, () => `${sig(registry, creator, keys)} is a map, requiring ${keys.length} arguments, ${args.length} found`);
|
||||||
return [creator];
|
}
|
||||||
|
|
||||||
|
// pass as tuple
|
||||||
|
return [creator, args];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ describe('misc online tests', (): void => {
|
|||||||
await api.disconnect();
|
await api.disconnect();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('expose rpc and rx definition', (): void => {
|
||||||
|
console.error(api.rpc.payment.queryFeeDetails.meta);
|
||||||
|
console.error(api.rx.rpc.chain.getBlock.meta);
|
||||||
|
});
|
||||||
|
|
||||||
it.skip('retrieves balances correctly', async (): Promise<void> => {
|
it.skip('retrieves balances correctly', async (): Promise<void> => {
|
||||||
console.error(JSON.stringify(
|
console.error(JSON.stringify(
|
||||||
await api.query.system.account('FPzukZw2mphWsXDqdkNzLaxnanjZEWH9i2vqwobTdtde5me')
|
await api.query.system.account('FPzukZw2mphWsXDqdkNzLaxnanjZEWH9i2vqwobTdtde5me')
|
||||||
@@ -64,10 +69,4 @@ describe('misc online tests', (): void => {
|
|||||||
await api.query.society.defenderVotes('Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9')
|
await api.query.society.defenderVotes('Dab4bfYTZRUDMWjYAUQuFbDreQ9mt7nULWu3Dw7jodbzVe9')
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('expose rpc and rx definition', (): void => {
|
|
||||||
console.error(api.rpc.payment.queryFeeDetails.meta);
|
|
||||||
|
|
||||||
console.error(api.rx.rpc.chain.getBlock.meta);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ const typesBundle = {
|
|||||||
|
|
||||||
types: [
|
types: [
|
||||||
{
|
{
|
||||||
minmax: [0, undefined] as [number?, number?],
|
minmax: [0, undefined],
|
||||||
types: {
|
types: {
|
||||||
Balance: 'u64',
|
Balance: 'u64',
|
||||||
BalanceOf: 'Balance',
|
BalanceOf: 'Balance',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/rpc-core",
|
"name": "@polkadot/rpc-core",
|
||||||
"version": "5.3.2",
|
"version": "6.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
"description": "A JavaScript wrapper for the Polkadot JsonRPC interface",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -19,13 +19,13 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/rpc-provider": "5.3.2",
|
"@polkadot/rpc-provider": "6.1.1",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"@polkadot/util": "^7.1.1",
|
"@polkadot/util": "^7.4.1",
|
||||||
"rxjs": "^7.2.0"
|
"rxjs": "^7.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^7.1.1"
|
"@polkadot/keyring": "^7.4.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ export class RpcCore {
|
|||||||
|
|
||||||
subscriptionPromise = this._createSubscriber({ paramsJson, subName, subType, update }, errorHandler);
|
subscriptionPromise = this._createSubscriber({ paramsJson, subName, subType, update }, errorHandler);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errorHandler(error);
|
errorHandler(error as Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Teardown logic
|
// Teardown logic
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Auto-generated by @polkadot/dev, do not edit
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/rpc-core', version: '5.3.2' };
|
export const packageInfo = { name: '@polkadot/rpc-core', version: '6.1.1' };
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/rpc-provider",
|
"name": "@polkadot/rpc-provider",
|
||||||
"version": "5.3.2",
|
"version": "6.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Transport providers for the API",
|
"description": "Transport providers for the API",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -19,19 +19,19 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"@polkadot/util": "^7.1.1",
|
"@polkadot/util": "^7.4.1",
|
||||||
"@polkadot/util-crypto": "^7.1.1",
|
"@polkadot/util-crypto": "^7.4.1",
|
||||||
"@polkadot/x-fetch": "^7.1.1",
|
"@polkadot/x-fetch": "^7.4.1",
|
||||||
"@polkadot/x-global": "^7.1.1",
|
"@polkadot/x-global": "^7.4.1",
|
||||||
"@polkadot/x-ws": "^7.1.1",
|
"@polkadot/x-ws": "^7.4.1",
|
||||||
"eventemitter3": "^4.0.7"
|
"eventemitter3": "^4.0.7"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@polkadot/keyring": "^7.1.1",
|
"@polkadot/keyring": "^7.4.1",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"mock-socket": "^9.0.3",
|
"mock-socket": "^9.0.3",
|
||||||
"nock": "^13.1.1"
|
"nock": "^13.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ describe('Http', (): void => {
|
|||||||
).not.toThrow();
|
).not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('allow clone', (): void => {
|
||||||
|
const clone = http.clone();
|
||||||
|
/* eslint-disable */
|
||||||
|
expect((clone as any)['#endpoint']).toEqual((http as any)['#endpoint']);
|
||||||
|
expect((clone as any)['#headers']).toEqual((http as any)['#headers']);
|
||||||
|
/* eslint-enable */
|
||||||
|
});
|
||||||
|
|
||||||
it('always returns isConnected true', (): void => {
|
it('always returns isConnected true', (): void => {
|
||||||
expect(http.isConnected).toEqual(true);
|
expect(http.isConnected).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export class HttpProvider implements ProviderInterface {
|
|||||||
* @description Returns a clone of the object
|
* @description Returns a clone of the object
|
||||||
*/
|
*/
|
||||||
public clone (): HttpProvider {
|
public clone (): HttpProvider {
|
||||||
throw new Error('Unimplemented');
|
return new HttpProvider(this.#endpoint, this.#headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import EventEmitter from 'eventemitter3';
|
|||||||
import { createTestKeyring } from '@polkadot/keyring/testing';
|
import { createTestKeyring } from '@polkadot/keyring/testing';
|
||||||
import { decorateStorage, Metadata } from '@polkadot/types';
|
import { decorateStorage, Metadata } from '@polkadot/types';
|
||||||
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
import jsonrpc from '@polkadot/types/interfaces/jsonrpc';
|
||||||
import rpcHeader from '@polkadot/types/json/Header.004.json';
|
import rpcHeader from '@polkadot/types-support/json/Header.004.json';
|
||||||
import rpcSignedBlock from '@polkadot/types/json/SignedBlock.004.immortal.json';
|
import rpcSignedBlock from '@polkadot/types-support/json/SignedBlock.004.immortal.json';
|
||||||
import rpcMetadata from '@polkadot/types/metadata/static-substrate';
|
import rpcMetadata from '@polkadot/types-support/metadata/static-substrate';
|
||||||
import { assert, BN, bnToU8a, logger, u8aToHex } from '@polkadot/util';
|
import { assert, BN, bnToU8a, logger, u8aToHex } from '@polkadot/util';
|
||||||
import { randomAsU8a } from '@polkadot/util-crypto';
|
import { randomAsU8a } from '@polkadot/util-crypto';
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Auto-generated by @polkadot/dev, do not edit
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/rpc-provider', version: '5.3.2' };
|
export const packageInfo = { name: '@polkadot/rpc-provider', version: '6.1.1' };
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ export class WsProvider implements ProviderInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handler.callback(error, undefined);
|
handler.callback(error as Error, undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete this.#handlers[response.id];
|
delete this.#handlers[response.id];
|
||||||
@@ -446,7 +446,7 @@ export class WsProvider implements ProviderInterface {
|
|||||||
|
|
||||||
handler.callback(null, result);
|
handler.callback(null, result);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handler.callback(error, undefined);
|
handler.callback(error as Error, undefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ interface ReplyDef {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
global.WebSocket = WebSocket;
|
global.WebSocket = WebSocket as typeof global.WebSocket;
|
||||||
|
|
||||||
export const TEST_WS_URL = 'ws://localhost:9955';
|
export const TEST_WS_URL = 'ws://localhost:9955';
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/typegen",
|
"name": "@polkadot/typegen",
|
||||||
"version": "5.3.2",
|
"version": "6.1.1",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "Type generation scripts",
|
"description": "Type generation scripts",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@@ -26,19 +26,20 @@
|
|||||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.14.8",
|
"@babel/core": "^7.15.5",
|
||||||
"@babel/register": "^7.14.5",
|
"@babel/register": "^7.15.3",
|
||||||
"@babel/runtime": "^7.14.8",
|
"@babel/runtime": "^7.15.4",
|
||||||
"@polkadot/api": "5.3.2",
|
"@polkadot/api": "6.1.1",
|
||||||
"@polkadot/rpc-provider": "5.3.2",
|
"@polkadot/rpc-provider": "6.1.1",
|
||||||
"@polkadot/types": "5.3.2",
|
"@polkadot/types": "6.1.1",
|
||||||
"@polkadot/util": "^7.1.1",
|
"@polkadot/types-support": "6.1.1",
|
||||||
|
"@polkadot/util": "^7.4.1",
|
||||||
"handlebars": "^4.7.7",
|
"handlebars": "^4.7.7",
|
||||||
"websocket": "^1.0.34",
|
"websocket": "^1.0.34",
|
||||||
"yargs": "^17.0.1"
|
"yargs": "^17.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/websocket": "^1.0.4",
|
"@types/websocket": "^1.0.4",
|
||||||
"@types/yargs": "^17.0.2"
|
"@types/yargs": "^17.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ try {
|
|||||||
'^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1',
|
'^@polkadot/rpc-core(.*)': './packages/rpc-core/src\\1',
|
||||||
'^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1',
|
'^@polkadot/rpc-provider(.*)': './packages/rpc-provider/src\\1',
|
||||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||||
|
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ try {
|
|||||||
['module-resolver', {
|
['module-resolver', {
|
||||||
alias: {
|
alias: {
|
||||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||||
|
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ try {
|
|||||||
alias: {
|
alias: {
|
||||||
'^@polkadot/typegen(.*)': './packages/typegen/src\\1',
|
'^@polkadot/typegen(.*)': './packages/typegen/src\\1',
|
||||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||||
|
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ try {
|
|||||||
['module-resolver', {
|
['module-resolver', {
|
||||||
alias: {
|
alias: {
|
||||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||||
|
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ try {
|
|||||||
['module-resolver', {
|
['module-resolver', {
|
||||||
alias: {
|
alias: {
|
||||||
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
'^@polkadot/types-known(.*)': './packages/types-known/src\\1',
|
||||||
|
'^@polkadot/types-support(.*)': './packages/types-support/src\\1',
|
||||||
'^@polkadot/types(.*)': './packages/types/src\\1'
|
'^@polkadot/types(.*)': './packages/types/src\\1'
|
||||||
}
|
}
|
||||||
}]
|
}]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { ApiPromise, WsProvider } from '@polkadot/api';
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
async function run (ws: string): Promise<void> {
|
async function run (ws: string): Promise<void> {
|
||||||
const provider = new WsProvider(ws);
|
const provider = new WsProvider(ws);
|
||||||
const api = await ApiPromise.create({ provider });
|
const api = await ApiPromise.create({ provider, throwOnConnect: true });
|
||||||
const [chain, props] = await Promise.all([
|
const [chain, props] = await Promise.all([
|
||||||
api.rpc.system.chain(),
|
api.rpc.system.chain(),
|
||||||
api.rpc.system.properties()
|
api.rpc.system.properties()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type { ExtraTypes } from './types';
|
|||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
|
import lookupDefinitions from '@polkadot/types/augment/lookup/definitions';
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
@@ -17,14 +18,19 @@ const generateForMetaTemplate = Handlebars.compile(template);
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes = {
|
||||||
|
'@polkadot/types/augment': { lookup: lookupDefinitions },
|
||||||
|
'@polkadot/types/interfaces': defaultDefs,
|
||||||
|
...extraTypes
|
||||||
|
};
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
}, {});
|
}, {});
|
||||||
|
const { lookup, pallets, registry } = meta.asLatest;
|
||||||
|
|
||||||
const modules = meta.asLatest.modules
|
const modules = pallets
|
||||||
.filter((mod) => mod.constants.length > 0)
|
.filter(({ constants }) => constants.length > 0)
|
||||||
.map(({ constants, name }) => {
|
.map(({ constants, name }) => {
|
||||||
if (!isStrict) {
|
if (!isStrict) {
|
||||||
setImports(allDefs, imports, ['Codec']);
|
setImports(allDefs, imports, ['Codec']);
|
||||||
@@ -32,7 +38,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
|||||||
|
|
||||||
const items = constants
|
const items = constants
|
||||||
.map(({ docs, name, type }) => {
|
.map(({ docs, name, type }) => {
|
||||||
const returnType = formatType(meta.registry, allDefs, type.toString(), imports);
|
const typeDef = lookup.getTypeDef(type);
|
||||||
|
const returnType = typeDef.lookupName || formatType(registry, allDefs, typeDef, imports);
|
||||||
|
|
||||||
setImports(allDefs, imports, [returnType]);
|
setImports(allDefs, imports, [returnType]);
|
||||||
|
|
||||||
@@ -57,8 +64,8 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
|||||||
isStrict,
|
isStrict,
|
||||||
modules,
|
modules,
|
||||||
types: [
|
types: [
|
||||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
...Object.keys(imports.localTypes).sort().map<{ file: string; types: string[] }>((packagePath) => ({
|
||||||
file: packagePath,
|
file: packagePath.replace('@polkadot/types/augment', '@polkadot/types'),
|
||||||
types: Object.keys(imports.localTypes[packagePath])
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ const generateForMetaTemplate = Handlebars.compile(template);
|
|||||||
function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void {
|
function generateForMeta (meta: Metadata, dest: string, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const imports = createImports({});
|
const imports = createImports({});
|
||||||
|
const { lookup, pallets } = meta.asLatest;
|
||||||
const modules = meta.asLatest.modules
|
const modules = pallets
|
||||||
.filter((mod) => mod.errors.length > 0)
|
.filter(({ errors }) => errors.isSome)
|
||||||
.map(({ errors, name }) => ({
|
.map(({ errors, name }) => ({
|
||||||
items: errors
|
items: lookup.getSiType(errors.unwrap().type).def.asVariant.variants
|
||||||
.map(({ docs, name }) => ({
|
.map(({ docs, name }) => ({
|
||||||
docs,
|
docs,
|
||||||
name: name.toString()
|
name: name.toString()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import type { ExtraTypes } from './types';
|
|||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
|
import lookupDefinitions from '@polkadot/types/augment/lookup/definitions';
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
@@ -17,29 +18,34 @@ const generateForMetaTemplate = Handlebars.compile(template);
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes = {
|
||||||
|
'@polkadot/types/augment': { lookup: lookupDefinitions },
|
||||||
|
'@polkadot/types/interfaces': defaultDefs,
|
||||||
|
...extraTypes
|
||||||
|
};
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
}, {});
|
}, {});
|
||||||
|
const { lookup, pallets, registry } = meta.asLatest;
|
||||||
const modules = meta.asLatest.modules
|
const modules = pallets
|
||||||
.filter((mod) => mod.events.isSome)
|
.filter(({ events }) => events.isSome)
|
||||||
.map(({ events, name }) => ({
|
.map(({ events, name }) => ({
|
||||||
items: events
|
items: lookup.getSiType(events.unwrap().type).def.asVariant.variants
|
||||||
.unwrap()
|
.map(({ docs, fields, name }) => {
|
||||||
.sort(compareName)
|
const args = fields
|
||||||
.map(({ args, docs, name }) => {
|
.map(({ type }) => lookup.getTypeDef(type))
|
||||||
const types = args.map((type) => formatType(meta.registry, allDefs, type.toString(), imports));
|
.map((typeDef) => typeDef.lookupName || formatType(registry, allDefs, typeDef, imports));
|
||||||
|
|
||||||
setImports(allDefs, imports, types);
|
setImports(allDefs, imports, args);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
docs,
|
docs,
|
||||||
name: name.toString(),
|
name: name.toString(),
|
||||||
type: types.join(', ')
|
type: args.join(', ')
|
||||||
};
|
};
|
||||||
}).sort(compareName),
|
})
|
||||||
|
.sort(compareName),
|
||||||
name: stringCamelCase(name)
|
name: stringCamelCase(name)
|
||||||
}))
|
}))
|
||||||
.sort(compareName);
|
.sort(compareName);
|
||||||
@@ -51,7 +57,7 @@ function generateForMeta (meta: Metadata, dest: string, extraTypes: ExtraTypes,
|
|||||||
modules,
|
modules,
|
||||||
types: [
|
types: [
|
||||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||||
file: packagePath,
|
file: packagePath.replace('@polkadot/types/augment', '@polkadot/types'),
|
||||||
types: Object.keys(imports.localTypes[packagePath])
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export { generateDefaultConsts } from './consts';
|
|||||||
export { generateDefaultErrors } from './errors';
|
export { generateDefaultErrors } from './errors';
|
||||||
export { generateDefaultEvents } from './events';
|
export { generateDefaultEvents } from './events';
|
||||||
export { generateDefaultInterface } from './interfaceRegistry';
|
export { generateDefaultInterface } from './interfaceRegistry';
|
||||||
|
export { generateDefaultLookup } from './lookup';
|
||||||
export { generateDefaultQuery } from './query';
|
export { generateDefaultQuery } from './query';
|
||||||
export { generateDefaultRpc } from './rpc';
|
export { generateDefaultRpc } from './rpc';
|
||||||
export { generateDefaultTsDef } from './tsDef';
|
export { generateDefaultTsDef } from './tsDef';
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { TypeRegistry } from '@polkadot/types/create';
|
|||||||
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||||
import * as defaultPrimitives from '@polkadot/types/primitive';
|
import * as defaultPrimitives from '@polkadot/types/primitive';
|
||||||
|
|
||||||
import { createImports, getDerivedTypes, readTemplate, setImports, writeFile } from '../util';
|
import { createImports, readTemplate, setImports, writeFile } from '../util';
|
||||||
import { ModuleTypes } from '../util/imports';
|
import { ModuleTypes } from '../util/imports';
|
||||||
|
|
||||||
const primitiveClasses = {
|
const primitiveClasses = {
|
||||||
@@ -35,10 +35,10 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
|||||||
Object
|
Object
|
||||||
.keys(primitiveClasses)
|
.keys(primitiveClasses)
|
||||||
.filter((name) => !name.includes('Generic'))
|
.filter((name) => !name.includes('Generic'))
|
||||||
.forEach((primitiveName) => {
|
.forEach((primitiveName): void => {
|
||||||
setImports(definitions, imports, [primitiveName]);
|
setImports(definitions, imports, [primitiveName]);
|
||||||
|
|
||||||
items.push(...getDerivedTypes(registry, definitions, primitiveName, primitiveName, imports));
|
items.push(primitiveName);
|
||||||
});
|
});
|
||||||
|
|
||||||
const existingTypes: Record<string, boolean> = {};
|
const existingTypes: Record<string, boolean> = {};
|
||||||
@@ -55,10 +55,10 @@ export function generateInterfaceTypes (importDefinitions: { [importPath: string
|
|||||||
|
|
||||||
const uniqueTypes = Object.keys(types).filter((type) => !existingTypes[type]);
|
const uniqueTypes = Object.keys(types).filter((type) => !existingTypes[type]);
|
||||||
|
|
||||||
uniqueTypes.forEach((type) => {
|
uniqueTypes.forEach((type): void => {
|
||||||
existingTypes[type] = true;
|
existingTypes[type] = true;
|
||||||
|
|
||||||
items.push(...getDerivedTypes(registry, definitions, type, types[type] as string, imports));
|
items.push(type);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,270 @@
|
|||||||
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import type { PortableRegistry, PortableType, SiLookupTypeId, SiPath, SiTypeParameter } from '@polkadot/types/interfaces';
|
||||||
|
import type { TypeDef } from '@polkadot/types/types';
|
||||||
|
|
||||||
|
import Handlebars from 'handlebars';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import * as defaultDefinitions from '@polkadot/types/interfaces/definitions';
|
||||||
|
import { Registry } from '@polkadot/types/types';
|
||||||
|
import staticKusama from '@polkadot/types-support/metadata/static-kusama';
|
||||||
|
import staticPolkadot from '@polkadot/types-support/metadata/static-polkadot';
|
||||||
|
import staticSubstrate from '@polkadot/types-support/metadata/static-substrate';
|
||||||
|
import { isString, stringify } from '@polkadot/util';
|
||||||
|
|
||||||
|
import { createImports, exportType, initMeta, readTemplate, writeFile } from '../util';
|
||||||
|
import { typeEncoders } from './tsDef';
|
||||||
|
|
||||||
|
const MAP_ENUMS = ['Call', 'Event', 'Error', 'RawEvent'];
|
||||||
|
const WITH_TYPEDEF = false;
|
||||||
|
|
||||||
|
const generateLookupDefsTmpl = Handlebars.compile(readTemplate('lookup/defs'));
|
||||||
|
const generateLookupDefsNamedTmpl = Handlebars.compile(readTemplate('lookup/defs-named'));
|
||||||
|
const generateLookupIndexTmpl = Handlebars.compile(readTemplate('lookup/index'));
|
||||||
|
const generateLookupTypesTmpl = Handlebars.compile(readTemplate('lookup/types'));
|
||||||
|
|
||||||
|
function generateParamType (registry: Registry, { name, type }: SiTypeParameter): string {
|
||||||
|
if (type.isSome) {
|
||||||
|
const link = registry.lookup.types[type.unwrap().toNumber()];
|
||||||
|
|
||||||
|
if (link.type.path.length) {
|
||||||
|
return generateTypeDocs(registry, null, link.type.path, link.type.params);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return name.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateTypeDocs (registry: Registry, id: SiLookupTypeId | null, path: SiPath, params: SiTypeParameter[]): string {
|
||||||
|
return `${id ? `${registry.createLookupType(id)}${path.length ? ': ' : ''}` : ''}${path.map((p) => p.toString()).join('::')}${params.length ? `<${params.map((p) => generateParamType(registry, p)).join(', ')}>` : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatObject (lines: string[]): string[] {
|
||||||
|
const max = lines.length - 1;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'{',
|
||||||
|
...lines.map((l, index) =>
|
||||||
|
(l.endsWith(',') || l.endsWith('{') || index === max || lines[index + 1].endsWith('}') || lines[index + 1].endsWith('}'))
|
||||||
|
? l
|
||||||
|
: `${l},`
|
||||||
|
),
|
||||||
|
'}'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandSet (parsed: Record<string, number>): string[] {
|
||||||
|
return formatObject(
|
||||||
|
Object.entries(parsed).reduce<string[]>((all, [k, v]) => {
|
||||||
|
all.push(`${k}: ${v}`);
|
||||||
|
|
||||||
|
return all;
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandObject (parsed: Record<string, string | Record<string, string>>): string[] {
|
||||||
|
if (parsed._set) {
|
||||||
|
return expandSet(parsed._set as unknown as Record<string, number>);
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatObject(
|
||||||
|
Object.entries(parsed).reduce<string[]>((all, [k, v]) => {
|
||||||
|
const inner = isString(v)
|
||||||
|
? expandType(v)
|
||||||
|
: Array.isArray(v)
|
||||||
|
? [`[${(v as string[]).map((e) => `'${e}'`).join(', ')}]`]
|
||||||
|
: expandObject(v);
|
||||||
|
|
||||||
|
inner.forEach((l, index): void => {
|
||||||
|
all.push(`${
|
||||||
|
index === 0
|
||||||
|
? `${k}: ${l}`
|
||||||
|
: `${l}`
|
||||||
|
}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
return all;
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandType (encoded: string): string[] {
|
||||||
|
if (!encoded.startsWith('{')) {
|
||||||
|
return [`'${encoded}'`];
|
||||||
|
}
|
||||||
|
|
||||||
|
return expandObject(JSON.parse(encoded) as Record<string, string | Record<string, string>>);
|
||||||
|
}
|
||||||
|
|
||||||
|
function expandDefToString ({ lookupNameRoot, type }: TypeDef, indent: number): string {
|
||||||
|
if (lookupNameRoot) {
|
||||||
|
return `'${lookupNameRoot}'`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lines = expandType(type);
|
||||||
|
let inc = 0;
|
||||||
|
|
||||||
|
return lines.map((l, index) => {
|
||||||
|
let r: string;
|
||||||
|
|
||||||
|
if (l.endsWith('{')) {
|
||||||
|
r = index === 0
|
||||||
|
? l
|
||||||
|
: `${' '.padStart(indent + inc)}${l}`;
|
||||||
|
inc += 2;
|
||||||
|
} else {
|
||||||
|
if (l.endsWith('},') || l.endsWith('}')) {
|
||||||
|
inc -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = index === 0
|
||||||
|
? l
|
||||||
|
: `${' '.padStart(indent + inc)}${l}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}).join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFilteredTypes (lookup: PortableRegistry, exclude: string[] = []): [PortableType, TypeDef][] {
|
||||||
|
const named = lookup.types.filter(({ id, type: { path } }) => {
|
||||||
|
const typeDef = lookup.getTypeDef(id);
|
||||||
|
|
||||||
|
return (
|
||||||
|
// We actually only want those with lookupName set
|
||||||
|
!!typeDef.lookupName &&
|
||||||
|
!(
|
||||||
|
path.length === 2 &&
|
||||||
|
(
|
||||||
|
(
|
||||||
|
// Ensure that we match {node, kusama, *}_runtime
|
||||||
|
path[0].toString().split('_')[1] === 'runtime' &&
|
||||||
|
!['Call', 'Event'].includes(path[1].toString())
|
||||||
|
) ||
|
||||||
|
path[0].toString().startsWith('pallet_')
|
||||||
|
) &&
|
||||||
|
// Ensure we strip generics, e.g. Event<T>
|
||||||
|
MAP_ENUMS.includes(path[1].toString().split('<')[0])
|
||||||
|
) &&
|
||||||
|
!(
|
||||||
|
path.length >= 3 &&
|
||||||
|
path[path.length - 2].toString() === 'pallet' &&
|
||||||
|
// As above, cater for generics
|
||||||
|
MAP_ENUMS.includes(path[path.length - 1].toString().split('<')[0])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
const names = named.map(({ id }) => lookup.getName(id));
|
||||||
|
|
||||||
|
return named
|
||||||
|
.filter((_, index) =>
|
||||||
|
!names.some((n, iindex) =>
|
||||||
|
index > iindex &&
|
||||||
|
n === names[index]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.map((p): [PortableType, TypeDef] => [p, lookup.getTypeDef(p.id)])
|
||||||
|
.filter(([, typeDef]) => !exclude.includes(typeDef.lookupName || '<invalid>'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateLookupDefs (registry: Registry, filtered: [PortableType, TypeDef][], destDir: string, subPath?: string): void {
|
||||||
|
writeFile(path.join(destDir, `${subPath || 'definitions'}.ts`), (): string => {
|
||||||
|
const all = filtered.map(([{ id, type: { params, path } }, typeDef]) => {
|
||||||
|
const typeLookup = registry.createLookupType(id);
|
||||||
|
const def = expandDefToString(typeDef, subPath ? 2 : 4);
|
||||||
|
|
||||||
|
return {
|
||||||
|
docs: [
|
||||||
|
generateTypeDocs(registry, id, path, params),
|
||||||
|
WITH_TYPEDEF
|
||||||
|
? `@typeDef ${stringify(typeDef)}`
|
||||||
|
: null
|
||||||
|
].filter((d): d is string => !!d),
|
||||||
|
type: { def, typeLookup, typeName: typeDef.lookupName }
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const max = all.length - 1;
|
||||||
|
|
||||||
|
return (subPath ? generateLookupDefsNamedTmpl : generateLookupDefsTmpl)({
|
||||||
|
defs: all.map(({ docs, type }, i) => {
|
||||||
|
const { def, typeLookup, typeName } = type;
|
||||||
|
|
||||||
|
return {
|
||||||
|
defs: [
|
||||||
|
[typeName || typeLookup, `${def}${i !== max ? ',' : ''}`]
|
||||||
|
].map(([n, t]) => `${n}: ${t}`),
|
||||||
|
docs
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
headerType: 'defs'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateLookupTypes (registry: Registry, filtered: [PortableType, TypeDef][], destDir: string, subPath?: string): void {
|
||||||
|
const imports = {
|
||||||
|
...createImports(
|
||||||
|
{ '@polkadot/types/interfaces': defaultDefinitions },
|
||||||
|
{ types: {} }
|
||||||
|
),
|
||||||
|
interfaces: []
|
||||||
|
};
|
||||||
|
const items = filtered.map(([, typeDef]) => {
|
||||||
|
typeDef.name = typeDef.lookupName;
|
||||||
|
|
||||||
|
return typeDef.lookupNameRoot && typeDef.lookupName
|
||||||
|
? exportType(typeDef.lookupIndex, typeDef.lookupName, typeDef.lookupNameRoot)
|
||||||
|
: typeEncoders[typeDef.info](registry, imports.definitions, typeDef, imports);
|
||||||
|
}).filter((t): t is string => !!t);
|
||||||
|
|
||||||
|
writeFile(path.join(destDir, `types${subPath ? `-${subPath}` : ''}.ts`), () => generateLookupTypesTmpl({
|
||||||
|
headerType: 'defs',
|
||||||
|
imports,
|
||||||
|
items: items.map((l) =>
|
||||||
|
l
|
||||||
|
.split('\n')
|
||||||
|
.map((l) => l.length ? ` ${l}` : '')
|
||||||
|
.join('\n')
|
||||||
|
),
|
||||||
|
types: [
|
||||||
|
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||||
|
file: packagePath,
|
||||||
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
|
}))
|
||||||
|
]
|
||||||
|
}), true);
|
||||||
|
writeFile(path.join(destDir, 'index.ts'), () => generateLookupIndexTmpl({ headerType: 'defs' }), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateLookup (destDir: string, entries: [string | undefined, string][]): void {
|
||||||
|
entries.reduce<string[]>((exclude, [subPath, staticMeta]): string[] => {
|
||||||
|
const { lookup, registry } = initMeta(staticMeta).metadata.asLatest;
|
||||||
|
const filtered = getFilteredTypes(lookup, exclude);
|
||||||
|
|
||||||
|
generateLookupDefs(registry, filtered, destDir, subPath);
|
||||||
|
generateLookupTypes(registry, filtered, destDir, subPath);
|
||||||
|
|
||||||
|
return exclude.concat(
|
||||||
|
...filtered
|
||||||
|
.map(([, typeDef]) => typeDef.lookupName)
|
||||||
|
.filter((n): n is string => !!n)
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate `packages/types/src/lookup/*s`, the registry of all lookup types
|
||||||
|
export function generateDefaultLookup (destDir = 'packages/types/src/augment/lookup', staticData?: string): void {
|
||||||
|
generateLookup(
|
||||||
|
destDir,
|
||||||
|
staticData
|
||||||
|
? [[undefined, staticData]]
|
||||||
|
: [
|
||||||
|
['substrate', staticSubstrate],
|
||||||
|
['polkadot', staticPolkadot],
|
||||||
|
['kusama', staticKusama]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,15 +1,16 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
import type { PortableRegistry, StorageEntryMetadataLatest } from '@polkadot/types/interfaces/metadata';
|
||||||
import type { Metadata } from '@polkadot/types/metadata/Metadata';
|
import type { Metadata } from '@polkadot/types/metadata/Metadata';
|
||||||
import type { Registry } from '@polkadot/types/types';
|
import type { Registry } from '@polkadot/types/types';
|
||||||
import type { ExtraTypes } from './types';
|
import type { ExtraTypes } from './types';
|
||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
|
import lookupDefinitions from '@polkadot/types/augment/lookup/definitions';
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
import { unwrapStorageSi } from '@polkadot/types/primitive/StorageKey';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
|
|
||||||
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, TypeImports, writeFile } from '../util';
|
import { compareName, createImports, formatType, getSimilarTypes, initMeta, readTemplate, setImports, TypeImports, writeFile } from '../util';
|
||||||
@@ -17,69 +18,43 @@ import { ModuleTypes } from '../util/imports';
|
|||||||
|
|
||||||
// From a storage entry metadata, we return [args, returnType]
|
// From a storage entry metadata, we return [args, returnType]
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function entrySignature (allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [string, string, string] {
|
function entrySignature (lookup: PortableRegistry, allDefs: Record<string, ModuleTypes>, registry: Registry, storageEntry: StorageEntryMetadataLatest, imports: TypeImports): [boolean, string, string, string] {
|
||||||
const outputType = unwrapStorageType(registry, storageEntry.type, storageEntry.modifier.isOptional);
|
const outputType = lookup.getTypeDef(unwrapStorageSi(storageEntry.type));
|
||||||
|
|
||||||
if (storageEntry.type.isPlain) {
|
if (storageEntry.type.isPlain) {
|
||||||
setImports(allDefs, imports, [storageEntry.type.asPlain.toString()]);
|
const typeDef = lookup.getTypeDef(storageEntry.type.asPlain);
|
||||||
|
|
||||||
return ['', '', formatType(registry, allDefs, outputType, imports)];
|
setImports(allDefs, imports, [
|
||||||
|
typeDef.lookupName || typeDef.type,
|
||||||
|
storageEntry.modifier.isOptional
|
||||||
|
? 'Option'
|
||||||
|
: null
|
||||||
|
]);
|
||||||
|
|
||||||
|
return [storageEntry.modifier.isOptional, '', '', formatType(registry, allDefs, outputType, imports)];
|
||||||
} else if (storageEntry.type.isMap) {
|
} else if (storageEntry.type.isMap) {
|
||||||
const map = storageEntry.type.asMap;
|
const { hashers, key, value } = storageEntry.type.asMap;
|
||||||
|
const keyDefs = hashers.length === 1
|
||||||
// Find similar types of the `key` type
|
? [lookup.getTypeDef(key)]
|
||||||
const similarTypes = getSimilarTypes(registry, allDefs, map.key.toString(), imports);
|
: lookup.getSiType(key).def.asTuple.map((k) => lookup.getTypeDef(k));
|
||||||
|
const similarTypes = keyDefs.map((k) => getSimilarTypes(registry, allDefs, k.lookupName || k.type, imports));
|
||||||
setImports(allDefs, imports, [
|
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
||||||
...similarTypes,
|
const defValue = lookup.getTypeDef(value);
|
||||||
map.value.toString()
|
|
||||||
]);
|
|
||||||
|
|
||||||
return [
|
|
||||||
formatType(registry, allDefs, map.key.toString(), imports),
|
|
||||||
`arg: ${similarTypes.join(' | ')}`,
|
|
||||||
formatType(registry, allDefs, outputType, imports)
|
|
||||||
];
|
|
||||||
} else if (storageEntry.type.isDoubleMap) {
|
|
||||||
const dm = storageEntry.type.asDoubleMap;
|
|
||||||
|
|
||||||
// Find similar types of `key1` and `key2` types
|
|
||||||
const similarTypes1 = getSimilarTypes(registry, allDefs, dm.key1.toString(), imports);
|
|
||||||
const similarTypes2 = getSimilarTypes(registry, allDefs, dm.key2.toString(), imports);
|
|
||||||
|
|
||||||
setImports(allDefs, imports, [
|
|
||||||
...similarTypes1,
|
|
||||||
...similarTypes2,
|
|
||||||
dm.value.toString()
|
|
||||||
]);
|
|
||||||
|
|
||||||
const key1Types = similarTypes1.join(' | ');
|
|
||||||
const key2Types = similarTypes2.join(' | ');
|
|
||||||
|
|
||||||
return [
|
|
||||||
[
|
|
||||||
formatType(registry, allDefs, dm.key1.toString(), imports),
|
|
||||||
formatType(registry, allDefs, dm.key2.toString(), imports)
|
|
||||||
].join(', '),
|
|
||||||
`arg1: ${key1Types}, arg2: ${key2Types}`,
|
|
||||||
formatType(registry, allDefs, outputType, imports)
|
|
||||||
];
|
|
||||||
} else if (storageEntry.type.isNMap) {
|
|
||||||
const nmap = storageEntry.type.asNMap;
|
|
||||||
|
|
||||||
// Find similar types for all keys
|
|
||||||
const similarTypes = nmap.keyVec.map((k) => getSimilarTypes(registry, allDefs, k.toString(), imports));
|
|
||||||
|
|
||||||
setImports(allDefs, imports, [
|
setImports(allDefs, imports, [
|
||||||
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
|
...similarTypes.reduce<string[]>((all, t) => all.concat(t), []),
|
||||||
nmap.value.toString()
|
storageEntry.modifier.isOptional
|
||||||
|
? 'Option'
|
||||||
|
: null,
|
||||||
|
defValue.lookupName
|
||||||
|
? undefined
|
||||||
|
: defValue.type
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const keyTypes = similarTypes.map((t) => t.join(' | '));
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
nmap.keyVec.map((k) => formatType(registry, allDefs, k.toString(), imports)).join(', '),
|
storageEntry.modifier.isOptional,
|
||||||
keyTypes.map((t, i) => `arg${i + 1}: ${t}`).join(', '),
|
keyDefs.map((k) => formatType(registry, allDefs, k.lookupName || k.type, imports)).join(', '),
|
||||||
|
keyTypes.map((t, i) => `arg${keyTypes.length === 1 ? '' : (i + 1)}: ${t}`).join(', '),
|
||||||
formatType(registry, allDefs, outputType, imports)
|
formatType(registry, allDefs, outputType, imports)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -93,19 +68,25 @@ const generateForMetaTemplate = Handlebars.compile(template);
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: ExtraTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes: ExtraTypes = {
|
||||||
|
'@polkadot/types/augment': { lookup: lookupDefinitions },
|
||||||
|
'@polkadot/types/interfaces': defaultDefs,
|
||||||
|
...extraTypes
|
||||||
|
};
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
}, {});
|
}, {});
|
||||||
|
const { lookup, pallets } = meta.asLatest;
|
||||||
const modules = meta.asLatest.modules
|
const modules = pallets
|
||||||
.sort(compareName)
|
.filter(({ storage }) => storage.isSome)
|
||||||
.filter((mod) => !mod.storage.isNone)
|
|
||||||
.map(({ name, storage }) => {
|
.map(({ name, storage }) => {
|
||||||
const items = storage.unwrap().items
|
const items = storage.unwrap().items
|
||||||
.map((storageEntry) => {
|
.map((storageEntry) => {
|
||||||
const [args, params, returnType] = entrySignature(allDefs, registry, storageEntry, imports);
|
const [isOptional, args, params, _returnType] = entrySignature(lookup, allDefs, registry, storageEntry, imports);
|
||||||
|
const returnType = isOptional
|
||||||
|
? `Option<${_returnType}>`
|
||||||
|
: _returnType;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
args,
|
args,
|
||||||
@@ -134,7 +115,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
|||||||
modules,
|
modules,
|
||||||
types: [
|
types: [
|
||||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||||
file: packagePath,
|
file: packagePath.replace('@polkadot/types/augment', '@polkadot/types'),
|
||||||
types: Object.keys(imports.localTypes[packagePath])
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ export function generateRpcTypes (registry: TypeRegistry, importDefinitions: Rec
|
|||||||
modules,
|
modules,
|
||||||
types: [
|
types: [
|
||||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||||
file: packagePath,
|
file: packagePath.replace('@polkadot/types/augment', '@polkadot/types'),
|
||||||
types: Object.keys(imports.localTypes[packagePath])
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
}))
|
}))
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function errorUnhandled (_: Registry, definitions: Record<string, ModuleTypes>,
|
|||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function tsExport (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
function tsExport (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||||
return exportInterface(def.name, formatType(registry, definitions, def, imports));
|
return exportInterface(def.lookupIndex, def.name, formatType(registry, definitions, def, imports, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
const tsBTreeMap = tsExport;
|
const tsBTreeMap = tsExport;
|
||||||
@@ -48,16 +48,16 @@ const tsPlain = tsExport;
|
|||||||
const tsTuple = tsExport;
|
const tsTuple = tsExport;
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, { name: enumName, sub }: TypeDef, imports: TypeImports): string {
|
function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, { lookupIndex, name: enumName, sub }: TypeDef, imports: TypeImports): string {
|
||||||
setImports(definitions, imports, ['Enum']);
|
setImports(definitions, imports, ['Enum']);
|
||||||
|
|
||||||
const keys = (sub as TypeDef[]).map((def, index): string => {
|
const keys = (sub as TypeDef[]).map((def, index): string => {
|
||||||
const { info, name = `unknown${index}`, type } = def;
|
const { info, lookupName, name = `unknown${index}`, type } = def;
|
||||||
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
|
const getter = stringUpperFirst(stringCamelCase(name.replace(' ', '_')));
|
||||||
const isComplex = [TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
const isComplex = [TypeDefInfo.Result, TypeDefInfo.Struct, TypeDefInfo.Tuple, TypeDefInfo.Vec, TypeDefInfo.VecFixed].includes(info);
|
||||||
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
const asGetter = type === 'Null' || info === TypeDefInfo.DoNotConstruct
|
||||||
? ''
|
? ''
|
||||||
: createGetter(definitions, `as${getter}`, isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports) : type, imports);
|
: createGetter(definitions, `as${getter}`, lookupName || (isComplex ? formatType(registry, definitions, info === TypeDefInfo.Struct ? def : type, imports, false) : type), imports);
|
||||||
const isGetter = info === TypeDefInfo.DoNotConstruct
|
const isGetter = info === TypeDefInfo.DoNotConstruct
|
||||||
? ''
|
? ''
|
||||||
: createGetter(definitions, `is${getter}`, 'boolean', imports);
|
: createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||||
@@ -65,6 +65,8 @@ function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, {
|
|||||||
switch (info) {
|
switch (info) {
|
||||||
case TypeDefInfo.Compact:
|
case TypeDefInfo.Compact:
|
||||||
case TypeDefInfo.Plain:
|
case TypeDefInfo.Plain:
|
||||||
|
case TypeDefInfo.Result:
|
||||||
|
case TypeDefInfo.Si:
|
||||||
case TypeDefInfo.Struct:
|
case TypeDefInfo.Struct:
|
||||||
case TypeDefInfo.Tuple:
|
case TypeDefInfo.Tuple:
|
||||||
case TypeDefInfo.Vec:
|
case TypeDefInfo.Vec:
|
||||||
@@ -73,39 +75,54 @@ function tsEnum (registry: Registry, definitions: Record<string, ModuleTypes>, {
|
|||||||
return `${isGetter}${asGetter}`;
|
return `${isGetter}${asGetter}`;
|
||||||
|
|
||||||
case TypeDefInfo.DoNotConstruct:
|
case TypeDefInfo.DoNotConstruct:
|
||||||
return '';
|
case TypeDefInfo.Null:
|
||||||
|
return `${isGetter}`;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Enum: ${enumName || 'undefined'}: Unhandled type ${TypeDefInfo[info]}`);
|
throw new Error(`Enum: ${enumName || 'undefined'}: Unhandled type ${TypeDefInfo[info]}, ${stringify(def)}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return exportInterface(enumName, 'Enum', keys.join(''));
|
return exportInterface(lookupIndex, enumName, 'Enum', keys.join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
function tsInt (_: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports, type: 'Int' | 'UInt' = 'Int'): string {
|
function tsInt (_: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports, type: 'Int' | 'UInt' = 'Int'): string {
|
||||||
setImports(definitions, imports, [type]);
|
setImports(definitions, imports, [type]);
|
||||||
|
|
||||||
return exportInterface(def.name, type);
|
return exportInterface(def.lookupIndex, def.name, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @internal */
|
||||||
|
function tsNull (registry: Registry, definitions: Record<string, ModuleTypes>, { lookupIndex = -1, name }: TypeDef, imports: TypeImports): string {
|
||||||
|
setImports(definitions, imports, ['Null']);
|
||||||
|
|
||||||
|
// * @description extends [[${base}]]
|
||||||
|
const doc = `/** @name ${name || ''}${lookupIndex !== -1 ? ` (${lookupIndex})` : ''} */\n`;
|
||||||
|
|
||||||
|
return `${doc}export type ${name || ''} = Null;`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
function tsResultGetter (registry: Registry, definitions: Record<string, ModuleTypes>, resultName = '', getter: 'Ok' | 'Err' | 'Error', def: TypeDef, imports: TypeImports): string {
|
||||||
const { info, type } = def;
|
const { info, lookupName, type } = def;
|
||||||
const asGetter = type === 'Null'
|
const asGetter = type === 'Null'
|
||||||
? ''
|
? ''
|
||||||
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports) : type, imports);
|
: (getter === 'Error' ? ' /** @deprecated Use asErr */\n' : '') + createGetter(definitions, `as${getter}`, lookupName || (info === TypeDefInfo.Tuple ? formatType(registry, definitions, def, imports, false) : type), imports);
|
||||||
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
|
const isGetter = (getter === 'Error' ? ' /** @deprecated Use isErr */\n' : '') + createGetter(definitions, `is${getter}`, 'boolean', imports);
|
||||||
|
|
||||||
switch (info) {
|
switch (info) {
|
||||||
case TypeDefInfo.Plain:
|
case TypeDefInfo.Plain:
|
||||||
|
case TypeDefInfo.Si:
|
||||||
case TypeDefInfo.Tuple:
|
case TypeDefInfo.Tuple:
|
||||||
case TypeDefInfo.Vec:
|
case TypeDefInfo.Vec:
|
||||||
case TypeDefInfo.Option:
|
case TypeDefInfo.Option:
|
||||||
return `${isGetter}${asGetter}`;
|
return `${isGetter}${asGetter}`;
|
||||||
|
|
||||||
|
case TypeDefInfo.Null:
|
||||||
|
return `${isGetter}`;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new Error(`Result: ${resultName}: Unhandled type ${TypeDefInfo[info]}`);
|
throw new Error(`Result: ${resultName}: Unhandled type ${TypeDefInfo[info]}, ${stringify(def)}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,17 +138,22 @@ function tsResult (registry: Registry, definitions: Record<string, ModuleTypes>,
|
|||||||
|
|
||||||
setImports(definitions, imports, [def.type]);
|
setImports(definitions, imports, [def.type]);
|
||||||
|
|
||||||
return exportInterface(def.name, formatType(registry, definitions, def, imports), inner);
|
const fmtType = def.lookupName && def.name !== def.lookupName
|
||||||
|
? def.lookupName
|
||||||
|
: formatType(registry, definitions, def, imports, false);
|
||||||
|
|
||||||
|
return exportInterface(def.lookupIndex, def.name, fmtType, inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
function tsSi (registry: Registry, definitions: Record<string, ModuleTypes>, { type }: TypeDef, imports: TypeImports): string {
|
function tsSi (registry: Registry, definitions: Record<string, ModuleTypes>, typeDef: TypeDef, imports: TypeImports): string {
|
||||||
throw new Error('Unable to generate string definition from TypeDefInfo.Si');
|
// FIXME
|
||||||
|
return `// SI: ${JSON.stringify(typeDef)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function tsSet (_: Registry, definitions: Record<string, ModuleTypes>, { name: setName, sub }: TypeDef, imports: TypeImports): string {
|
function tsSet (_: Registry, definitions: Record<string, ModuleTypes>, { lookupIndex, name: setName, sub }: TypeDef, imports: TypeImports): string {
|
||||||
setImports(definitions, imports, ['Set']);
|
setImports(definitions, imports, ['Set']);
|
||||||
|
|
||||||
const types = (sub as TypeDef[]).map(({ name }): string => {
|
const types = (sub as TypeDef[]).map(({ name }): string => {
|
||||||
@@ -140,20 +162,22 @@ function tsSet (_: Registry, definitions: Record<string, ModuleTypes>, { name: s
|
|||||||
return createGetter(definitions, `is${name}`, 'boolean', imports);
|
return createGetter(definitions, `is${name}`, 'boolean', imports);
|
||||||
});
|
});
|
||||||
|
|
||||||
return exportInterface(setName, 'Set', types.join(''));
|
return exportInterface(lookupIndex, setName, 'Set', types.join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function tsStruct (registry: Registry, definitions: Record<string, ModuleTypes>, { name: structName, sub }: TypeDef, imports: TypeImports): string {
|
function tsStruct (registry: Registry, definitions: Record<string, ModuleTypes>, { lookupIndex, name: structName, sub }: TypeDef, imports: TypeImports): string {
|
||||||
setImports(definitions, imports, ['Struct']);
|
setImports(definitions, imports, ['Struct']);
|
||||||
|
|
||||||
const keys = (sub as TypeDef[]).map((typedef): string => {
|
const keys = (sub as TypeDef[]).map((def): string => {
|
||||||
const returnType = formatType(registry, definitions, typedef, imports);
|
const fmtType = def.lookupName && def.name !== def.lookupName
|
||||||
|
? def.lookupName
|
||||||
|
: formatType(registry, definitions, def, imports, false);
|
||||||
|
|
||||||
return createGetter(definitions, typedef.name, returnType, imports);
|
return createGetter(definitions, def.name, fmtType, imports);
|
||||||
});
|
});
|
||||||
|
|
||||||
return exportInterface(structName, 'Struct', keys.join(''));
|
return exportInterface(lookupIndex, structName, 'Struct', keys.join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
@@ -165,19 +189,29 @@ function tsUInt (registry: Registry, definitions: Record<string, ModuleTypes>, d
|
|||||||
function tsVec (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
function tsVec (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports): string {
|
||||||
const type = (def.sub as TypeDef).type;
|
const type = (def.sub as TypeDef).type;
|
||||||
|
|
||||||
if (def.info === TypeDefInfo.VecFixed && type === 'u8') {
|
if (type === 'u8') {
|
||||||
|
if (def.info === TypeDefInfo.VecFixed) {
|
||||||
setImports(definitions, imports, ['U8aFixed']);
|
setImports(definitions, imports, ['U8aFixed']);
|
||||||
|
|
||||||
return exportType(def.name, 'U8aFixed');
|
return exportType(def.lookupIndex, def.name, 'U8aFixed');
|
||||||
|
} else {
|
||||||
|
setImports(definitions, imports, ['Bytes']);
|
||||||
|
|
||||||
|
return exportType(def.lookupIndex, def.name, 'Bytes');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return exportInterface(def.name, formatType(registry, definitions, def, imports));
|
const fmtType = def.lookupName && def.name !== def.lookupName
|
||||||
|
? def.lookupName
|
||||||
|
: formatType(registry, definitions, def, imports, false);
|
||||||
|
|
||||||
|
return exportInterface(def.lookupIndex, def.name, fmtType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handlers are defined externally to use - this means that when we do a
|
// handlers are defined externally to use - this means that when we do a
|
||||||
// `generators[typedef.info](...)` TS will show any unhandled types. Rather
|
// `generators[typedef.info](...)` TS will show any unhandled types. Rather
|
||||||
// we are being explicit in having no handlers where we do not support (yet)
|
// we are being explicit in having no handlers where we do not support (yet)
|
||||||
const encoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string> = {
|
export const typeEncoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<string, ModuleTypes>, def: TypeDef, imports: TypeImports) => string> = {
|
||||||
[TypeDefInfo.BTreeMap]: tsBTreeMap,
|
[TypeDefInfo.BTreeMap]: tsBTreeMap,
|
||||||
[TypeDefInfo.BTreeSet]: tsBTreeSet,
|
[TypeDefInfo.BTreeSet]: tsBTreeSet,
|
||||||
[TypeDefInfo.Compact]: tsCompact,
|
[TypeDefInfo.Compact]: tsCompact,
|
||||||
@@ -186,9 +220,10 @@ const encoders: Record<TypeDefInfo, (registry: Registry, definitions: Record<str
|
|||||||
[TypeDefInfo.HashMap]: tsHashMap,
|
[TypeDefInfo.HashMap]: tsHashMap,
|
||||||
[TypeDefInfo.Int]: tsInt,
|
[TypeDefInfo.Int]: tsInt,
|
||||||
[TypeDefInfo.Linkage]: errorUnhandled,
|
[TypeDefInfo.Linkage]: errorUnhandled,
|
||||||
[TypeDefInfo.Null]: errorUnhandled,
|
[TypeDefInfo.Null]: tsNull,
|
||||||
[TypeDefInfo.Option]: tsOption,
|
[TypeDefInfo.Option]: tsOption,
|
||||||
[TypeDefInfo.Plain]: tsPlain,
|
[TypeDefInfo.Plain]: tsPlain,
|
||||||
|
[TypeDefInfo.Range]: errorUnhandled,
|
||||||
[TypeDefInfo.Result]: tsResult,
|
[TypeDefInfo.Result]: tsResult,
|
||||||
[TypeDefInfo.Set]: tsSet,
|
[TypeDefInfo.Set]: tsSet,
|
||||||
[TypeDefInfo.Si]: tsSi,
|
[TypeDefInfo.Si]: tsSi,
|
||||||
@@ -204,7 +239,7 @@ function generateInterfaces (registry: Registry, definitions: Record<string, Mod
|
|||||||
return Object.entries(types).map(([name, type]): [string, string] => {
|
return Object.entries(types).map(([name, type]): [string, string] => {
|
||||||
const def = getTypeDef(isString(type) ? type : stringify(type), { name });
|
const def = getTypeDef(isString(type) ? type : stringify(type), { name });
|
||||||
|
|
||||||
return [name, encoders[def.info](registry, definitions, def, imports)];
|
return [name, typeEncoders[def.info](registry, definitions, def, imports)];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,25 +253,23 @@ const templateTypes = readTemplate('tsDef/types');
|
|||||||
const generateTsDefTypesTemplate = Handlebars.compile(templateTypes);
|
const generateTsDefTypesTemplate = Handlebars.compile(templateTypes);
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function generateTsDefFor (registry: Registry, importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
|
export function generateTsDefFor (registry: Registry, importDefinitions: { [importPath: string]: Record<string, ModuleTypes> }, defName: string, { types }: { types: Record<string, any> }, outputDir: string): void {
|
||||||
const imports = { ...createImports(importDefinitions, { types }), interfaces: [] } as Imports;
|
const imports = { ...createImports(importDefinitions, { types }), interfaces: [] } as Imports;
|
||||||
const definitions = imports.definitions;
|
const definitions = imports.definitions;
|
||||||
const interfaces = generateInterfaces(registry, definitions, { types }, imports);
|
const interfaces = generateInterfaces(registry, definitions, { types }, imports);
|
||||||
const items = interfaces.sort((a, b): number => a[0].localeCompare(b[0])).map(([, definition]): string => definition);
|
const items = interfaces.sort((a, b) => a[0].localeCompare(b[0])).map(([, definition]) => definition);
|
||||||
|
|
||||||
const importTypes = [
|
|
||||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
|
||||||
file: packagePath,
|
|
||||||
types: Object.keys(imports.localTypes[packagePath])
|
|
||||||
}))
|
|
||||||
];
|
|
||||||
|
|
||||||
writeFile(path.join(outputDir, defName, 'types.ts'), () => generateTsDefModuleTypesTemplate({
|
writeFile(path.join(outputDir, defName, 'types.ts'), () => generateTsDefModuleTypesTemplate({
|
||||||
headerType: 'defs',
|
headerType: 'defs',
|
||||||
imports,
|
imports,
|
||||||
items,
|
items,
|
||||||
name: defName,
|
name: defName,
|
||||||
types: importTypes
|
types: [
|
||||||
|
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||||
|
file: packagePath.replace('@polkadot/types/augment', '@polkadot/types'),
|
||||||
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
|
}))
|
||||||
|
]
|
||||||
}), true);
|
}), true);
|
||||||
writeFile(path.join(outputDir, defName, 'index.ts'), () => generateTsDefIndexTemplate({ headerType: 'defs' }), true);
|
writeFile(path.join(outputDir, defName, 'index.ts'), () => generateTsDefIndexTemplate({ headerType: 'defs' }), true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { ExtraTypes } from './types';
|
|||||||
|
|
||||||
import Handlebars from 'handlebars';
|
import Handlebars from 'handlebars';
|
||||||
|
|
||||||
|
import lookupDefinitions from '@polkadot/types/augment/lookup/definitions';
|
||||||
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
import * as defaultDefs from '@polkadot/types/interfaces/definitions';
|
||||||
import { Text } from '@polkadot/types/primitive';
|
import { Text } from '@polkadot/types/primitive';
|
||||||
import { stringCamelCase } from '@polkadot/util';
|
import { stringCamelCase } from '@polkadot/util';
|
||||||
@@ -30,32 +31,54 @@ const generateForMetaTemplate = Handlebars.compile(template);
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
function generateForMeta (registry: Registry, meta: Metadata, dest: string, extraTypes: ExtraTypes, isStrict: boolean): void {
|
||||||
writeFile(dest, (): string => {
|
writeFile(dest, (): string => {
|
||||||
const allTypes: ExtraTypes = { '@polkadot/types/interfaces': defaultDefs, ...extraTypes };
|
const allTypes: ExtraTypes = {
|
||||||
|
'@polkadot/types/augment': { lookup: lookupDefinitions },
|
||||||
|
'@polkadot/types/interfaces': defaultDefs,
|
||||||
|
...extraTypes
|
||||||
|
};
|
||||||
const imports = createImports(allTypes);
|
const imports = createImports(allTypes);
|
||||||
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
const allDefs = Object.entries(allTypes).reduce((defs, [path, obj]) => {
|
||||||
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
return Object.entries(obj).reduce((defs, [key, value]) => ({ ...defs, [`${path}/${key}`]: value }), defs);
|
||||||
}, {});
|
}, {});
|
||||||
|
const { lookup, pallets } = meta.asLatest;
|
||||||
const modules = meta.asLatest.modules
|
const modules = pallets
|
||||||
.filter(({ calls }) => calls.unwrapOr([]).length !== 0)
|
.sort(compareName)
|
||||||
|
.filter(({ calls }) => calls.isSome)
|
||||||
.map(({ calls, name }) => {
|
.map(({ calls, name }) => {
|
||||||
setImports(allDefs, imports, ['Call', 'Extrinsic', 'SubmittableExtrinsic']);
|
setImports(allDefs, imports, ['Call', 'Extrinsic', 'SubmittableExtrinsic']);
|
||||||
|
|
||||||
const items = calls.unwrap()
|
const sectionName = stringCamelCase(name);
|
||||||
.map(({ args, docs, name }) => {
|
const items = lookup.getSiType(calls.unwrap().type).def.asVariant.variants
|
||||||
const params = args
|
.map(({ docs, fields, name }) => {
|
||||||
.map(({ name, type }) => {
|
const typesInfo = fields.map(({ name, type, typeName }, index): [string, string, string] => {
|
||||||
const typeStr = type.toString();
|
const typeDef = registry.lookup.getTypeDef(type);
|
||||||
|
|
||||||
|
return [
|
||||||
|
name.isSome
|
||||||
|
? mapName(name.unwrap())
|
||||||
|
: `param${index}`,
|
||||||
|
typeName.isSome
|
||||||
|
? typeName.toString()
|
||||||
|
: typeDef.type,
|
||||||
|
typeDef.isFromSi
|
||||||
|
? typeDef.type
|
||||||
|
: typeDef.lookupName || typeDef.type
|
||||||
|
];
|
||||||
|
});
|
||||||
|
const params = typesInfo
|
||||||
|
.map(([name,, typeStr]) => {
|
||||||
const similarTypes = getSimilarTypes(registry, allDefs, typeStr, imports);
|
const similarTypes = getSimilarTypes(registry, allDefs, typeStr, imports);
|
||||||
|
|
||||||
setImports(allDefs, imports, [typeStr, ...similarTypes]);
|
setImports(allDefs, imports, [typeStr, ...similarTypes]);
|
||||||
|
|
||||||
return `${mapName(name)}: ${similarTypes.join(' | ')}`;
|
return `${name}: ${similarTypes.join(' | ')}`;
|
||||||
})
|
})
|
||||||
.join(', ');
|
.join(', ');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
args: args.map(({ type }) => formatType(registry, allDefs, type.toString(), imports)).join(', '),
|
args: typesInfo.map(([,, typeStr]) =>
|
||||||
|
formatType(registry, allDefs, typeStr, imports)
|
||||||
|
).join(', '),
|
||||||
docs,
|
docs,
|
||||||
name: stringCamelCase(name),
|
name: stringCamelCase(name),
|
||||||
params
|
params
|
||||||
@@ -65,7 +88,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
items,
|
items,
|
||||||
name: stringCamelCase(name)
|
name: sectionName
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.sort(compareName);
|
.sort(compareName);
|
||||||
@@ -77,7 +100,7 @@ function generateForMeta (registry: Registry, meta: Metadata, dest: string, extr
|
|||||||
modules,
|
modules,
|
||||||
types: [
|
types: [
|
||||||
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
...Object.keys(imports.localTypes).sort().map((packagePath): { file: string; types: string[] } => ({
|
||||||
file: packagePath,
|
file: packagePath.replace('@polkadot/types/augment', '@polkadot/types'),
|
||||||
types: Object.keys(imports.localTypes[packagePath])
|
types: Object.keys(imports.localTypes[packagePath])
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultInterface, generateDefaultQuery, generateDefaultRpc, generateDefaultTsDef, generateDefaultTx } from './generate';
|
import { generateDefaultConsts, generateDefaultErrors, generateDefaultEvents, generateDefaultInterface, generateDefaultLookup, generateDefaultQuery, generateDefaultRpc, generateDefaultTsDef, generateDefaultTx } from './generate';
|
||||||
|
|
||||||
export function main (): void {
|
export function main (): void {
|
||||||
|
generateDefaultLookup();
|
||||||
generateDefaultInterface();
|
generateDefaultInterface();
|
||||||
|
|
||||||
generateDefaultConsts();
|
generateDefaultConsts();
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
import type { MetadataLatest } from '@polkadot/types/interfaces/metadata';
|
import type { MetadataLatest, PortableRegistry, SiLookupTypeId } from '@polkadot/types/interfaces';
|
||||||
import type { Codec, DefinitionRpcParam } from '@polkadot/types/types';
|
import type { Codec, DefinitionRpcParam } from '@polkadot/types/types';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
import { GenericCall as Call, Metadata, TypeRegistry, Vec } from '@polkadot/types';
|
import { Metadata, TypeRegistry, Vec } from '@polkadot/types';
|
||||||
import * as definitions from '@polkadot/types/interfaces/definitions';
|
import * as definitions from '@polkadot/types/interfaces/definitions';
|
||||||
import { getStorage as getSubstrateStorage } from '@polkadot/types/metadata/decorate/storage/getStorage';
|
import { getStorage as getSubstrateStorage } from '@polkadot/types/metadata/decorate/storage/getStorage';
|
||||||
import rpcdata from '@polkadot/types/metadata/static-substrate';
|
|
||||||
import { Text } from '@polkadot/types/primitive';
|
import { Text } from '@polkadot/types/primitive';
|
||||||
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
import { unwrapStorageType } from '@polkadot/types/primitive/StorageKey';
|
||||||
|
import rpcdata from '@polkadot/types-support/metadata/static-substrate';
|
||||||
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
import { stringCamelCase, stringLowerFirst } from '@polkadot/util';
|
||||||
|
|
||||||
interface SectionItem {
|
interface SectionItem {
|
||||||
@@ -45,9 +45,15 @@ const DESC_STORAGE = `The following sections contain Storage methods are part of
|
|||||||
/** @internal */
|
/** @internal */
|
||||||
function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
function docsVecToMarkdown (docLines: Vec<Text>, indent = 0): string {
|
||||||
const md = docLines
|
const md = docLines
|
||||||
.map((docLine) => docLine && docLine.substring(1)) // trim the leading space
|
.map((docLine) =>
|
||||||
.reduce((md, docLine): string => // generate paragraphs
|
docLine
|
||||||
!docLine.trim().length
|
.toString()
|
||||||
|
.trimStart()
|
||||||
|
.replace(/^r"/g, '')
|
||||||
|
.trimStart()
|
||||||
|
)
|
||||||
|
.reduce((md, docLine) => // generate paragraphs
|
||||||
|
!docLine.length
|
||||||
? `${md}\n\n` // empty line
|
? `${md}\n\n` // empty line
|
||||||
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
|
: /^[*-]/.test(docLine.trimStart()) && !md.endsWith('\n\n')
|
||||||
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
|
? `${md}\n\n${docLine}` // line calling for a preceding linebreak
|
||||||
@@ -112,6 +118,12 @@ function sortByName<T extends { name: Codec | string }> (a: T, b: T): number {
|
|||||||
return a.name.toString().toUpperCase().localeCompare(b.name.toString().toUpperCase());
|
return a.name.toString().toUpperCase().localeCompare(b.name.toString().toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSiName (lookup: PortableRegistry, type: SiLookupTypeId): string {
|
||||||
|
const typeDef = lookup.getTypeDef(type);
|
||||||
|
|
||||||
|
return typeDef.lookupName || typeDef.type;
|
||||||
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function addRpc (): string {
|
function addRpc (): string {
|
||||||
const sections = Object
|
const sections = Object
|
||||||
@@ -162,25 +174,25 @@ function addRpc (): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function addConstants (metadata: MetadataLatest): string {
|
function addConstants ({ lookup, pallets }: MetadataLatest): string {
|
||||||
return renderPage({
|
return renderPage({
|
||||||
description: DESC_CONSTANTS,
|
description: DESC_CONSTANTS,
|
||||||
sections: metadata.modules
|
sections: pallets
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.filter((moduleMetadata) => !moduleMetadata.constants.isEmpty)
|
.filter(({ constants }) => !constants.isEmpty)
|
||||||
.map((moduleMetadata) => {
|
.map(({ constants, name }) => {
|
||||||
const sectionName = stringLowerFirst(moduleMetadata.name);
|
const sectionName = stringLowerFirst(name);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: moduleMetadata.constants
|
items: constants
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.map((func) => {
|
.map(({ docs, name, type }) => {
|
||||||
const methodName = stringCamelCase(func.name);
|
const methodName = stringCamelCase(name);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
|
interface: '`' + `api.consts.${sectionName}.${methodName}` + '`',
|
||||||
name: `${methodName}: ` + '`' + func.type.toString() + '`',
|
name: `${methodName}: ` + '`' + getSiName(lookup, type) + '`',
|
||||||
...(func.docs.length && { summary: func.docs })
|
...(docs.length && { summary: docs })
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
name: sectionName
|
name: sectionName
|
||||||
@@ -191,9 +203,9 @@ function addConstants (metadata: MetadataLatest): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function addStorage (metadata: MetadataLatest): string {
|
function addStorage ({ lookup, pallets, registry }: MetadataLatest): string {
|
||||||
const { substrate } = getSubstrateStorage(metadata.registry);
|
const { substrate } = getSubstrateStorage(registry);
|
||||||
const moduleSections = metadata.modules
|
const moduleSections = pallets
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.filter((moduleMetadata) => !moduleMetadata.storage.isNone)
|
.filter((moduleMetadata) => !moduleMetadata.storage.isNone)
|
||||||
.map((moduleMetadata): Section => {
|
.map((moduleMetadata): Section => {
|
||||||
@@ -203,15 +215,20 @@ function addStorage (metadata: MetadataLatest): string {
|
|||||||
items: moduleMetadata.storage.unwrap().items
|
items: moduleMetadata.storage.unwrap().items
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.map((func) => {
|
.map((func) => {
|
||||||
const arg = func.type.isMap
|
let arg = '';
|
||||||
? ('`' + func.type.asMap.key.toString() + '`')
|
|
||||||
: func.type.isDoubleMap
|
if (func.type.isMap) {
|
||||||
? ('`' + func.type.asDoubleMap.key1.toString() + ', ' + func.type.asDoubleMap.key2.toString() + '`')
|
const { hashers, key } = func.type.asMap;
|
||||||
: func.type.isNMap
|
|
||||||
? ('`' + func.type.asNMap.keyVec.map((k) => k.toString()).join(', ') + '`')
|
arg = '`' + (
|
||||||
: '';
|
hashers.length === 1
|
||||||
|
? getSiName(lookup, key)
|
||||||
|
: lookup.getSiType(key).def.asTuple.map((t) => getSiName(lookup, t)).join(', ')
|
||||||
|
) + '`';
|
||||||
|
}
|
||||||
|
|
||||||
const methodName = stringLowerFirst(func.name);
|
const methodName = stringLowerFirst(func.name);
|
||||||
const outputType = unwrapStorageType(metadata.registry, func.type, func.modifier.isOptional);
|
const outputType = unwrapStorageType(registry, func.type, func.modifier.isOptional);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
interface: '`' + `api.query.${sectionName}.${methodName}` + '`',
|
interface: '`' + `api.query.${sectionName}.${methodName}` + '`',
|
||||||
@@ -229,12 +246,10 @@ function addStorage (metadata: MetadataLatest): string {
|
|||||||
description: 'These are well-known keys that are always available to the runtime implementation of any Substrate-based network.',
|
description: 'These are well-known keys that are always available to the runtime implementation of any Substrate-based network.',
|
||||||
items: Object.entries(substrate).map(([name, { meta }]) => {
|
items: Object.entries(substrate).map(([name, { meta }]) => {
|
||||||
const arg = meta.type.isMap
|
const arg = meta.type.isMap
|
||||||
? ('`' + meta.type.asMap.key.toString() + '`')
|
? ('`' + getSiName(lookup, meta.type.asMap.key) + '`')
|
||||||
: meta.type.isDoubleMap
|
|
||||||
? ('`' + meta.type.asDoubleMap.key1.toString() + ', ' + meta.type.asDoubleMap.key2.toString() + '`')
|
|
||||||
: '';
|
: '';
|
||||||
const methodName = stringLowerFirst(name);
|
const methodName = stringLowerFirst(name);
|
||||||
const outputType = unwrapStorageType(metadata.registry, meta.type, meta.modifier.isOptional);
|
const outputType = unwrapStorageType(registry, meta.type, meta.modifier.isOptional);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
interface: '`' + `api.query.substrate.${methodName}` + '`',
|
interface: '`' + `api.query.substrate.${methodName}` + '`',
|
||||||
@@ -249,26 +264,28 @@ function addStorage (metadata: MetadataLatest): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function addExtrinsics (metadata: MetadataLatest): string {
|
function addExtrinsics ({ lookup, pallets }: MetadataLatest): string {
|
||||||
return renderPage({
|
return renderPage({
|
||||||
description: DESC_EXTRINSICS,
|
description: DESC_EXTRINSICS,
|
||||||
sections: metadata.modules
|
sections: pallets
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.filter((meta) => !meta.calls.isNone && meta.calls.unwrap().length !== 0)
|
.filter(({ calls }) => calls.isSome)
|
||||||
.map((meta) => {
|
.map(({ calls, name }) => {
|
||||||
const sectionName = stringCamelCase(meta.name);
|
const sectionName = stringCamelCase(name);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: meta.calls.unwrap()
|
items: lookup.getSiType(calls.unwrap().type).def.asVariant.variants
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.map((func) => {
|
.map(({ docs, fields, name }, index) => {
|
||||||
const methodName = stringCamelCase(func.name);
|
const methodName = stringCamelCase(name);
|
||||||
const args = Call.filterOrigin(func).map(({ name, type }) => `${name.toString()}: ` + '`' + type.toString() + '`').join(', ');
|
const args = fields.map(({ name, type }) =>
|
||||||
|
`${name.isSome ? name.toString() : `param${index}`}: ` + '`' + getSiName(lookup, type) + '`'
|
||||||
|
).join(', ');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
interface: '`' + `api.tx.${sectionName}.${methodName}` + '`',
|
interface: '`' + `api.tx.${sectionName}.${methodName}` + '`',
|
||||||
name: `${methodName}(${args})`,
|
name: `${methodName}(${args})`,
|
||||||
...(func.docs.length && { summary: func.docs })
|
...(docs.length && { summary: docs })
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
name: sectionName
|
name: sectionName
|
||||||
@@ -279,23 +296,25 @@ function addExtrinsics (metadata: MetadataLatest): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function addEvents (metadata: MetadataLatest): string {
|
function addEvents ({ lookup, pallets }: MetadataLatest): string {
|
||||||
return renderPage({
|
return renderPage({
|
||||||
description: DESC_EVENTS,
|
description: DESC_EVENTS,
|
||||||
sections: metadata.modules
|
sections: pallets
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.filter((meta) => !meta.events.isNone && meta.events.unwrap().length !== 0)
|
.filter(({ events }) => events.isSome)
|
||||||
.map((meta) => ({
|
.map((meta) => ({
|
||||||
items: meta.events.unwrap()
|
items: lookup.getSiType(meta.events.unwrap().type).def.asVariant.variants
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.map((func) => {
|
.map(({ docs, fields, name }) => {
|
||||||
const methodName = func.name.toString();
|
const methodName = name.toString();
|
||||||
const args = func.args.map((type): string => '`' + type.toString() + '`').join(', ');
|
const args = fields.map(({ type }) =>
|
||||||
|
'`' + getSiName(lookup, type) + '`'
|
||||||
|
).join(', ');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
|
interface: '`' + `api.events.${stringCamelCase(meta.name)}.${methodName}.is` + '`',
|
||||||
name: `${methodName}(${args})`,
|
name: `${methodName}(${args})`,
|
||||||
...(func.docs.length && { summary: func.docs })
|
...(docs.length && { summary: docs })
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
name: stringCamelCase(meta.name)
|
name: stringCamelCase(meta.name)
|
||||||
@@ -305,14 +324,14 @@ function addEvents (metadata: MetadataLatest): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
function addErrors (metadata: MetadataLatest): string {
|
function addErrors ({ lookup, pallets }: MetadataLatest): string {
|
||||||
return renderPage({
|
return renderPage({
|
||||||
description: DESC_ERRORS,
|
description: DESC_ERRORS,
|
||||||
sections: metadata.modules
|
sections: pallets
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.filter((moduleMetadata) => !moduleMetadata.errors.isEmpty)
|
.filter(({ errors }) => errors.isSome)
|
||||||
.map((moduleMetadata) => ({
|
.map((moduleMetadata) => ({
|
||||||
items: moduleMetadata.errors
|
items: lookup.getSiType(moduleMetadata.errors.unwrap().type).def.asVariant.variants
|
||||||
.sort(sortByName)
|
.sort(sortByName)
|
||||||
.map((error) => ({
|
.map((error) => ({
|
||||||
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
|
interface: '`' + `api.errors.${stringCamelCase(moduleMetadata.name)}.${error.name.toString()}.is` + '`',
|
||||||
|
|||||||
@@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
// Auto-generated by @polkadot/dev, do not edit
|
// Auto-generated by @polkadot/dev, do not edit
|
||||||
|
|
||||||
export const packageInfo = { name: '@polkadot/typegen', version: '5.3.2' };
|
export const packageInfo = { name: '@polkadot/typegen', version: '6.1.1' };
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
declare module '@polkadot/types/types/registry' {
|
declare module '@polkadot/types/types/registry' {
|
||||||
export interface InterfaceTypes {
|
export interface InterfaceTypes {
|
||||||
{{#each items}}
|
{{#each items}}
|
||||||
{{{this}}}
|
{{{this}}}: {{{this}}};
|
||||||
{{/each}}
|
{{/each}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{{> header }}
|
||||||
|
|
||||||
|
/* eslint-disable sort-keys */
|
||||||
|
|
||||||
|
import type { DefinitionsTypes } from '../../types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
{{#each defs}}
|
||||||
|
{{> docs}}
|
||||||
|
{{#each defs}}
|
||||||
|
{{{this}}}
|
||||||
|
{{/each}}
|
||||||
|
{{/each}}
|
||||||
|
} as DefinitionsTypes;
|
||||||
|
{{> footer }}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
{{> header }}
|
||||||
|
|
||||||
|
/* eslint-disable sort-keys */
|
||||||
|
|
||||||
|
import type { Definitions } from '../../types';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
rpc: {},
|
||||||
|
types: {
|
||||||
|
{{#each defs}}
|
||||||
|
{{> docs}}
|
||||||
|
{{#each defs}}
|
||||||
|
{{{this}}}
|
||||||
|
{{/each}}
|
||||||
|
{{/each}}
|
||||||
|
}
|
||||||
|
} as Definitions;
|
||||||
|
{{> footer }}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{{> header }}
|
||||||
|
|
||||||
|
export * from './types';
|
||||||
|
{{> footer }}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{{> header }}
|
||||||
|
|
||||||
|
{{{ imports }}}
|
||||||
|
|
||||||
|
declare module '@polkadot/types/lookup' {
|
||||||
|
|
||||||
|
{{#each items}}
|
||||||
|
{{{this}}}
|
||||||
|
|
||||||
|
{{/each}}
|
||||||
|
}
|
||||||
|
{{> footer }}
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
// Copyright 2017-2021 @polkadot/typegen authors & contributors
|
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
import type { Constructor } from '@polkadot/types/types';
|
|
||||||
|
|
||||||
import { UInt } from '@polkadot/types/codec';
|
|
||||||
import { isChildClass } from '@polkadot/util';
|
|
||||||
|
|
||||||
/** @internal */
|
|
||||||
export function isCompactEncodable (Child: Constructor<any>): boolean {
|
|
||||||
return isChildClass(UInt, Child);
|
|
||||||
}
|
|
||||||
@@ -6,15 +6,13 @@ import type { Constructor, Registry } from '@polkadot/types/types';
|
|||||||
|
|
||||||
import { Compact, Enum, Option, Struct, Tuple, UInt, Vec } from '@polkadot/types/codec';
|
import { Compact, Enum, Option, Struct, Tuple, UInt, Vec } from '@polkadot/types/codec';
|
||||||
import { AbstractInt } from '@polkadot/types/codec/AbstractInt';
|
import { AbstractInt } from '@polkadot/types/codec/AbstractInt';
|
||||||
import { ClassOfUnsafe, getTypeDef } from '@polkadot/types/create';
|
import { getTypeDef } from '@polkadot/types/create';
|
||||||
import { TypeDefInfo } from '@polkadot/types/create/types';
|
import { TypeDefInfo } from '@polkadot/types/create/types';
|
||||||
import { GenericAccountId, GenericLookupSource, GenericVote } from '@polkadot/types/generic';
|
import { GenericAccountId, GenericLookupSource, GenericVote } from '@polkadot/types/generic';
|
||||||
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
|
import { AllConvictions } from '@polkadot/types/interfaces/democracy/definitions';
|
||||||
import { bool, Null } from '@polkadot/types/primitive';
|
import { bool, Null } from '@polkadot/types/primitive';
|
||||||
import * as primitiveClasses from '@polkadot/types/primitive';
|
|
||||||
import { isChildClass, stringify } from '@polkadot/util';
|
import { isChildClass, stringify } from '@polkadot/util';
|
||||||
|
|
||||||
import { isCompactEncodable } from './class';
|
|
||||||
import { formatType } from './formatting';
|
import { formatType } from './formatting';
|
||||||
import { ModuleTypes, setImports, TypeImports } from './imports';
|
import { ModuleTypes, setImports, TypeImports } from './imports';
|
||||||
|
|
||||||
@@ -24,46 +22,6 @@ function arrayToStrType (arr: string[]): string {
|
|||||||
|
|
||||||
const voteConvictions = arrayToStrType(AllConvictions);
|
const voteConvictions = arrayToStrType(AllConvictions);
|
||||||
|
|
||||||
// From `T`, generate `Compact<T>, Option<T>, Vec<T>`
|
|
||||||
/** @internal */
|
|
||||||
export function getDerivedTypes (registry: Registry, definitions: Record<string, ModuleTypes>, type: string, primitiveName: string, imports: TypeImports): string[] {
|
|
||||||
// `primitiveName` represents the actual primitive type our type is mapped to
|
|
||||||
const isCompact = isCompactEncodable(
|
|
||||||
(primitiveClasses as Record<string, any>)[primitiveName] ||
|
|
||||||
ClassOfUnsafe(registry, type)
|
|
||||||
);
|
|
||||||
const def = getTypeDef(type);
|
|
||||||
|
|
||||||
setImports(definitions, imports, ['Option', 'Vec', isCompact ? 'Compact' : '']);
|
|
||||||
|
|
||||||
const types = [
|
|
||||||
{
|
|
||||||
info: TypeDefInfo.Option,
|
|
||||||
sub: def,
|
|
||||||
type
|
|
||||||
},
|
|
||||||
{
|
|
||||||
info: TypeDefInfo.Vec,
|
|
||||||
sub: def,
|
|
||||||
type
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
if (isCompact) {
|
|
||||||
types.unshift({
|
|
||||||
info: TypeDefInfo.Compact,
|
|
||||||
sub: def,
|
|
||||||
type
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = types.map((t) => formatType(registry, definitions, t, imports)).map((t) => `'${t}': ${t};`);
|
|
||||||
|
|
||||||
result.unshift(`${type}: ${type};`);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make types a little bit more flexible
|
// Make types a little bit more flexible
|
||||||
// - if param instanceof AbstractInt, then param: u64 | Uint8array | AnyNumber
|
// - if param instanceof AbstractInt, then param: u64 | Uint8array | AnyNumber
|
||||||
// etc
|
// etc
|
||||||
@@ -87,7 +45,7 @@ export function getSimilarTypes (registry: Registry, definitions: Record<string,
|
|||||||
return ['null'];
|
return ['null'];
|
||||||
}
|
}
|
||||||
|
|
||||||
const Clazz = ClassOfUnsafe(registry, type);
|
const Clazz = registry.createClass(type);
|
||||||
|
|
||||||
if (isChildClass(Vec, Clazz)) {
|
if (isChildClass(Vec, Clazz)) {
|
||||||
const vecDef = getTypeDef(type);
|
const vecDef = getTypeDef(type);
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ Handlebars.registerHelper({
|
|||||||
...types
|
...types
|
||||||
];
|
];
|
||||||
|
|
||||||
return defs.reduce((result, { file, types }): string => {
|
return [...defs].sort((a, b) => a.file.localeCompare(b.file)).reduce((result, { file, types }): string => {
|
||||||
return types.length
|
return types.length
|
||||||
? `${result}import type { ${types.sort().join(', ')} } from '${file}';\n`
|
? `${result}import type { ${types.sort().join(', ')} } from '${file}';\n`
|
||||||
: result;
|
: result;
|
||||||
@@ -71,9 +71,9 @@ Handlebars.registerHelper({
|
|||||||
|
|
||||||
// helper to generate a `export interface <Name> extends <Base> {<Body>}
|
// helper to generate a `export interface <Name> extends <Base> {<Body>}
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function exportInterface (name = '', base: string, body = ''): string {
|
export function exportInterface (lookupIndex = -1, name = '', base: string, body = ''): string {
|
||||||
// * @description extends [[${base}]]
|
// * @description extends [[${base}]]
|
||||||
const doc = `/** @name ${name} */\n`;
|
const doc = `/** @name ${name}${lookupIndex !== -1 ? ` (${lookupIndex})` : ''} */\n`;
|
||||||
|
|
||||||
return `${doc}export interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`;
|
return `${doc}export interface ${name} extends ${base} {${body.length ? '\n' : ''}${body}}`;
|
||||||
}
|
}
|
||||||
@@ -82,19 +82,19 @@ export function exportInterface (name = '', base: string, body = ''): string {
|
|||||||
// but since we don't want type alias (TS doesn't preserve names) we use
|
// but since we don't want type alias (TS doesn't preserve names) we use
|
||||||
// interface here.
|
// interface here.
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function exportType (name = '', base: string): string {
|
export function exportType (lookupIndex = -1, name = '', base: string): string {
|
||||||
return exportInterface(name, base);
|
return exportInterface(lookupIndex, name, base);
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => string> = {
|
const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => string> = {
|
||||||
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Compact]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['Compact']);
|
|
||||||
|
|
||||||
const sub = typeDef.sub as TypeDef;
|
const sub = typeDef.sub as TypeDef;
|
||||||
|
|
||||||
return paramsNotation('Compact', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
setImports(definitions, imports, ['Compact', sub.lookupName]);
|
||||||
|
|
||||||
|
return paramsNotation('Compact', sub.lookupName || formatType(registry, definitions, sub.type, imports, withShortcut));
|
||||||
},
|
},
|
||||||
[TypeDefInfo.DoNotConstruct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.DoNotConstruct]: (registry: Registry, { lookupName }: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['DoNotConstruct']);
|
setImports(definitions, imports, ['DoNotConstruct']);
|
||||||
|
|
||||||
return 'DoNotConstruct';
|
return 'DoNotConstruct';
|
||||||
@@ -118,17 +118,20 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
|||||||
return 'Null';
|
return 'Null';
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Option]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['Option']);
|
|
||||||
|
|
||||||
const sub = (typeDef.sub as TypeDef);
|
const sub = (typeDef.sub as TypeDef);
|
||||||
|
|
||||||
return paramsNotation('Option', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
setImports(definitions, imports, ['Option', sub.lookupName]);
|
||||||
|
|
||||||
|
return paramsNotation('Option', sub.lookupName || formatType(registry, definitions, sub.type, imports, withShortcut));
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Plain]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Plain]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, [typeDef.type]);
|
setImports(definitions, imports, [typeDef.type]);
|
||||||
|
|
||||||
return typeDef.type;
|
return typeDef.type;
|
||||||
},
|
},
|
||||||
|
[TypeDefInfo.Range]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
|
throw new Error(`TypeDefInfo.Range: Not implemented on ${stringify(typeDef)}`);
|
||||||
|
},
|
||||||
[TypeDefInfo.Set]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Set]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
throw new Error(`TypeDefInfo.Set: Not implemented on ${stringify(typeDef)}`);
|
throw new Error(`TypeDefInfo.Set: Not implemented on ${stringify(typeDef)}`);
|
||||||
},
|
},
|
||||||
@@ -136,31 +139,39 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
|||||||
return formatType(registry, definitions, registry.lookup.getTypeDef(typeDef.type), imports, withShortcut);
|
return formatType(registry, definitions, registry.lookup.getTypeDef(typeDef.type), imports, withShortcut);
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Struct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Struct]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['Struct']);
|
if (typeDef.lookupName) {
|
||||||
|
return typeDef.lookupName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sub = typeDef.sub as TypeDef[];
|
||||||
|
|
||||||
|
setImports(definitions, imports, ['Struct', ...sub.map(({ lookupName }) => lookupName)]);
|
||||||
|
|
||||||
return `{${withShortcut ? ' ' : '\n'}${
|
return `{${withShortcut ? ' ' : '\n'}${
|
||||||
((typeDef.sub as TypeDef[]).map(({ lookupName, name, type }, index) => [
|
sub.map(({ lookupName, name, type }, index) => [
|
||||||
name || `unknown${index}`,
|
name || `unknown${index}`,
|
||||||
formatType(registry, definitions, lookupName || type, imports, withShortcut)
|
lookupName || formatType(registry, definitions, type, imports, withShortcut)
|
||||||
])).map(([k, t]) => `${withShortcut ? '' : ' readonly '}${k}: ${t};`).join(withShortcut ? ' ' : '\n')
|
]).map(([k, t]) => `${withShortcut ? '' : ' readonly '}${k}: ${t};`).join(withShortcut ? ' ' : '\n')
|
||||||
}${withShortcut ? ' ' : '\n '}} & Struct`;
|
}${withShortcut ? ' ' : '\n '}} & Struct`;
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Tuple]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Tuple]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['ITuple']);
|
const sub = typeDef.sub as TypeDef[];
|
||||||
|
|
||||||
|
setImports(definitions, imports, ['ITuple', ...sub.map(({ lookupName }) => lookupName)]);
|
||||||
|
|
||||||
// `(a,b)` gets transformed into `ITuple<[a, b]>`
|
// `(a,b)` gets transformed into `ITuple<[a, b]>`
|
||||||
return paramsNotation('ITuple', `[${
|
return paramsNotation('ITuple', `[${
|
||||||
((typeDef.sub as TypeDef[]).map(({ lookupName, type }) =>
|
sub.map(({ lookupName, type }) =>
|
||||||
formatType(registry, definitions, lookupName || type, imports, withShortcut)
|
lookupName || formatType(registry, definitions, type, imports, withShortcut)
|
||||||
)).join(', ')
|
).join(', ')
|
||||||
}]`);
|
}]`);
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Vec]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['Vec']);
|
|
||||||
|
|
||||||
const sub = (typeDef.sub as TypeDef);
|
const sub = (typeDef.sub as TypeDef);
|
||||||
|
|
||||||
return paramsNotation('Vec', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
setImports(definitions, imports, ['Vec', sub.lookupName]);
|
||||||
|
|
||||||
|
return paramsNotation('Vec', sub.lookupName || formatType(registry, definitions, sub.type, imports, withShortcut));
|
||||||
},
|
},
|
||||||
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.VecFixed]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
const sub = (typeDef.sub as TypeDef);
|
const sub = (typeDef.sub as TypeDef);
|
||||||
@@ -171,44 +182,44 @@ const formatters: Record<TypeDefInfo, (registry: Registry, typeDef: TypeDef, def
|
|||||||
return 'U8aFixed';
|
return 'U8aFixed';
|
||||||
}
|
}
|
||||||
|
|
||||||
setImports(definitions, imports, ['Vec']);
|
setImports(definitions, imports, ['Vec', sub.lookupName]);
|
||||||
|
|
||||||
return paramsNotation('Vec', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
return paramsNotation('Vec', sub.lookupName || formatType(registry, definitions, sub.type, imports, withShortcut));
|
||||||
},
|
},
|
||||||
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.BTreeMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['BTreeMap']);
|
|
||||||
|
|
||||||
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
||||||
|
|
||||||
return `BTreeMap<${formatType(registry, definitions, keyDef.lookupName || keyDef.type, imports, withShortcut)}, ${formatType(registry, definitions, valDef.lookupName || valDef.type, imports, withShortcut)}>`;
|
setImports(definitions, imports, ['BTreeMap', keyDef.lookupName, valDef.lookupName]);
|
||||||
|
|
||||||
|
return `BTreeMap<${keyDef.lookupName || formatType(registry, definitions, keyDef.type, imports, withShortcut)}, ${valDef.lookupName || formatType(registry, definitions, valDef.type, imports, withShortcut)}>`;
|
||||||
},
|
},
|
||||||
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.BTreeSet]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['BTreeSet']);
|
|
||||||
|
|
||||||
const valDef = typeDef.sub as TypeDef;
|
const valDef = typeDef.sub as TypeDef;
|
||||||
|
|
||||||
return `BTreeSet<${formatType(registry, definitions, valDef.lookupName || valDef.type, imports, withShortcut)}>`;
|
setImports(definitions, imports, ['BTreeSet', valDef.lookupName]);
|
||||||
|
|
||||||
|
return `BTreeSet<${valDef.lookupName || formatType(registry, definitions, valDef.type, imports, withShortcut)}>`;
|
||||||
},
|
},
|
||||||
[TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.HashMap]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['HashMap']);
|
|
||||||
|
|
||||||
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
const [keyDef, valDef] = (typeDef.sub as TypeDef[]);
|
||||||
|
|
||||||
return `HashMap<${formatType(registry, definitions, keyDef.lookupName || keyDef.type, imports, withShortcut)}, ${formatType(registry, definitions, valDef.lookupName || valDef.type, imports, withShortcut)}>`;
|
setImports(definitions, imports, ['HashMap', keyDef.lookupName, valDef.lookupName]);
|
||||||
|
|
||||||
|
return `HashMap<${keyDef.lookupName || formatType(registry, definitions, keyDef.type, imports, withShortcut)}, ${valDef.lookupName || formatType(registry, definitions, valDef.type, imports, withShortcut)}>`;
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Linkage]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['Linkage']);
|
|
||||||
|
|
||||||
const sub = (typeDef.sub as TypeDef);
|
const sub = (typeDef.sub as TypeDef);
|
||||||
|
|
||||||
return paramsNotation('Linkage', formatType(registry, definitions, sub.lookupName || sub.type, imports, withShortcut));
|
setImports(definitions, imports, ['Linkage', sub.lookupName]);
|
||||||
|
|
||||||
|
return paramsNotation('Linkage', sub.lookupName || formatType(registry, definitions, sub.type, imports, withShortcut));
|
||||||
},
|
},
|
||||||
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
[TypeDefInfo.Result]: (registry: Registry, typeDef: TypeDef, definitions: Record<string, ModuleTypes>, imports: TypeImports, withShortcut: boolean) => {
|
||||||
setImports(definitions, imports, ['Result']);
|
|
||||||
|
|
||||||
const [okDef, errDef] = (typeDef.sub as TypeDef[]);
|
const [okDef, errDef] = (typeDef.sub as TypeDef[]);
|
||||||
|
|
||||||
return `Result<${formatType(registry, definitions, okDef.lookupName || okDef.type, imports, withShortcut)}, ${formatType(registry, definitions, errDef.lookupName || errDef.type, imports, withShortcut)}>`;
|
setImports(definitions, imports, ['Result', okDef.lookupName, errDef.lookupName]);
|
||||||
|
|
||||||
|
return `Result<${okDef.lookupName || formatType(registry, definitions, okDef.type, imports, withShortcut)}, ${errDef.lookupName || formatType(registry, definitions, errDef.type, imports, withShortcut)}>`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,7 +245,7 @@ export function formatType (registry: Registry, definitions: Record<string, Modu
|
|||||||
typeDef = type;
|
typeDef = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
setImports(definitions, imports, [typeDef.type]);
|
setImports(definitions, imports, [typeDef.lookupName || typeDef.type]);
|
||||||
|
|
||||||
return formatters[typeDef.info](registry, typeDef, definitions, imports, withShortcut);
|
return formatters[typeDef.info](registry, typeDef, definitions, imports, withShortcut);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ export interface TypeImports {
|
|||||||
// Maps the types as found to the source location. This is used to generate the
|
// Maps the types as found to the source location. This is used to generate the
|
||||||
// imports in the output file, dep-duped and sorted
|
// imports in the output file, dep-duped and sorted
|
||||||
/** @internal */
|
/** @internal */
|
||||||
export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeImports, types: string[]): void {
|
export function setImports (allDefs: Record<string, ModuleTypes>, imports: TypeImports, types: (string | null | undefined)[]): void {
|
||||||
const { codecTypes, extrinsicTypes, genericTypes, ignoredTypes, localTypes, metadataTypes, primitiveTypes, typesTypes } = imports;
|
const { codecTypes, extrinsicTypes, genericTypes, ignoredTypes, localTypes, metadataTypes, primitiveTypes, typesTypes } = imports;
|
||||||
|
|
||||||
types.forEach((type): void => {
|
types.filter((t): t is string => !!t).forEach((type): void => {
|
||||||
if (ignoredTypes.includes(type)) {
|
if (ignoredTypes.includes(type)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (['AnyNumber', 'CallFunction', 'Codec', 'IExtrinsic', 'ITuple'].includes(type)) {
|
} else if (['AnyNumber', 'CallFunction', 'Codec', 'IExtrinsic', 'ITuple'].includes(type)) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user