Skip to content

Commit

Permalink
[docs] Event updates (#19603)
Browse files Browse the repository at this point in the history
## Description 

Updates guides/sui-101/using-events to remove subscriptions
Removes concepts/event because it was always a topic for enhancement and
now the Move Book is a better resource for the info.
Updates links to events.
Adds a redirect from concepts/events to guides/events, which contains a
link to the topic in the move book.
Adds a deprecation note to the coin flip example for subscriptions.

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
ronny-mysten authored Oct 2, 2024
1 parent ff0a47c commit c4bca81
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 304 deletions.
107 changes: 0 additions & 107 deletions docs/content/concepts/events.mdx

This file was deleted.

8 changes: 8 additions & 0 deletions docs/content/guides/developer/advanced/custom-indexer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ The concurrency parameter specifies how many threads the workflow uses. Having a
### Hybrid mode

Specify both a local and remote store as a fallback to ensure constant data flow. The framework always prioritizes locally available checkpoint data over remote data. It's useful when you want to start utilizing your own Full node for data ingestion but need to partially backfill historical data or just have a failover.

```rust
executor.run(
PathBuf::from("./chk".to_string()), // path to a local directory
Expand All @@ -129,9 +130,16 @@ Code for the cargo.toml manifest file for the custom indexer.

Find the following source code in the [Sui repo](https://github.com/mystenlabs/sui/tree/main/examples/custom-indexer/rust).

{@inject: examples/custom-indexer/rust/Cargo.toml}

{@inject: examples/custom-indexer/rust/local_reader.rs}

{@inject: examples/custom-indexer/rust/remote_reader.rs}


## Related links

- [Sui internal example](https://github.com/MystenLabs/sui/tree/main/crates/sui-data-ingestion/src/): Sui data ingestion daemon that runs internal pipelines.
- [Production example](https://github.com/MystenLabs/sui/tree/main/crates/suins-indexer/src): Sui Name Service custom indexer.
- [Using Events](../sui-101/using-events.mdx): Events in Sui enable you to monitor on-chain activity in near-real time when coupled with a custom indexer.

12 changes: 9 additions & 3 deletions docs/content/guides/developer/app-examples/coin-flip.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Source code locations for the smart contracts and frontend:
- **One-time witnesses:** The guide teaches you how to use [one-time witnesses](concepts/sui-move-concepts.mdx#one-time-witness) to ensure only a single instance of the `HouseData` object ever exists.
- **Asserts:** The guide teaches you how to use [asserts](https://move-book.com/move-basics/assert-and-abort.html?highlight=asserts#assert) to abort functions due to certain conditions not being met.
- **Address-owned objects:** The guide teaches you how to use [address-owned objects](concepts/object-ownership/address-owned.mdx) when necessary.
- **Events:** The guide teaches you how to emit [events](concepts/events.mdx) in your contracts, which can be used to track off chain.
- **Events:** The guide teaches you how to emit events in your contracts, which can be used to track on-chain activity. For more information on events, see [Using Events](../sui-101/using-events.mdx) for practical usage of events on Sui or [Events in The Move Book](https://move-book.com/programmability/events.html) to learn about event structure and how to emit them in Move.
- **Storage rebates:** The guide shows you best practices regarding [storage fee rebates](concepts/tokenomics/storage-fund.mdx#incentives).
- **MEV attack protection:** The guide introduces you to [MEV attacks](https://github.com/MystenLabs/satoshi-coin-flip?tab=readme-ov-file#mev-attack-resistant-single-player-satoshi-smart-contract-flow), how to make your contracts MEV-resistant, and the trade-offs between protection and user experience.

Expand Down Expand Up @@ -372,7 +372,7 @@ module satoshi_flip::single_player_satoshi {

This code follows the same pattern as the others. First, you include the respective imports, although this time the imports are not only from the standard library but also include modules created previously in this example. You also create several constants (in upper case), as well as constants used for errors (Pascal case prefixed with `E`).

Lastly in this section, you also create structs for two [events](concepts/events.mdx) to emit. Indexers consume emitted events, which enables you to track these events through API services, or your own indexer. In this case, the events are for when a new game begins (`NewGame`) and for the outcome of a game when it has finished (`Outcome`).
Lastly in this section, you also create structs for two events to emit. Indexers consume emitted events, which enables you to track these events through API services, or your own indexer. In this case, the events are for when a new game begins (`NewGame`) and for the outcome of a game when it has finished (`Outcome`).

Add a struct to the module:

Expand Down Expand Up @@ -1081,7 +1081,13 @@ execCreateGame(
One final step remains: settle the game. There are a couple of ways you can use the UI to settle the game:

1. Create a Settle Game button and pass all the necessary arguments to the `single_player_satoshi::finish_game()` Move call.
1. Settle the game automatically through an events subscription. This example uses this path to teache good practices on events and how to subscribe to them.
1. Settle the game automatically through an events subscription. This example uses this path to teach good practices on events and how to subscribe to them.

:::info

Event subscriptions are deprecated. To learn future-safe methods to work with events, see [Using Events](../sui-101/using-events.mdx).

:::

All of this logic is in `HouseFinishGame.tsx`:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ Functions responsible for various aspects of the escrow's lifecycle emit these e

:::tip Additional resources

- Concepts: [Events](../../../concepts/events)
- Concepts: [Events in The Move Book](https://move-book.com/programmability/events.html)
- Guide: [Using Events](../sui-101/using-events.mdx)

:::

Expand Down
Loading

0 comments on commit c4bca81

Please sign in to comment.