Skip to content

Commit 7dea97e

Browse files
author
Joshua Mir
committed
aggregate types
1 parent 94a3b37 commit 7dea97e

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ to build the test node, run:
2121

2222
add the `--release` flag to either of those commands to create a release build - debug and release builds will be located in `./target/release` or `./target/debug` respectively.
2323

24+
### Custom Types
25+
26+
You can aggregate the custom types of any pallets in `datdot-node/pallets` by running:
27+
`node datdot-node/runtime/aggregate_types.js`
28+
This will produce a `types.json` file.
29+
30+
Performing this requires each pallet defined in `aggregate_types.js` have their own types.json file premade.
31+
2432
### Running
2533

2634
currently, executing `./target/release/datdot-node --dev` (or `./target/debug/datdot-node --dev` if you didn't use a `--release` flag) runs a dev node. You can interact with this node by using the [Polkadot.js Apps UI](https://polkadot.js.org/apps/) - selecting "local node" as your endpoint in the settings page should connect you to your node; however, until you [specify the additional types](https://polkadot.js.org/api/start/types.extend.html#user-defined-types) in the developer tab, all functionality of the Apps UI will remain disabled.

datdot-node/runtime/aggregate_types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fs = require('fs');
77
// Does not include system pallets because Apps already supports them.
88
// Redundant with construct_runtime!
99
const pallets = [
10-
"dat_verify"
10+
"datdot"
1111
]
1212

1313
// Types that are native to the runtime itself (ie come from lib.rs)
@@ -21,7 +21,7 @@ const runtimeOwnTypes = {
2121
let finalTypes = runtimeOwnTypes;
2222
let palletTypes;
2323
for (let dirname of pallets) {
24-
let path = `../../pallets/${dirname}/types.json`;
24+
let path = `datdot-node/pallets/${dirname}/types.json`;
2525
palletTypes = JSON.parse(fs.readFileSync(path, 'utf8'));
2626
finalTypes = {...finalTypes, ...palletTypes};
2727
}

datdot-node/runtime/types.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

types.json

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"Address": "AccountId",
3+
"LookupSource": "AccountId",
4+
"Node": {
5+
"index": "u64",
6+
"hash": "H256",
7+
"size": "u64"
8+
},
9+
"Proof": {
10+
"index": "u64",
11+
"nodes": "Vec<Node>",
12+
"signature": "Option<Signature>"
13+
},
14+
"ChunkHashPayload": {
15+
"hash_type": "u8",
16+
"chunk_length": "u64",
17+
"chunk_content": "Vec<u8>"
18+
},
19+
"ParentHashPayload": {
20+
"hash_type": "u8",
21+
"total_length": "u64",
22+
"child_hashes": "[H256; 2]"
23+
},
24+
"ParentHashInRoot": {
25+
"hash": "H256",
26+
"hash_number": "u64",
27+
"total_length": "u64"
28+
},
29+
"RootHashPayload": {
30+
"hash_type": "u8",
31+
"children": "Vec<ParentHashInRoot>"
32+
},
33+
"Attestation": {
34+
"location": "u8",
35+
"latency": "Option<u8>"
36+
},
37+
"ChallengeAttestations": {
38+
"expected_attestors": "Vec<u64>",
39+
"expected_friends": "Vec<u64>",
40+
"completed": "Vec<(u64, Attestation)>"
41+
},
42+
"DatIdIndex": "u64",
43+
"DatIdVec": "Vec<DatIdIndex>",
44+
"UserIdIndex": "u64",
45+
"DatSize": "u64",
46+
"Public": "[u8; 32]"
47+
}

0 commit comments

Comments
 (0)