@totochain/api-augment 0.0.0-stage → 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.
Files changed (59) hide show
  1. package/README.md +70 -2
  2. package/dist/definitions/definitions.d.ts +1 -0
  3. package/dist/definitions/definitions.js +2 -0
  4. package/dist/definitions/totochain/definitions.d.ts +5 -0
  5. package/dist/definitions/totochain/definitions.js +7 -0
  6. package/dist/index.d.ts +4 -0
  7. package/dist/index.js +12 -0
  8. package/dist/interfaces/augment-api-consts.d.ts +819 -0
  9. package/dist/interfaces/augment-api-consts.js +5 -0
  10. package/dist/interfaces/augment-api-errors.d.ts +1156 -0
  11. package/dist/interfaces/augment-api-errors.js +5 -0
  12. package/dist/interfaces/augment-api-events.d.ts +1999 -0
  13. package/dist/interfaces/augment-api-events.js +5 -0
  14. package/dist/interfaces/augment-api-query.d.ts +1334 -0
  15. package/dist/interfaces/augment-api-query.js +5 -0
  16. package/dist/interfaces/augment-api-rpc.d.ts +683 -0
  17. package/dist/interfaces/augment-api-rpc.js +5 -0
  18. package/dist/interfaces/augment-api-runtime.d.ts +298 -0
  19. package/dist/interfaces/augment-api-runtime.js +5 -0
  20. package/dist/interfaces/augment-api-tx.d.ts +2333 -0
  21. package/dist/interfaces/augment-api-tx.js +5 -0
  22. package/dist/interfaces/augment-api.d.ts +7 -0
  23. package/dist/interfaces/augment-api.js +9 -0
  24. package/dist/interfaces/augment-types.d.ts +1368 -0
  25. package/dist/interfaces/augment-types.js +5 -0
  26. package/dist/interfaces/definitions.d.ts +1 -0
  27. package/dist/interfaces/definitions.js +2 -0
  28. package/dist/interfaces/index.d.ts +1 -0
  29. package/dist/interfaces/index.js +3 -0
  30. package/dist/interfaces/lookup.d.ts +3899 -0
  31. package/dist/interfaces/lookup.js +3901 -0
  32. package/dist/interfaces/registry.d.ts +278 -0
  33. package/dist/interfaces/registry.js +5 -0
  34. package/dist/interfaces/totochain/definitions.d.ts +5 -0
  35. package/dist/interfaces/totochain/definitions.js +7 -0
  36. package/dist/interfaces/types-lookup.d.ts +4026 -0
  37. package/dist/interfaces/types-lookup.js +5 -0
  38. package/dist/interfaces/types.d.ts +1 -0
  39. package/dist/interfaces/types.js +3 -0
  40. package/package.json +69 -4
  41. package/src/definitions/definitions.ts +2 -0
  42. package/src/definitions/totochain/definitions.ts +7 -0
  43. package/src/index.ts +15 -0
  44. package/src/interfaces/augment-api-consts.ts +827 -0
  45. package/src/interfaces/augment-api-errors.ts +1164 -0
  46. package/src/interfaces/augment-api-events.ts +1294 -0
  47. package/src/interfaces/augment-api-query.ts +1342 -0
  48. package/src/interfaces/augment-api-rpc.ts +621 -0
  49. package/src/interfaces/augment-api-runtime.ts +264 -0
  50. package/src/interfaces/augment-api-tx.ts +2152 -0
  51. package/src/interfaces/augment-api.ts +10 -0
  52. package/src/interfaces/augment-types.ts +1375 -0
  53. package/src/interfaces/definitions.ts +2 -0
  54. package/src/interfaces/index.ts +4 -0
  55. package/src/interfaces/lookup.ts +3903 -0
  56. package/src/interfaces/registry.ts +285 -0
  57. package/src/interfaces/totochain/definitions.ts +7 -0
  58. package/src/interfaces/types-lookup.ts +4292 -0
  59. package/src/interfaces/types.ts +4 -0
package/README.md CHANGED
@@ -1,3 +1,71 @@
1
- # Temporary Holding Version
1
+ # @totochain/api-augment
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Polkadot API type augmentation for Totochain, generated from the chain's own metadata.
4
+
5
+ Importing this package once, anywhere in your program, types every `@polkadot/api`
6
+ call against Totochain's runtime. It declares types only — nothing is added at runtime.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @totochain/api-augment
12
+ ```
13
+
14
+ `@polkadot/api` is a peer dependency; version 16 or later.
15
+
16
+ ## Use
17
+
18
+ ```ts
19
+ import '@totochain/api-augment';
20
+ ```
21
+
22
+ Without it, `api.tx.ctype.add` accepts any arguments and returns `AnyTuple`. With it:
23
+
24
+ ```ts
25
+ api.tx.ctype.add(ctypeHash); // ctype: string | Uint8Array | Bytes
26
+ api.query.attestation.attestations(h); // typed storage result
27
+ api.consts.potential.minPotential; // typed constant
28
+ ```
29
+
30
+ Unknown pallets and misspelled calls become compile errors rather than runtime failures.
31
+
32
+ ## With the client
33
+
34
+ `@totochain/client` carries the RPC definitions and the types bundle that
35
+ `ApiPromise.create` needs at runtime. The two are complementary — the bundle teaches
36
+ the API about the chain, this package teaches TypeScript about it:
37
+
38
+ ```ts
39
+ import '@totochain/api-augment';
40
+ import { typesBundle } from '@totochain/client/rpc';
41
+
42
+ const api = await ApiPromise.create({ provider, typesBundle });
43
+ ```
44
+
45
+ ## Regenerating
46
+
47
+ The interfaces are generated, not written.
48
+
49
+ ```bash
50
+ npm run generate # pulls and runs the published master image
51
+ npm run generate -- ws://host:9944 # or a node you are already running
52
+ ```
53
+
54
+ With no endpoint the script starts `totochain/master:latest` in Docker, generates
55
+ against it and removes the container afterwards, so the types match the chain's master
56
+ rather than whatever happens to be listening locally.
57
+
58
+ This overwrites `src/interfaces` from `src/definitions` and the node's metadata,
59
+ then typechecks the result. Change the chain, not the output.
60
+
61
+ Parameter names travel from the pallet through the metadata into these types, so a
62
+ parameter named after a TypeScript reserved word produces a file that cannot be
63
+ parsed. Rename it in the pallet.
64
+
65
+ ## Contributing
66
+
67
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for the build, test and release commands.
68
+
69
+ ## Licence
70
+
71
+ Apache-2.0
@@ -0,0 +1 @@
1
+ export { default as totochain } from './totochain/definitions.js';
@@ -0,0 +1,2 @@
1
+ // Namespace index for @polkadot/typegen's --input directory.
2
+ export { default as totochain } from './totochain/definitions.js';
@@ -0,0 +1,5 @@
1
+ declare const _default: {
2
+ rpc: {};
3
+ types: {};
4
+ };
5
+ export default _default;
@@ -0,0 +1,7 @@
1
+ // Totochain's RPC definitions and types bundle live in @totochain/client, which
2
+ // is the single source for both. This namespace exists only to anchor typegen's
3
+ // output; the generated interfaces come from the chain's metadata alone.
4
+ export default {
5
+ rpc: {},
6
+ types: {},
7
+ };
@@ -0,0 +1,4 @@
1
+ import './interfaces/types-lookup.js';
2
+ import './interfaces/augment-api.js';
3
+ import './interfaces/augment-types.js';
4
+ export type * from './interfaces/types.js';
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ // Importing this module augments the `@polkadot/api` interfaces in place: once it is
2
+ // loaded, `api.tx`, `api.query`, `api.consts`, `api.errors`, `api.events` and the
3
+ // runtime calls are typed against Totochain's own metadata rather than the generic
4
+ // `AnyTuple` fallbacks. It declares types only and emits no runtime values.
5
+ //
6
+ // import '@totochain/api-augment';
7
+ //
8
+ // The RPC definitions and the types bundle that `ApiPromise.create` needs at runtime
9
+ // live in `@totochain/client`, which is the single source for both.
10
+ import './interfaces/types-lookup.js';
11
+ import './interfaces/augment-api.js';
12
+ import './interfaces/augment-types.js';