From f355a8bc1c930860fab7ab46810713a074e72e8b Mon Sep 17 00:00:00 2001 From: Lucas Tortora Date: Wed, 11 Dec 2024 15:02:28 -0300 Subject: [PATCH] fix(devx) Add tabs, remove headers --- .../developer/iota-101/using-events.mdx | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/content/developer/iota-101/using-events.mdx b/docs/content/developer/iota-101/using-events.mdx index bd240f6045e..a10d9d792d1 100644 --- a/docs/content/developer/iota-101/using-events.mdx +++ b/docs/content/developer/iota-101/using-events.mdx @@ -55,9 +55,10 @@ Then, within your function, you can emit an event using the [`emit`](../../refer ## Querying Events -### IOTA RPC + -The IOTA RPC provides a [queryEvents](../../references/iota-api-ref#iotax_queryEvents) method to query on-chain packages and return available events. As an example, the following `curl` command queries the Deepbook package on Mainnet for a specific type of event: + +The IOTA RPC provides a [`queryEvents`](../../references/iota-api-ref#iotax_queryEvents) method to query on-chain packages and return available events. As an example, the following `curl` command queries the Deepbook package on Mainnet for a specific type of event: ```sh curl -X POST https://api.testnet.iota.cafe:443 \ @@ -81,9 +82,11 @@ curl -X POST https://api.testnet.iota.cafe:443 \ }' ``` -The TypeScript SDK provides a wrapper for the `iotax_queryEvents` method: [`client.queryEvents`](../../references/ts-sdk/api/client/classes/IotaClient#queryevents). +The TypeScript SDK provides a wrapper for the `iotax_queryEvents` method: +[`client.queryEvents`](../../references/ts-sdk/api/client/classes/IotaClient#queryevents). -### Rust + + You can use the following as an example on how to query for events using the `query_events` function. You should update the `PACKAGE_ID_CONST` with a package of your choice. @@ -119,8 +122,8 @@ async fn main() -> Result<(), anyhow::Error> { Ok(()) } ``` - -### Query Events with GraphQL + + You can use GraphQL to query events instead of JSON RPC. The following example queries are in the [`iota-graphql-rpc` crate](https://github.com/iotaledger/iota/tree/develop/crates/iota-graphql-rpc/examples/event_connection) in the IOTA repo. @@ -147,6 +150,10 @@ interact with the IOTA GraphQL service. ::: + + + + ## Subscribing to Events This example leverages the IOTA TypeScript SDK to subscribe to events the package with ID `` emits. Each time the event fires, the code displays the response to the console. @@ -154,8 +161,6 @@ This example leverages the IOTA TypeScript SDK to subscribe to events the packag -### Rust - See [Rust SDK](../../references/rust-sdk.mdx). ```rust @@ -180,8 +185,6 @@ async fn main() -> Result<()> { -### TypeScript - To create the event subscription, you can use a basic Node.js app. You need the [IOTA TypeScript SDK](../../references/ts-sdk/typescript/index.mdx), so install the module using `npm install @iota/iota-sdk` at the root of your project. In your TypeScript code, import `JsonRpcProvider` and a connection from the library. ```ts