diff --git a/docs/pages/typed/apis.md b/docs/pages/typed/apis.md new file mode 100644 index 00000000..58822f85 --- /dev/null +++ b/docs/pages/typed/apis.md @@ -0,0 +1,31 @@ +# Runtime APIs + +Runtime APIs (aka Runtime calls in other frameworks) directly query the wasm runtime to get some information. In PAPI they're under `typedApi.apis`. Let's see its interface: + +```ts +type CallOptions = Partial<{ + at: string + signal: AbortSignal +}> +interface RuntimeCall { + (...args: [...Args, options?: CallOptions]): Promise + isCompatible: IsCompatible +} +``` + +They're fairly straight-forward, let's see it with some examples: + +With `callOptions.at` we can control which block to query. It can be a blockHash, `"finalized"` (the default), or `"best"` + +```ts +// there are some APIs that do not take arguments! +const metadata = await typedApi.apis.Metadata.metadata() + +// we can pass as well callOptions +const metadataAtBest = await typedApi.apis.Metadata.metadata({ at: "best" }) + +// this one takes a number as argument +const metadataV15 = await typedApi.apis.Metadata.metadata_at_version(15, { + at: "best", +}) +``` diff --git a/vocs.config.tsx b/vocs.config.tsx index 049517be..e0aab887 100644 --- a/vocs.config.tsx +++ b/vocs.config.tsx @@ -30,6 +30,10 @@ export default defineConfig({ text: "Constants", link: "/typed/constants", }, + { + text: "Runtime APIs", + link: "/typed/apis", + }, { text: "Storage queries", link: "/typed/queries",