Skip to content

Commit 3d3e663

Browse files
Merge branch 'next' into fabrizioorsi-multicall-cli
2 parents f644498 + 06536f0 commit 3d3e663

26 files changed

+510
-31
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
* [BREAKING] Updated `toBech32` AccountID method: it now expects a parameter to specify the NetworkID ([#1043](https://github.com/0xMiden/miden-client/pull/1043)).
99
* Introduced enums instead of booleans for public APIs ([#1042](https://github.com/0xMiden/miden-client/pull/1042)).
1010
* [BREAKING] Made authenticator optional for `ClientBuilder` and `Client::new`. The authenticator parameter is now optional, allowing clients to be created without authentication capabilities ([#1056](https://github.com/0xMiden/miden-client/pull/1056)).
11-
* [BREAKING] Updated `applyStateSync` to receive a single object and then write the changes in a single transaction ([#1050](https://github.com/0xMiden/miden-client/pull/1050))
11+
* [BREAKING] Updated `applyStateSync` to receive a single object and then write the changes in a single transaction ([#1050](https://github.com/0xMiden/miden-client/pull/1050)).
1212
* [BREAKING] Refactored `OnNoteReceived` callback to return enum with update action ([#1051](https://github.com/0xMiden/miden-client/pull/1051)).
1313
* [BREAKING] Changed `OnNoteReceived` from closure to trait object (#1080)
1414
* `NoteScript` now has a `toString` method that prints its own MAST source [(#1082)](https://github.com/0xMiden/miden-client/pull/1082).
15-
15+
* Added a `NoteScript` getter for the Web Client `Note` model ([#1135](https://github.com/0xMiden/miden-client/pull/1135/)).
16+
* [BREAKING] Changed `OnNoteReceived` from closure to trait object ([#1080](https://github.com/0xMiden/miden-client/pull/1080)).
1617

1718
### Features
1819

@@ -22,7 +23,10 @@
2223
* Added ability to convert `Word` to `U64` array and `Felt` array in Web Client (([#1041](https://github.com/0xMiden/miden-client/pull/1041)).
2324
* Added `TokenSymbol` type to Web Client ([#1046](https://github.com/0xMiden/miden-client/pull/1046)).
2425
* [BREAKING] Added genesis commitment header to `TonicRpcClient` requests (#1045).
25-
* Made CLI `multicall` aware (#TBD)
26+
* Added authentication arguments support to `TransactionRequest` ([#1121](https://github.com/0xMiden/miden-client/pull/1121)).
27+
* Added bindings for retrieving storage `AccountDelta` in the web client ([#1098](https://github.com/0xMiden/miden-client/pull/1098)).
28+
* Added `multicall` suuport for the CLI (#TBD)
29+
2630

2731
## 0.10.1 (2025-07-26)
2832

crates/rust-client/src/transaction/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -980,10 +980,10 @@ where
980980
account_id: AccountId,
981981
transaction_request: &TransactionRequest,
982982
) -> Result<(), ClientError> {
983-
let current_chain_tip =
984-
self.rpc_api.get_block_header_by_number(None, false).await?.0.block_num();
985-
986983
if let Some(max_block_number_delta) = self.max_block_number_delta {
984+
let current_chain_tip =
985+
self.rpc_api.get_block_header_by_number(None, false).await?.0.block_num();
986+
987987
if current_chain_tip > self.store.get_sync_height().await? + max_block_number_delta {
988988
return Err(ClientError::RecencyConditionError(
989989
"The client is too far behind the chain tip to execute the transaction"

crates/rust-client/src/transaction/request/builder.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ pub struct TransactionRequestBuilder {
6868
/// execution. If the advice map is extended with some user defined entries, this script
6969
/// argument could be used as a key to access the corresponding value.
7070
script_arg: Option<Word>,
71+
/// Optional [`Word`] that will be pushed to the stack for the authentication procedure
72+
/// during transaction execution.
73+
auth_arg: Option<Word>,
7174
}
7275

7376
impl TransactionRequestBuilder {
@@ -89,6 +92,7 @@ impl TransactionRequestBuilder {
8992
foreign_accounts: BTreeMap::default(),
9093
ignore_invalid_input_notes: false,
9194
script_arg: None,
95+
auth_arg: None,
9296
}
9397
}
9498

@@ -240,6 +244,14 @@ impl TransactionRequestBuilder {
240244
self
241245
}
242246

247+
/// Sets an optional [`Word`] that will be pushed to the stack for the authentication
248+
/// procedure during transaction execution.
249+
#[must_use]
250+
pub fn auth_arg(mut self, auth_arg: Word) -> Self {
251+
self.auth_arg = Some(auth_arg);
252+
self
253+
}
254+
243255
// STANDARDIZED REQUESTS
244256
// --------------------------------------------------------------------------------------------
245257

@@ -412,6 +424,7 @@ impl TransactionRequestBuilder {
412424
expiration_delta: self.expiration_delta,
413425
ignore_invalid_input_notes: self.ignore_invalid_input_notes,
414426
script_arg: self.script_arg,
427+
auth_arg: self.auth_arg,
415428
})
416429
}
417430
}

crates/rust-client/src/transaction/request/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ pub struct TransactionRequest {
9090
/// Optional [`Word`] that will be pushed to the operand stack before the transaction script
9191
/// execution.
9292
script_arg: Option<Word>,
93+
/// Optional [`Word`] that will be pushed to the stack for the authentication procedure
94+
/// during transaction execution.
95+
auth_arg: Option<Word>,
9396
}
9497

9598
impl TransactionRequest {
@@ -198,6 +201,16 @@ impl TransactionRequest {
198201
self.ignore_invalid_input_notes
199202
}
200203

204+
/// Returns the script argument for the transaction request.
205+
pub fn script_arg(&self) -> &Option<Word> {
206+
&self.script_arg
207+
}
208+
209+
/// Returns the auth argument for the transaction request.
210+
pub fn auth_arg(&self) -> &Option<Word> {
211+
&self.auth_arg
212+
}
213+
201214
/// Builds the [`InputNotes`] needed for the transaction execution. Full valid notes for the
202215
/// specified authenticated notes need to be provided, otherwise an error will be returned.
203216
/// The transaction input notes will include both authenticated and unauthenticated notes in the
@@ -284,6 +297,10 @@ impl TransactionRequest {
284297
tx_args.with_tx_script(tx_script)
285298
};
286299

300+
if let Some(auth_argument) = self.auth_arg {
301+
tx_args = tx_args.with_auth_args(auth_argument);
302+
}
303+
287304
tx_args
288305
.extend_output_note_recipients(expected_output_recipients.into_values().map(Box::new));
289306
tx_args.extend_merkle_store(merkle_store.inner_nodes());
@@ -338,6 +355,7 @@ impl Serializable for TransactionRequest {
338355
self.expiration_delta.write_into(target);
339356
target.write_u8(u8::from(self.ignore_invalid_input_notes));
340357
self.script_arg.write_into(target);
358+
self.auth_arg.write_into(target);
341359
}
342360
}
343361

@@ -374,6 +392,7 @@ impl Deserializable for TransactionRequest {
374392
let expiration_delta = Option::<u16>::read_from(source)?;
375393
let ignore_invalid_input_notes = source.read_u8()? == 1;
376394
let script_arg = Option::<Word>::read_from(source)?;
395+
let auth_arg = Option::<Word>::read_from(source)?;
377396

378397
Ok(TransactionRequest {
379398
unauthenticated_input_notes,
@@ -387,6 +406,7 @@ impl Deserializable for TransactionRequest {
387406
expiration_delta,
388407
ignore_invalid_input_notes,
389408
script_arg,
409+
auth_arg,
390410
})
391411
}
392412
}
@@ -537,6 +557,8 @@ mod tests {
537557
OutputNote::Full(notes.pop().unwrap()),
538558
OutputNote::Partial(notes.pop().unwrap().into()),
539559
])
560+
.script_arg(rng.draw_word())
561+
.auth_arg(rng.draw_word())
540562
.build()
541563
.unwrap();
542564

crates/web-client/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/web-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@demox-labs/miden-sdk",
3-
"version": "0.11.0-next.8",
3+
"version": "0.11.0-next.11",
44
"description": "Miden Wasm SDK",
55
"collaborators": [
66
"Miden",

crates/web-client/src/models/account_delta.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use miden_objects::account::AccountDelta as NativeAccountDelta;
22
use wasm_bindgen::prelude::*;
33

44
use super::{
5-
// account_storage_delta::AccountStorageDelta,
6-
// account_vault_delta::AccountVaultDelta,
7-
felt::Felt,
5+
account_storage_delta::AccountStorageDelta, account_vault_delta::AccountVaultDelta, felt::Felt,
86
};
97

108
#[derive(Clone)]
@@ -18,15 +16,13 @@ impl AccountDelta {
1816
self.0.is_empty()
1917
}
2018

21-
// TODO: storage
22-
// pub fn storage(&self) -> AccountStorageDelta {
23-
// self.0.storage().into()
24-
// }
19+
pub fn storage(&self) -> AccountStorageDelta {
20+
self.0.storage().into()
21+
}
2522

26-
// TODO: vault
27-
// pub fn vault(&self) -> AccountVaultDelta {
28-
// self.0.vault().into()
29-
// }
23+
pub fn vault(&self) -> AccountVaultDelta {
24+
self.0.vault().into()
25+
}
3026

3127
#[wasm_bindgen(js_name = "nonceDelta")]
3228
pub fn nonce_delta(&self) -> Felt {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use miden_objects::account::AccountStorageDelta as NativeAccountStorageDelta;
2+
use wasm_bindgen::prelude::*;
3+
4+
use super::word::Word;
5+
6+
#[derive(Clone)]
7+
#[wasm_bindgen]
8+
pub struct AccountStorageDelta(NativeAccountStorageDelta);
9+
10+
#[wasm_bindgen]
11+
impl AccountStorageDelta {
12+
#[wasm_bindgen(js_name = "isEmpty")]
13+
pub fn is_empty(&self) -> bool {
14+
self.0.is_empty()
15+
}
16+
17+
pub fn values(&self) -> Vec<Word> {
18+
self.0.values().values().copied().map(Into::into).collect()
19+
}
20+
}
21+
22+
// CONVERSIONS
23+
// ================================================================================================
24+
25+
impl From<NativeAccountStorageDelta> for AccountStorageDelta {
26+
fn from(native_account_storage_delta: NativeAccountStorageDelta) -> Self {
27+
AccountStorageDelta(native_account_storage_delta)
28+
}
29+
}
30+
31+
impl From<&NativeAccountStorageDelta> for AccountStorageDelta {
32+
fn from(native_account_storage_delta: &NativeAccountStorageDelta) -> Self {
33+
AccountStorageDelta(native_account_storage_delta.clone())
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use miden_objects::account::AccountVaultDelta as NativeAccountVaultDelta;
2+
use wasm_bindgen::prelude::*;
3+
4+
use super::fungible_asset_delta::FungibleAssetDelta;
5+
6+
#[derive(Clone)]
7+
#[wasm_bindgen]
8+
pub struct AccountVaultDelta(NativeAccountVaultDelta);
9+
10+
#[wasm_bindgen]
11+
impl AccountVaultDelta {
12+
#[wasm_bindgen(js_name = "isEmpty")]
13+
pub fn is_empty(&self) -> bool {
14+
self.0.is_empty()
15+
}
16+
17+
pub fn fungible(&self) -> FungibleAssetDelta {
18+
self.0.fungible().into()
19+
}
20+
}
21+
22+
// CONVERSIONS
23+
// ================================================================================================
24+
25+
impl From<NativeAccountVaultDelta> for AccountVaultDelta {
26+
fn from(native_account_vault_delta: NativeAccountVaultDelta) -> Self {
27+
AccountVaultDelta(native_account_vault_delta)
28+
}
29+
}
30+
31+
impl From<&NativeAccountVaultDelta> for AccountVaultDelta {
32+
fn from(native_account_vault_delta: &NativeAccountVaultDelta) -> Self {
33+
AccountVaultDelta(native_account_vault_delta.clone())
34+
}
35+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
use miden_objects::account::{
2+
AccountId as NativeAccountId, FungibleAssetDelta as NativeFungibleAssetDelta,
3+
};
4+
use wasm_bindgen::prelude::*;
5+
6+
use super::account_id::AccountId;
7+
8+
#[derive(Clone)]
9+
#[wasm_bindgen]
10+
pub struct FungibleAssetDeltaItem {
11+
faucet_id: AccountId,
12+
amount: i64,
13+
}
14+
15+
#[wasm_bindgen]
16+
impl FungibleAssetDeltaItem {
17+
#[wasm_bindgen(getter, js_name = "faucetId")]
18+
pub fn faucet_id(&self) -> AccountId {
19+
self.faucet_id
20+
}
21+
22+
#[wasm_bindgen(getter)]
23+
pub fn amount(&self) -> i64 {
24+
self.amount
25+
}
26+
}
27+
28+
impl From<(&NativeAccountId, &i64)> for FungibleAssetDeltaItem {
29+
fn from(native_fungible_asset_delta_item: (&NativeAccountId, &i64)) -> Self {
30+
Self {
31+
faucet_id: (*native_fungible_asset_delta_item.0).into(),
32+
amount: *native_fungible_asset_delta_item.1,
33+
}
34+
}
35+
}
36+
37+
#[derive(Clone)]
38+
#[wasm_bindgen]
39+
pub struct FungibleAssetDelta(NativeFungibleAssetDelta);
40+
41+
#[wasm_bindgen]
42+
impl FungibleAssetDelta {
43+
#[wasm_bindgen(js_name = "numAssets")]
44+
pub fn num_assets(&self) -> usize {
45+
self.0.num_assets()
46+
}
47+
48+
#[wasm_bindgen(js_name = "isEmpty")]
49+
pub fn is_empty(&self) -> bool {
50+
self.0.is_empty()
51+
}
52+
53+
pub fn assets(&self) -> Vec<FungibleAssetDeltaItem> {
54+
self.0.iter().map(Into::into).collect()
55+
}
56+
}
57+
58+
// CONVERSIONS
59+
// ================================================================================================
60+
61+
impl From<NativeFungibleAssetDelta> for FungibleAssetDelta {
62+
fn from(native_fungible_asset_delta: NativeFungibleAssetDelta) -> Self {
63+
FungibleAssetDelta(native_fungible_asset_delta)
64+
}
65+
}
66+
67+
impl From<&NativeFungibleAssetDelta> for FungibleAssetDelta {
68+
fn from(native_fungible_asset_delta: &NativeFungibleAssetDelta) -> Self {
69+
FungibleAssetDelta(native_fungible_asset_delta.clone())
70+
}
71+
}

0 commit comments

Comments
 (0)