-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: import
NoteFile
in client (#375)
* Update import in cli to use `NoteFile` * Update CHANGELOG * Update cli export to use `NoteFile` * Fix build errors with file tag * Rename `import_input_note` to `import_note` * Implement `From<InputNoteRecord>` for `NoteFile` * Change `import_note` parameter to `NoteFile` * Fix integration tests * Implement `metadata` for `NoteDetails` * Add `get_notes_without_block_header` method to store * Add `ignored` and `imported_tag` to `InputNoteRecord` * Update `import_note` with new functionality * Fix integration tests * Update `ignored` field on note tag add * Update `export` to accept type of note file * Update MMR data for committed notes on sync * Update ignored notes on sync * Fix after rebase * Update tracked note when importing `NoteFile::NoteId` * Remove `NoteFile` conversion from `InputNoteRecord` * Check ephemeral tags when importing * Fix rebase * Fix integration tests * Remove tag from export cli command * Remove `--no-verify` flag from import cli command * Remove `InputNoteRecord` conversion on cli export * Update doc comments for `import_note` * Change suggestions * Add `maybe_await` * Update note when importing `NoteId` even if private * Only update ignored notes if specified in `sync` command * Change suggestions * Update `cli-reference` * Change suggestions * Add tests for ignored notes * Improve doc for `get_notes_without_block_header` * Change suggestions * Fix authentication hash calls for note * Temporarily change `NODE_BRANCH` in Makefile * force CI reset --------- Co-authored-by: igamigo <[email protected]>
- Loading branch information
Showing
26 changed files
with
800 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
use clap::Parser; | ||
use miden_client::{rpc::NodeRpcClient, store::Store, Client}; | ||
use miden_objects::crypto::rand::FeltRng; | ||
use miden_tx::auth::TransactionAuthenticator; | ||
|
||
pub async fn sync_state<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator>( | ||
mut client: Client<N, R, S, A>, | ||
) -> Result<(), String> { | ||
let new_details = client.sync_state().await?; | ||
println!("State synced to block {}", new_details.block_num); | ||
println!("New public notes: {}", new_details.new_notes); | ||
println!("Tracked notes updated: {}", new_details.new_inclusion_proofs); | ||
println!("Tracked notes consumed: {}", new_details.new_nullifiers); | ||
println!("Tracked accounts updated: {}", new_details.updated_onchain_accounts); | ||
println!("Commited transactions: {}", new_details.commited_transactions); | ||
Ok(()) | ||
#[derive(Debug, Parser, Clone)] | ||
#[clap(about = "Sync this client with the latest state of the Miden network.")] | ||
pub struct SyncCmd { | ||
/// If enabled, the ignored notes will also be updated by fetching them directly from the node. | ||
#[clap(short, long)] | ||
update_ignored: bool, | ||
} | ||
|
||
impl SyncCmd { | ||
pub async fn execute<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator>( | ||
&self, | ||
mut client: Client<N, R, S, A>, | ||
) -> Result<(), String> { | ||
let mut new_details = client.sync_state().await?; | ||
if self.update_ignored { | ||
new_details.combine_with(&client.update_ignored_notes().await?); | ||
} | ||
|
||
println!("State synced to block {}", new_details.block_num); | ||
println!("New public notes: {}", new_details.new_notes); | ||
println!("Tracked notes updated: {}", new_details.new_inclusion_proofs); | ||
println!("Tracked notes consumed: {}", new_details.new_nullifiers); | ||
println!("Tracked accounts updated: {}", new_details.updated_onchain_accounts); | ||
println!("Commited transactions: {}", new_details.commited_transactions); | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.