@storagehub/api-augment 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -0
- package/biome.json +10 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/augment-api-consts.js +6 -0
- package/dist/interfaces/augment-api-consts.js.map +1 -0
- package/dist/interfaces/augment-api-errors.js +6 -0
- package/dist/interfaces/augment-api-errors.js.map +1 -0
- package/dist/interfaces/augment-api-events.js +6 -0
- package/dist/interfaces/augment-api-events.js.map +1 -0
- package/dist/interfaces/augment-api-query.js +6 -0
- package/dist/interfaces/augment-api-query.js.map +1 -0
- package/dist/interfaces/augment-api-rpc.js +6 -0
- package/dist/interfaces/augment-api-rpc.js.map +1 -0
- package/dist/interfaces/augment-api-runtime.js +6 -0
- package/dist/interfaces/augment-api-runtime.js.map +1 -0
- package/dist/interfaces/augment-api-tx.js +6 -0
- package/dist/interfaces/augment-api-tx.js.map +1 -0
- package/dist/interfaces/augment-api.js +10 -0
- package/dist/interfaces/augment-api.js.map +1 -0
- package/dist/interfaces/augment-types.js +6 -0
- package/dist/interfaces/augment-types.js.map +1 -0
- package/dist/interfaces/definitions.js +2 -0
- package/dist/interfaces/definitions.js.map +1 -0
- package/dist/interfaces/index.js +4 -0
- package/dist/interfaces/index.js.map +1 -0
- package/dist/interfaces/lookup.js +4504 -0
- package/dist/interfaces/lookup.js.map +1 -0
- package/dist/interfaces/registry.js +6 -0
- package/dist/interfaces/registry.js.map +1 -0
- package/dist/interfaces/storagehubclient/definitions.js +7 -0
- package/dist/interfaces/storagehubclient/definitions.js.map +1 -0
- package/dist/interfaces/storagehubclient/index.js +4 -0
- package/dist/interfaces/storagehubclient/index.js.map +1 -0
- package/dist/interfaces/storagehubclient/runtime.js +152 -0
- package/dist/interfaces/storagehubclient/runtime.js.map +1 -0
- package/dist/interfaces/storagehubclient/types.js +4 -0
- package/dist/interfaces/storagehubclient/types.js.map +1 -0
- package/dist/interfaces/types-lookup.js +6 -0
- package/dist/interfaces/types-lookup.js.map +1 -0
- package/dist/interfaces/types.js +4 -0
- package/dist/interfaces/types.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces/augment-api-consts.d.ts +556 -0
- package/dist/types/interfaces/augment-api-errors.d.ts +1195 -0
- package/dist/types/interfaces/augment-api-events.d.ts +2070 -0
- package/dist/types/interfaces/augment-api-query.d.ts +1439 -0
- package/dist/types/interfaces/augment-api-rpc.d.ts +718 -0
- package/dist/types/interfaces/augment-api-runtime.d.ts +441 -0
- package/dist/types/interfaces/augment-api-tx.d.ts +3039 -0
- package/dist/types/interfaces/augment-api.d.ts +7 -0
- package/dist/types/interfaces/augment-types.d.ts +1285 -0
- package/dist/types/interfaces/definitions.d.ts +1 -0
- package/dist/types/interfaces/index.d.ts +1 -0
- package/dist/types/interfaces/lookup.d.ts +4179 -0
- package/dist/types/interfaces/registry.d.ts +272 -0
- package/dist/types/interfaces/storagehubclient/definitions.d.ts +6 -0
- package/dist/types/interfaces/storagehubclient/index.d.ts +1 -0
- package/dist/types/interfaces/storagehubclient/runtime.d.ts +2 -0
- package/dist/types/interfaces/storagehubclient/types.d.ts +198 -0
- package/dist/types/interfaces/types-lookup.d.ts +4457 -0
- package/dist/types/interfaces/types.d.ts +1 -0
- package/package.json +38 -0
- package/scripts/scrapeMetadata.ts +77 -0
- package/src/index.ts +3 -0
- package/src/interfaces/augment-api-consts.ts +570 -0
- package/src/interfaces/augment-api-errors.ts +1203 -0
- package/src/interfaces/augment-api-events.ts +1836 -0
- package/src/interfaces/augment-api-query.ts +1975 -0
- package/src/interfaces/augment-api-rpc.ts +1201 -0
- package/src/interfaces/augment-api-runtime.ts +707 -0
- package/src/interfaces/augment-api-tx.ts +3418 -0
- package/src/interfaces/augment-api.ts +10 -0
- package/src/interfaces/augment-types.ts +2508 -0
- package/src/interfaces/definitions.ts +1 -0
- package/src/interfaces/index.ts +4 -0
- package/src/interfaces/lookup.ts +4511 -0
- package/src/interfaces/registry.ts +546 -0
- package/src/interfaces/storagehubclient/definitions.ts +7 -0
- package/src/interfaces/storagehubclient/index.ts +4 -0
- package/src/interfaces/storagehubclient/runtime.ts +156 -0
- package/src/interfaces/storagehubclient/types.ts +241 -0
- package/src/interfaces/types-lookup.ts +5623 -0
- package/src/interfaces/types.ts +4 -0
- package/storagehub.json +1 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./storagehubclient/types.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@storagehub/api-augment",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"scrape": "pnpm tsx scripts/scrapeMetadata.ts",
|
|
7
|
+
"fmt": "biome format .",
|
|
8
|
+
"fmt:fix": "biome format . --write",
|
|
9
|
+
"tsc": "tsc --noEmit --pretty",
|
|
10
|
+
"build": "tsc -b --verbose",
|
|
11
|
+
"generate:all": "pnpm generate:defs && pnpm generate:meta",
|
|
12
|
+
"generate:defs": "pnpm tsx node_modules/@polkadot/typegen/scripts/polkadot-types-from-defs.mjs --package @storagehub/api-augment/interfaces --input ./src/interfaces --endpoint ./storagehub.json",
|
|
13
|
+
"generate:meta": "pnpm tsx node_modules/@polkadot/typegen/scripts/polkadot-types-from-chain.mjs --package @storagehub/api-augment/interfaces --endpoint ./storagehub.json --output ./src/interfaces"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [],
|
|
16
|
+
"author": "",
|
|
17
|
+
"module": "./dist/index.js",
|
|
18
|
+
"types": "./dist/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/types/index.d.ts",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"license": "ISC",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@polkadot/api": "12.4.2",
|
|
29
|
+
"@polkadot/api-base": "12.4.2",
|
|
30
|
+
"@polkadot/rpc-core": "12.4.2",
|
|
31
|
+
"@polkadot/typegen": "12.4.2",
|
|
32
|
+
"@polkadot/types": "12.4.2",
|
|
33
|
+
"@polkadot/types-codec": "12.4.2",
|
|
34
|
+
"@storagehub/types-bundle": "workspace:*",
|
|
35
|
+
"tsx": "4.19.0",
|
|
36
|
+
"typescript": "5.5.4"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { execSync, spawn } from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const fetchMetadata = async () => {
|
|
6
|
+
const maxRetries = 60;
|
|
7
|
+
const sleepTime = 500;
|
|
8
|
+
const url = "http://localhost:9944";
|
|
9
|
+
const payload = {
|
|
10
|
+
id: "1",
|
|
11
|
+
jsonrpc: "2.0",
|
|
12
|
+
method: "state_getMetadata",
|
|
13
|
+
params: []
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
17
|
+
try {
|
|
18
|
+
const response = await fetch(url, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: {
|
|
21
|
+
"Content-Type": "application/json"
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify(payload)
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return response.arrayBuffer();
|
|
31
|
+
} catch {
|
|
32
|
+
console.log("Waiting for node to launch...");
|
|
33
|
+
await new Promise((resolve) => setTimeout(resolve, sleepTime));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log(`Error fetching container IP after ${(maxRetries * sleepTime) / 1000} seconds`);
|
|
37
|
+
throw new Error("Error fetching metadata");
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
async function main() {
|
|
41
|
+
const nodePath = path.join(process.cwd(), "..", "target", "release", "storage-hub-node");
|
|
42
|
+
const metadataPath = path.join(process.cwd(), "storagehub.json");
|
|
43
|
+
|
|
44
|
+
if (!fs.existsSync(nodePath)) {
|
|
45
|
+
console.error("Storage Hub Node not found at path: ", nodePath);
|
|
46
|
+
throw new Error("File not found");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// TODO: replace with dockerode
|
|
50
|
+
spawn(
|
|
51
|
+
"docker",
|
|
52
|
+
[
|
|
53
|
+
"compose",
|
|
54
|
+
"-f=../docker/local-node-compose.yml",
|
|
55
|
+
"up",
|
|
56
|
+
"--remove-orphans",
|
|
57
|
+
"--renew-anon-volumes"
|
|
58
|
+
],
|
|
59
|
+
{
|
|
60
|
+
stdio: "inherit"
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const metadata = await fetchMetadata();
|
|
65
|
+
fs.writeFileSync(metadataPath, Buffer.from(metadata));
|
|
66
|
+
|
|
67
|
+
console.log("✅ Metadata file written to:", metadataPath);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main()
|
|
71
|
+
.catch((error) => {
|
|
72
|
+
console.error(error);
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
})
|
|
75
|
+
.finally(() => {
|
|
76
|
+
execSync("docker compose -f=../docker/local-node-compose.yml down --remove-orphans --volumes");
|
|
77
|
+
});
|
package/src/index.ts
ADDED