Skip to content

Commit 2710f3b

Browse files
authored
refactor: Clean up the examples and dev-dependencies (#83)
* refactor: Clean up the examples and dev-dependencies * Mark code-snippets in the docs to be ignored (they miss the dependency)
1 parent 260e5f4 commit 2710f3b

File tree

11 files changed

+77
-4
lines changed

11 files changed

+77
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ For more information [refer to the docs](https://docs.rs/near-lake-framework)
7474

7575
### More examples
7676

77+
We're keeping a set of examples in the [examples](./examples/) folder. The examples there are always up-to-date with the latest version of the NEAR Lake Framework.
78+
79+
And here are some more examples. Despite the fact that they are not up-to-date with the latest version of the NEAR Lake Framework, they still can be used as a reference. Though, we try to keep them updated as well.
80+
7781
- [`near-examples/near-lake-raw-printer`](https://github.com/near-examples/near-lake-raw-printer) simple example of a data printer built on top of NEAR Lake Framework
7882
- [`near-examples/near-lake-accounts-watcher`](https://github.com/near-examples/near-lake-accounts-watcher) another simple example of the indexer built on top of NEAR Lake Framework for a tutorial purpose
7983
- [`near-examples/indexer-tx-watcher-example-lake`](https://github.com/near-examples/indexer-tx-watcher-example-lake) an example of the indexer built on top of NEAR Lake Framework that watches for transactions related to specified account(s)

examples/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# NEAR Lake Framework Examples
2+
3+
This directory contains several example scripts showcasing the usage of the NEAR Lake Framework. Each example demonstrates different aspects and features of the framework. Below is a brief description of each example:
4+
5+
## simple.rs
6+
7+
A simple example of how to use the Lake Framework. This indexer will listen to the NEAR blockchain and print the block height of each block.
8+
9+
```bash
10+
$ cd lake-framework
11+
$ cargo run --example simple
12+
```
13+
14+
## actions.rs
15+
16+
This example shows how to filter actions in a block. It is a more real-life example than the simple example. It is going to follow the NEAR Social contract and print all function calls to it.
17+
18+
```bash
19+
$ cd lake-framework
20+
$ cargo run --example actions
21+
```
22+
23+
## nft_indexer.rs
24+
25+
This is a more complex real-life example of how to use the NEAR Lake Framework.
26+
27+
It is going to follow the network and watch for the Events according to the [Events Format][1]. It will monitor for nft_mint events from the known marketplaces, such as Mintbase and Paras, and index them to print in the terminal.
28+
29+
[1]: https://nomicon.io/Standards/EventsFormat
30+
31+
```bash
32+
$ cd lake-framework
33+
$ cargo run --example nft_indexer
34+
```
35+
36+
## with_context.rs
37+
38+
This example show how to use a context with Lake Framework. It is going to follow the NEAR Social contract and the block height along with a number of calls to the contract.
39+
40+
```bash
41+
$ cd lake-framework
42+
$ cargo run --example with_context
43+
```
44+
45+
## with_context_parent_tx_cache.rs
46+
47+
This example show how to use a context `ParentTransactionCache` with the Lake Framework. It is going to follow the NEAR Social contract and cache the parent Transaction for the Receipts. Thus we would be able to capture the Transaction where the change to the contract state has started.
48+
49+
```bash
50+
$ cd lake-parent-transaction-cache
51+
$ cargo run --example with_context_parent_tx_cache
52+
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

lake-framework/Cargo.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,18 @@ once_cell = "1.8.0"
3737
# used in the doc examples
3838
diesel = { version = "2", features = ["postgres_backend", "postgres"] }
3939

40-
# used by with_context_parent_tx_cache example
41-
near-lake-parent-transaction-cache = { path = "../lake-parent-transaction-cache", version = "0.8.0-beta.2" }
40+
[[example]]
41+
name = "simple"
42+
path = "../examples/simple.rs"
43+
44+
[[example]]
45+
name = "actions"
46+
path = "../examples/actions.rs"
47+
48+
[[example]]
49+
name = "nft_indexer"
50+
path = "../examples/nft_indexer.rs"
51+
52+
[[example]]
53+
name = "with_context"
54+
path = "../examples/with_context.rs"

lake-framework/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async fn handle_block(
7171

7272
It is an old problem that the NEAR Protocol doesn't provide the parent transaction hash in the receipt. This is a problem for the indexer that needs to know the parent transaction hash to build the transaction tree. We've got you covered with the [`lake-parent-transaction-cache`](../lake-parent-transaction-cache/) crate that provides a cache for the parent transaction hashes.
7373

74-
```no_run
74+
```ignore
7575
use near_lake_framework::near_lake_primitives;
7676
use near_lake_primitives::CryptoHash;
7777
use near_lake_parent_transaction_cache::{ParentTransactionCache, ParentTransactionCacheBuilder};

lake-framework/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ pub enum LakeError {
275275
/// #### Advanced Context example
276276
/// In this example we will extend a previous one with the `ParentTransactionCache` context Lake Framework team has created and shared with everybody.
277277
///
278-
/// ```no_run
278+
/// ```ignore
279279
/// use near_lake_framework::LakeContext; // This is a derive macro
280280
/// use near_lake_parent_transaction_cache::{ParentTransactionCache, ParentTransactionCacheBuilder}; // This is a ready-to-use Context from the community that impls LakeContext trait
281281
/// use near_lake_framework::LakeBuilder;

0 commit comments

Comments
 (0)