miden_client::rpc

Trait NodeRpcClient

Source
pub trait NodeRpcClient {
    // Required methods
    fn submit_proven_transaction<'life0, 'async_trait>(
        &'life0 mut self,
        proven_transaction: ProvenTransaction,
    ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_block_header_by_number<'life0, 'async_trait>(
        &'life0 mut self,
        block_num: Option<u32>,
        include_mmr_proof: bool,
    ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, Option<MmrProof>), RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_notes_by_id<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        note_ids: &'life1 [NoteId],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<NoteDetails>, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn sync_state<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        block_num: u32,
        account_ids: &'life1 [AccountId],
        note_tags: &'life2 [NoteTag],
        nullifiers_tags: &'life3 [u16],
    ) -> Pin<Box<dyn Future<Output = Result<StateSyncInfo, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn get_account_update<'life0, 'async_trait>(
        &'life0 mut self,
        account_id: AccountId,
    ) -> Pin<Box<dyn Future<Output = Result<AccountDetails, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn sync_notes<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        block_num: u32,
        note_tags: &'life1 [NoteTag],
    ) -> Pin<Box<dyn Future<Output = Result<NoteSyncInfo, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn check_nullifiers_by_prefix<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        prefix: &'life1 [u16],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(Nullifier, u32)>, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_account_proofs<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        account_ids: &'life1 BTreeSet<AccountId>,
        code_commitments: &'life2 [Digest],
        include_headers: bool,
    ) -> Pin<Box<dyn Future<Output = Result<AccountProofs, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided method
    fn get_nullifier_commit_height<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        nullifier: &'life1 Nullifier,
    ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, RpcError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
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

fn submit_proven_transaction<'life0, 'async_trait>( &'life0 mut self, proven_transaction: ProvenTransaction, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

Source

fn get_block_header_by_number<'life0, 'async_trait>( &'life0 mut self, block_num: Option<u32>, include_mmr_proof: bool, ) -> Pin<Box<dyn Future<Output = Result<(BlockHeader, Option<MmrProof>), RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

fn get_notes_by_id<'life0, 'life1, 'async_trait>( &'life0 mut self, note_ids: &'life1 [NoteId], ) -> Pin<Box<dyn Future<Output = Result<Vec<NoteDetails>, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

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

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

Source

fn sync_state<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, block_num: u32, account_ids: &'life1 [AccountId], note_tags: &'life2 [NoteTag], nullifiers_tags: &'life3 [u16], ) -> Pin<Box<dyn Future<Output = Result<StateSyncInfo, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

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

fn get_account_update<'life0, 'async_trait>( &'life0 mut self, account_id: AccountId, ) -> Pin<Box<dyn Future<Output = Result<AccountDetails, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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

  • account_id is the id of the wanted account.
Source

fn sync_notes<'life0, 'life1, 'async_trait>( &'life0 mut self, block_num: u32, note_tags: &'life1 [NoteTag], ) -> Pin<Box<dyn Future<Output = Result<NoteSyncInfo, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source

fn check_nullifiers_by_prefix<'life0, 'life1, 'async_trait>( &'life0 mut self, prefix: &'life1 [u16], ) -> Pin<Box<dyn Future<Output = Result<Vec<(Nullifier, u32)>, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the nullifiers corresponding to a list of prefixes using the /CheckNullifiersByPrefix RPC endpoint.

Source

fn get_account_proofs<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, account_ids: &'life1 BTreeSet<AccountId>, code_commitments: &'life2 [Digest], include_headers: bool, ) -> Pin<Box<dyn Future<Output = Result<AccountProofs, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Fetches the current account state, using th /GetAccountProofs RPC endpoint.

Provided Methods§

Source

fn get_nullifier_commit_height<'life0, 'life1, 'async_trait>( &'life0 mut self, nullifier: &'life1 Nullifier, ) -> Pin<Box<dyn Future<Output = Result<Option<u32>, RpcError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Fetches the commit height where the nullifier was consumed. If the nullifier is not found, then None is returned.

The default implementation of this method uses NodeRpcClient::check_nullifiers_by_prefix.

Implementors§