Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* Incremented the limits for various RPC calls to accommodate larger data sets ([#1621](https://github.com/0xMiden/miden-client/pull/1621)).
* [BREAKING] Introduced named storage slots, changed `FilesystemKeystore` to not be generic over RNG ([#1626](https://github.com/0xMiden/miden-client/pull/1626)).
* Added `submit_new_transaction_with_prover` to the Rust client and `submitNewTransactionWithProver` to the WebClient([#1622](https://github.com/0xMiden/miden-client/pull/1622)).
* Added WebClient bindings and RPC helpers for additional account, note, and validation workflows ([#1638](https://github.com/0xMiden/miden-client/pull/1638)).
* [BREAKING] Modified JS binding for `AccountComponent::compile` which now takes an `AccountComponentCode` built with the newly added binding `CodeBuilder::compile_account_component_code` ([#1627](https://github.com/0xMiden/miden-client/pull/1627)).

## 0.12.5 (2025-12-01)
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions crates/web-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ testing = ["miden-client/testing"]

[dependencies]
# Workspace dependencies
idxdb-store = { package = "miden-idxdb-store", path = "../idxdb-store" }
miden-client = { default-features = false, features = ["testing", "tonic"], path = "../rust-client" }
idxdb-store = { package = "miden-idxdb-store", path = "../idxdb-store" }
miden-client = { default-features = false, features = ["testing", "tonic"], path = "../rust-client" }
miden-protocol = { workspace = true }

# External dependencies
console_error_panic_hook = { version = "0.1.7" }
Expand Down
6 changes: 6 additions & 0 deletions crates/web-client/js/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export {
AuthSecretKey,
BasicFungibleFaucetComponent,
BlockHeader,
CommittedNote,
ConsumableNoteRecord,
Endpoint,
ExecutedTransaction,
Felt,
FeltArray,
FetchedAccount,
FetchedNote,
FlattenedU8Vec,
ForeignAccount,
Expand Down Expand Up @@ -86,12 +88,15 @@ export {
NoteRecipient,
NoteRecipientArray,
NoteScript,
NoteSyncInfo,
NoteTag,
NoteType,
OutputNote,
OutputNoteArray,
OutputNotes,
OutputNotesArray,
OutputNoteRecord,
OutputNoteState,
Package,
PartialNote,
Program,
Expand All @@ -108,6 +113,7 @@ export {
SigningInputs,
SigningInputsType,
SlotAndKeys,
SparseMerklePath,
StorageMap,
StorageSlot,
StorageSlotArray,
Expand Down
19 changes: 19 additions & 0 deletions crates/web-client/src/models/account_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use miden_client::account::AccountFile as NativeAccountFile;
use wasm_bindgen::prelude::*;
use wasm_bindgen_futures::js_sys::Uint8Array;

use crate::models::account::Account;
use crate::models::account_id::AccountId;
use crate::utils::{deserialize_from_uint8array, serialize_to_uint8array};

#[derive(Debug, Clone)]
Expand All @@ -10,6 +12,23 @@ pub struct AccountFile(NativeAccountFile);

#[wasm_bindgen]
impl AccountFile {
/// Returns the account ID.
#[wasm_bindgen(js_name = "accountId")]
pub fn account_id(&self) -> AccountId {
self.0.account.id().into()
}

/// Returns the account data.
pub fn account(&self) -> Account {
self.0.account.clone().into()
}

/// Returns the number of auth secret keys included.
#[wasm_bindgen(js_name = "authSecretKeyCount")]
pub fn auth_secret_key_count(&self) -> usize {
self.0.auth_secret_keys.len()
}

/// Serializes the `AccountFile` into a byte array
pub fn serialize(&self) -> Uint8Array {
serialize_to_uint8array(&self.0)
Expand Down
5 changes: 1 addition & 4 deletions crates/web-client/src/models/code_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ use crate::models::transaction_script::TransactionScript;
#[derive(Clone)]
#[wasm_bindgen(inspectable)]
pub struct CodeBuilder {
// We need both a builder and an assembler since we want the capability of linking libraries,
// and compiling scripts. This can be done by the NativeCodeBuilder alone, but we still
// need an assembler to compile an AccountComponent. After miden-base issue #1756 is complete
// we will be able to remove the Assembler and only use the NativeCodeBuilder.
// Keep the builder and derive an assembler when compiling account component code.
builder: NativeCodeBuilder,
}

Expand Down
52 changes: 52 additions & 0 deletions crates/web-client/src/models/committed_note.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use miden_client::rpc::domain::note::CommittedNote as NativeCommittedNote;
use wasm_bindgen::prelude::*;

use super::note_id::NoteId;
use super::note_metadata::NoteMetadata;
use super::sparse_merkle_path::SparseMerklePath;

/// Represents a note committed on chain, as returned by `syncNotes`.
#[derive(Clone)]
#[wasm_bindgen]
pub struct CommittedNote(NativeCommittedNote);

#[wasm_bindgen]
impl CommittedNote {
/// Returns the note ID.
#[wasm_bindgen(js_name = "noteId")]
pub fn note_id(&self) -> NoteId {
(*self.0.note_id()).into()
}

/// Returns the note index in the block's note tree.
#[wasm_bindgen(js_name = "noteIndex")]
pub fn note_index(&self) -> u16 {
self.0.note_index()
}

/// Returns the inclusion path for the note.
#[wasm_bindgen(js_name = "inclusionPath")]
pub fn inclusion_path(&self) -> SparseMerklePath {
self.0.inclusion_path().into()
}

/// Returns the note metadata.
pub fn metadata(&self) -> NoteMetadata {
self.0.metadata().into()
}
}

// CONVERSIONS
// ================================================================================================

impl From<NativeCommittedNote> for CommittedNote {
fn from(native_note: NativeCommittedNote) -> Self {
CommittedNote(native_note)
}
}

impl From<&NativeCommittedNote> for CommittedNote {
fn from(native_note: &NativeCommittedNote) -> Self {
CommittedNote(native_note.clone())
}
}
85 changes: 85 additions & 0 deletions crates/web-client/src/models/fetched_account.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
use miden_client::rpc::domain::account::FetchedAccount as NativeFetchedAccount;
use wasm_bindgen::prelude::*;

use super::account::Account;
use super::account_id::AccountId;
use super::word::Word;

/// Account details returned by the node.
#[derive(Clone)]
#[wasm_bindgen]
pub struct FetchedAccount {
account_id: AccountId,
commitment: Word,
last_block_num: u32,
account: Option<Account>,
}

#[wasm_bindgen]
impl FetchedAccount {
/// Returns the account ID.
#[wasm_bindgen(js_name = "accountId")]
pub fn account_id(&self) -> AccountId {
self.account_id
}

/// Returns the account commitment reported by the node.
pub fn commitment(&self) -> Word {
self.commitment.clone()
}

/// Returns the last block height where the account was updated.
#[wasm_bindgen(js_name = "lastBlockNum")]
pub fn last_block_num(&self) -> u32 {
self.last_block_num
}

/// Returns the full account data when the account is public.
pub fn account(&self) -> Option<Account> {
self.account.clone()
}

/// Returns true when the account is public.
#[wasm_bindgen(js_name = "isPublic")]
pub fn is_public(&self) -> bool {
self.account_id.is_public()
}

/// Returns true when the account is private.
#[wasm_bindgen(js_name = "isPrivate")]
pub fn is_private(&self) -> bool {
self.account_id.is_private()
}

/// Returns true when the account is a network account.
#[wasm_bindgen(js_name = "isNetwork")]
pub fn is_network(&self) -> bool {
self.account_id.is_network()
}
}

// CONVERSIONS
// ================================================================================================

impl From<NativeFetchedAccount> for FetchedAccount {
fn from(native_account: NativeFetchedAccount) -> Self {
match native_account {
NativeFetchedAccount::Private(account_id, summary) => FetchedAccount {
account_id: account_id.into(),
commitment: summary.commitment.into(),
last_block_num: summary.last_block_num,
account: None,
},
NativeFetchedAccount::Public(account, summary) => {
let account_id = account.id().into();
let account = (*account).into();
FetchedAccount {
account_id,
commitment: summary.commitment.into(),
last_block_num: summary.last_block_num,
account: Some(account),
}
},
}
}
}
6 changes: 6 additions & 0 deletions crates/web-client/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ pub mod auth_secret_key;
pub mod basic_fungible_faucet_component;
pub mod block_header;
pub mod code_builder;
pub mod committed_note;
pub mod consumable_note_record;
pub mod endpoint;
pub mod executed_transaction;
pub mod felt;
pub mod fetched_account;
pub mod foreign_account;
pub mod fungible_asset;
pub mod input_note;
Expand All @@ -77,9 +79,12 @@ pub mod note_location;
pub mod note_metadata;
pub mod note_recipient;
pub mod note_script;
pub mod note_sync_info;
pub mod note_tag;
pub mod note_type;
pub mod output_note;
pub mod output_note_record;
pub mod output_note_state;
pub mod output_notes;
pub mod package;
pub mod partial_note;
Expand All @@ -90,6 +95,7 @@ pub mod public_key;
pub mod rpo256;
pub mod signature;
pub mod signing_inputs;
pub mod sparse_merkle_path;
pub mod storage_map;
pub mod storage_slot;
pub mod sync_summary;
Expand Down
11 changes: 10 additions & 1 deletion crates/web-client/src/models/note.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use miden_client::Felt as NativeFelt;
use miden_client::asset::Asset as NativeAsset;
use miden_client::block::BlockNumber as NativeBlockNumber;
use miden_client::crypto::RpoRandomCoin;
Expand All @@ -8,6 +7,7 @@ use miden_client::note::{
create_p2id_note,
create_p2ide_note,
};
use miden_client::{Felt as NativeFelt, Word as NativeWord};
use rand::rngs::StdRng;
use rand::{Rng, SeedableRng};
use wasm_bindgen::prelude::*;
Expand Down Expand Up @@ -86,6 +86,15 @@ impl Note {
self.0.script().clone().into()
}

/// Returns the note nullifier as a word.
pub fn nullifier(&self) -> Word {
let nullifier = self.0.nullifier();
let elements: [miden_client::Felt; 4] =
nullifier.as_elements().try_into().expect("nullifier has 4 elements");
let native_word: NativeWord = NativeWord::from(&elements);
native_word.into()
}

/// Builds a standard P2ID note that targets the specified account.
#[wasm_bindgen(js_name = "createP2IDNote")]
pub fn create_p2id_note(
Expand Down
11 changes: 11 additions & 0 deletions crates/web-client/src/models/note_details.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use miden_client::Word as NativeWord;
use miden_client::note::NoteDetails as NativeNoteDetails;
use wasm_bindgen::prelude::*;

use super::note_assets::NoteAssets;
use super::note_id::NoteId;
use super::note_recipient::NoteRecipient;
use super::word::Word;

/// Details of a note consisting of assets, script, inputs, and a serial number.
///
Expand Down Expand Up @@ -34,6 +36,15 @@ impl NoteDetails {
pub fn recipient(&self) -> NoteRecipient {
self.0.recipient().into()
}

/// Returns the note nullifier as a word.
pub fn nullifier(&self) -> Word {
let nullifier = self.0.nullifier();
let elements: [miden_client::Felt; 4] =
nullifier.as_elements().try_into().expect("nullifier has 4 elements");
let native_word: NativeWord = NativeWord::from(&elements);
native_word.into()
}
}

impl From<NoteDetails> for NativeNoteDetails {
Expand Down
Loading