Skip to content

Commit

Permalink
Handle aux parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
igamigo authored and mFragaBA committed Jun 14, 2024
1 parent 7b5a85d commit e4a2565
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use.miden::contracts::wallets::basic->wallet
begin
push.{recipient}
push.{note_type}
push.{aux}
push.{tag}
push.{asset}
call.wallet::send_asset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use.miden::contracts::auth::basic->auth_tx
begin
push.{recipient}
push.{note_type}
push.{aux}
push.{tag}
push.{amount}
call.faucet::distribute
Expand Down
13 changes: 8 additions & 5 deletions src/client/transactions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use miden_objects::{
ExecutedTransaction, InputNote, InputNotes, OutputNote, OutputNotes, ProvenTransaction,
TransactionArgs, TransactionId, TransactionScript,
},
Digest, Felt, Word,
Digest, Felt, FieldElement, Word,
};
use miden_tx::{auth::TransactionAuthenticator, ProvingOptions, ScriptTarget, TransactionProver};
#[cfg(not(feature = "wasm"))]
Expand Down Expand Up @@ -364,7 +364,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
payment_data.target_account_id(),
vec![payment_data.asset()],
note_type,
Default::default(),
Felt::ZERO,
recall_height,
&mut random_coin,
)?
Expand All @@ -374,7 +374,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
payment_data.target_account_id(),
vec![payment_data.asset()],
note_type,
Default::default(),
Felt::ZERO,
&mut random_coin,
)?
};
Expand All @@ -393,6 +393,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
&transaction_request::AUTH_SEND_ASSET_SCRIPT
.replace("{recipient}", &recipient)
.replace("{note_type}", &Felt::new(note_type as u64).to_string())
.replace("{aux}", &created_note.metadata().aux().to_string())
.replace("{tag}", &Felt::new(note_tag.into()).to_string())
.replace("{asset}", &prepare_word(&payment_data.asset().into()).to_string()),
)
Expand Down Expand Up @@ -426,7 +427,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
swap_data.offered_asset(),
swap_data.requested_asset(),
note_type,
Default::default(),
Felt::ZERO,
&mut random_coin,
)?;

Expand All @@ -444,6 +445,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
&transaction_request::AUTH_SEND_ASSET_SCRIPT
.replace("{recipient}", &recipient)
.replace("{note_type}", &Felt::new(note_type as u64).to_string())
.replace("{aux}", &created_note.metadata().aux().to_string())
.replace("{tag}", &Felt::new(note_tag.into()).to_string())
.replace("{asset}", &prepare_word(&swap_data.offered_asset().into()).to_string()),
)
Expand Down Expand Up @@ -475,7 +477,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
target_account_id,
vec![asset.into()],
note_type,
Default::default(),
Felt::ZERO,
&mut random_coin,
)?;

Expand All @@ -493,6 +495,7 @@ impl<N: NodeRpcClient, R: FeltRng, S: Store, A: TransactionAuthenticator> Client
&transaction_request::DISTRIBUTE_FUNGIBLE_ASSET_SCRIPT
.replace("{recipient}", &recipient)
.replace("{note_type}", &Felt::new(note_type as u64).to_string())
.replace("{aux}", &created_note.metadata().aux().to_string())
.replace("{tag}", &Felt::new(note_tag.into()).to_string())
.replace("{amount}", &Felt::new(asset.amount()).to_string()),
)
Expand Down
4 changes: 4 additions & 0 deletions src/client/transactions/transaction_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ mod tests {
assets::FungibleAsset,
crypto::rand::RpoRandomCoin,
notes::NoteType,
Felt, FieldElement,
};

use crate::client::transactions::transaction_request::known_script_roots::{P2ID, P2IDR, SWAP};
Expand All @@ -263,6 +264,7 @@ mod tests {
account_id,
vec![FungibleAsset::new(faucet_id, 100u64).unwrap().into()],
NoteType::OffChain,
Felt::ZERO,
&mut rng,
)
.unwrap();
Expand All @@ -271,6 +273,7 @@ mod tests {
account_id,
vec![FungibleAsset::new(faucet_id, 100u64).unwrap().into()],
NoteType::OffChain,
Felt::ZERO,
10,
&mut rng,
)
Expand All @@ -280,6 +283,7 @@ mod tests {
FungibleAsset::new(faucet_id, 100u64).unwrap().into(),
FungibleAsset::new(faucet_id, 100u64).unwrap().into(),
NoteType::OffChain,
Felt::ZERO,
&mut rng,
)
.unwrap();
Expand Down

0 comments on commit e4a2565

Please sign in to comment.