Add an `expected_future_notes` equivalent for output notes
- 主要言語
- Rust
- スター
- 78
- フォーク
- 129
- 平均マージ
- 4日 14時間
- マージ済み PR(30日)
- 52
説明
Originally discussed [here](https://github.com/0xMiden/faucet/pull/262#discussion_r3769719925)
The existing [`TransactionRequestBuilder::expected_future_notes`](https://github.com/0xMiden/rust-sdk/blob/cf66cdbe76f7287b2e59cf44aa64da4fe4b64ebe/crates/rust-client/src/transaction/request/builder.rs#L215) declares notes that a transaction does not create, but that will be created later when the notes it does create are consumed. On submission, these notes are stored as input notes in the client's store. That is correct for the SWAP case in the docs, where the client is the recipient of the future note.
The Miden faucet needs the same mechanism, except that the notes should be stored as output notes.
After 0xMiden/faucet#262 is merged, the faucet minting flow is:
1. a transaction sends a MINT note to the faucet, which is now a network account
2. the ntx builder consumes the MINT note and creates a P2ID note addressed to the recipient
3. the recipient consumes the P2ID note
The faucet has to keep track of the P2ID notes created in step 2, because it must serve them to clients so they can consume them when the notes are private. This is currently done with an in-memory hashmap.
An `expected_future_notes` equivalent for output notes would let the faucet drop the hashmap and keep these notes in the store instead.
**Proposal**
Add a `TransactionRequestBuilder::expected_future_output_notes` setter that records future notes in the output notes table:
```rust
pub fn expected_future_output_notes(self, notes: Vec) -> Self
```
We should also update the functions involved in storing notes so that they handle the expected future **output** notes as well. The main one is [`get_note_updates`](https://github.com/0xMiden/rust-sdk/blob/cf66cdbe76f7287b2e59cf44aa64da4fe4b64ebe/crates/rust-client/src/transaction/mod.rs#L1017). [`TransactionResult`](https://github.com/0xMiden/rust-sdk/blob/cf66cdbe76f7287b2e59cf44aa64da4fe4b64ebe/crates/rust-client/src/transaction/result.rs#L33) would probably need to be updated as well,so that it carries the `output_future_notes`.
コントリビューションガイド
調査の方向性
Start by reading the existing `expected_future_notes` implementation in `crates/rust-client/src/transaction/request/builder.rs`. Then examine `get_note_updates` in `crates/rust-client/src/transaction/mod.rs` and `TransactionResult` in `crates/rust-client/src/transaction/result.rs` to understand how notes are stored. The task is to add a parallel setter for output notes and update the storage logic accordingly. A test should verify that future output notes are correctly stored in the output notes table.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rust
- 領域
- backend-api-design
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 65/100