@totochain/api-augment 0.0.0-stage → 0.2.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 +70 -2
- package/dist/definitions/definitions.d.ts +1 -0
- package/dist/definitions/definitions.js +2 -0
- package/dist/definitions/totochain/definitions.d.ts +5 -0
- package/dist/definitions/totochain/definitions.js +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -0
- package/dist/interfaces/augment-api-consts.d.ts +861 -0
- package/dist/interfaces/augment-api-consts.js +5 -0
- package/dist/interfaces/augment-api-errors.d.ts +1183 -0
- package/dist/interfaces/augment-api-errors.js +5 -0
- package/dist/interfaces/augment-api-events.d.ts +2033 -0
- package/dist/interfaces/augment-api-events.js +5 -0
- package/dist/interfaces/augment-api-query.d.ts +1375 -0
- package/dist/interfaces/augment-api-query.js +5 -0
- package/dist/interfaces/augment-api-rpc.d.ts +683 -0
- package/dist/interfaces/augment-api-rpc.js +5 -0
- package/dist/interfaces/augment-api-runtime.d.ts +298 -0
- package/dist/interfaces/augment-api-runtime.js +5 -0
- package/dist/interfaces/augment-api-tx.d.ts +2356 -0
- package/dist/interfaces/augment-api-tx.js +5 -0
- package/dist/interfaces/augment-api.d.ts +7 -0
- package/dist/interfaces/augment-api.js +9 -0
- package/dist/interfaces/augment-types.d.ts +1368 -0
- package/dist/interfaces/augment-types.js +5 -0
- package/dist/interfaces/definitions.d.ts +1 -0
- package/dist/interfaces/definitions.js +2 -0
- package/dist/interfaces/index.d.ts +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/lookup.d.ts +3952 -0
- package/dist/interfaces/lookup.js +3954 -0
- package/dist/interfaces/registry.d.ts +279 -0
- package/dist/interfaces/registry.js +5 -0
- package/dist/interfaces/totochain/definitions.d.ts +5 -0
- package/dist/interfaces/totochain/definitions.js +7 -0
- package/dist/interfaces/types-lookup.d.ts +4085 -0
- package/dist/interfaces/types-lookup.js +5 -0
- package/dist/interfaces/types.d.ts +1 -0
- package/dist/interfaces/types.js +3 -0
- package/package.json +69 -4
- package/src/definitions/definitions.ts +2 -0
- package/src/definitions/totochain/definitions.ts +7 -0
- package/src/index.ts +15 -0
- package/src/interfaces/augment-api-consts.ts +869 -0
- package/src/interfaces/augment-api-errors.ts +1191 -0
- package/src/interfaces/augment-api-events.ts +1307 -0
- package/src/interfaces/augment-api-query.ts +1383 -0
- package/src/interfaces/augment-api-rpc.ts +621 -0
- package/src/interfaces/augment-api-runtime.ts +264 -0
- package/src/interfaces/augment-api-tx.ts +2175 -0
- package/src/interfaces/augment-api.ts +10 -0
- package/src/interfaces/augment-types.ts +1375 -0
- package/src/interfaces/definitions.ts +2 -0
- package/src/interfaces/index.ts +4 -0
- package/src/interfaces/lookup.ts +3956 -0
- package/src/interfaces/registry.ts +286 -0
- package/src/interfaces/totochain/definitions.ts +7 -0
- package/src/interfaces/types-lookup.ts +4352 -0
- package/src/interfaces/types.ts +4 -0
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @totochain/api-augment
|
|
2
2
|
|
|
3
|
-
|
|
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(subject, ctypeHash); // 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,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
|
+
};
|
package/dist/index.d.ts
ADDED
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';
|