0xMiden / 0xMiden/rust-sdk

`add_account` should track the tag associated with the `Address`

Đang mở
#1,260 8 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Rust
Star
78
Fork
129
Merge trung bình
4 ngày 14 giờ
Pull request đã merge (30 ngày)
52

Mô tả

# `Address`-derived vs. `AccountId`-derived `NoteTag`
The tag derived from an `Address` is (potentially) different than the tag derived from an `AccountId`.
Currently, when we add a new account to the client store, we fall back to `AccountId`-derived tag (via `Account` -> `NoteTagRecord` conversion): https://github.com/0xMiden/miden-client/blob/ba14ca5e765c7c81c45a56a7114b0a156374387b/crates/rust-client/src/account/mod.rs#L155

But, `client.add_account` doesn't provide any option to specify the `Address` as a parameter.
There are two paths:
1. Easy path: inside `add_account`, derive the "default" `Address::AccountIdAddress` by passing in the `AccountId` and `AddressInterface::Unspecified`.
2. New interface: let users add `Address`es, for example by exposing a new `add_address` method, similar to `add_account`. Potentially deprecate `add_account`.
3. Change the interface of `add_account` to accept `AccountIdAddress ` instead of `AccountId`. This is akin to what @PhilippGackstatter suggested in https://github.com/0xMiden/miden-base/issues/1837#issuecomment-3243999913.
4. Other ideas?

These approaches would further require adding a new enum variant `Address` to `NoteTagSource` (or potentially change `NoteTagSource::Account` to `NoteTagSource::AccountIdAddress` if we choose option 3).

---

# Query the store for `NoteTag`s based on the source.

This part could be potentially to be split out into a separate issue, depending on the decisions above^.

It would also be great if we could query the store for tags coming from a specific source.
This would allow us to limit the amount of notes downloaded from the note transport layer to only `Address`-derived tags. So in [Fetch notes section here](https://github.com/0xMiden/miden-client/issues/1229), instead of:
```rust
let note_tags: BTreeSet = self.store.get_unique_note_tags().await?;
// query the gRPC node for these note_tags AND query the transport layer for these tags
```

we could define a new store-querying source interface: `NoteTagStoreSource`:
```rust
pub enum NoteTagStoreSource { // name TBD
Address(AddressSource),
Note(NoteSource),
User(UserSource),
}

pub enum AddressSource {
All,
Exact(Address)
}

// etc. for NoteSource, UserSource
```

And then query as:
```rust
let public_note_tags: BTreeSet = self.store.get_unique_note_tags().await?; // this doesn't change, gets all note tags
// query the gRPC node for public_note_tags

let public_note_tags: BTreeSet = self.store.get_unique_note_tags_from_source(
NoteTagStoreSource::Address(AddressSource:All)
).await?;
// query the transport layer for private note tags
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.