Trait miden_client::rpc::NodeRpcClient

source ·
pub trait NodeRpcClient {
    // Required methods
    async fn submit_proven_transaction(
        &mut self,
        proven_transaction: ProvenTransaction,
    ) -> Result<(), RpcError>;
    async fn get_block_header_by_number(
        &mut self,
        block_num: Option<u32>,
        include_mmr_proof: bool,
    ) -> Result<(BlockHeader, Option<MmrProof>), RpcError>;
    async fn get_notes_by_id(
        &mut self,
        note_ids: &[NoteId],
    ) -> Result<Vec<NoteDetails>, RpcError>;
    async fn sync_state(
        &mut self,
        block_num: u32,
        account_ids: &[AccountId],
        note_tags: &[NoteTag],
        nullifiers_tags: &[u16],
    ) -> Result<StateSyncInfo, RpcError>;
    async fn get_account_update(
        &mut self,
        account_id: AccountId,
    ) -> Result<AccountDetails, RpcError>;
}
Expand description

Defines the interface for communicating with the Miden node.

The implementers are responsible for connecting to the Miden node, handling endpoint requests/responses, and translating responses into domain objects relevant for each of the endpoints.

Required Methods§

source

async fn submit_proven_transaction( &mut self, proven_transaction: ProvenTransaction, ) -> Result<(), RpcError>

Given a Proven Transaction, send it to the node for it to be included in a future block using the /SubmitProvenTransaction rpc endpoint

source

async fn get_block_header_by_number( &mut self, block_num: Option<u32>, include_mmr_proof: bool, ) -> Result<(BlockHeader, Option<MmrProof>), RpcError>

Given a block number, fetches the block header corresponding to that height from the node using the /GetBlockHeaderByNumber endpoint. If include_mmr_proof is set to true and the function returns an Ok, the second value of the return tuple should always be Some(MmrProof)

When None is provided, returns info regarding the latest block

source

async fn get_notes_by_id( &mut self, note_ids: &[NoteId], ) -> Result<Vec<NoteDetails>, RpcError>

Fetches note-related data for a list of NoteId using the /GetNotesById rpc endpoint

For any NoteType::Offchain note, the return data is only the NoteMetadata, whereas for NoteType::Onchain notes, the return data includes all details.

source

async fn sync_state( &mut self, block_num: u32, account_ids: &[AccountId], note_tags: &[NoteTag], nullifiers_tags: &[u16], ) -> Result<StateSyncInfo, RpcError>

Fetches info from the node necessary to perform a state sync using the /SyncState rpc endpoint

  • block_num is the last block number known by the client. The returned StateSyncInfo should contain data starting from the next block, until the first block which contains a note of matching the requested tag, or the chain tip if there are no notes.
  • account_ids is a list of account ids and determines the accounts the client is interested in and should receive account updates of.
  • note_tags is a list of tags used to filter the notes the client is interested in, which serves as a “note group” filter. Notice that you can’t filter by a specific note id
  • nullifiers_tags similar to note_tags, is a list of tags used to filter the nullifiers corresponding to some notes the client is interested in
source

async fn get_account_update( &mut self, account_id: AccountId, ) -> Result<AccountDetails, RpcError>

Fetches the current state of an account from the node using the /GetAccountDetails rpc endpoint

  • account_id is the id of the wanted account.

Object Safety§

This trait is not object safe.

Implementors§