Skip to content

Commit

Permalink
add opt_ins to preview request
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbzurovski committed Sep 25, 2024
1 parent c446600 commit 72f1627
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@
}
],
"start_epoch_inclusive": 51652,
"tip_percentage": 0
"tip_percentage": 0,
"opt_ins":
{
"radix_engine_toolkit_receipt": true
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod opt_ins;
mod request_flags;
mod transaction_preview;

pub use opt_ins::*;
pub use request_flags::*;
pub use transaction_preview::*;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use crate::prelude::*;

impl TransactionPreviewRequestOptIns {
pub fn new(radix_engine_toolkit_receipt: bool) -> Self {
Self {
radix_engine_toolkit_receipt,
}
}
}

impl Default for TransactionPreviewRequestOptIns {
fn default() -> Self {
Self::new(true)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[allow(clippy::upper_case_acronyms)]
type SUT = TransactionPreviewRequestOptIns;

#[test]
fn default_value() {
let sut = SUT::default();
assert!(sut.radix_engine_toolkit_receipt);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ impl TransactionPreviewRequest {
flags: flags
.into()
.unwrap_or(TransactionPreviewRequestFlags::default()),
opt_ins: TransactionPreviewRequestOptIns::default(),
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
mod opt_ins;
mod request_flags;
mod transaction_preview;

pub use opt_ins::*;
pub use request_flags::*;
pub use transaction_preview::*;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use crate::prelude::*;

#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize, /* Deserialize so we can test roundtrip of JSON vectors */
)]
pub struct TransactionPreviewRequestOptIns {
/** This flag controls whether the preview response will include a Radix Engine Toolkit serializable receipt or not. */
pub(crate) radix_engine_toolkit_receipt: bool,
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@ pub(crate) struct TransactionPreviewRequest {
pub(crate) signer_public_keys: Vec<GWPublicKey>,

pub(crate) flags: TransactionPreviewRequestFlags,

/** A set of flags to configure the response of the transaction preview. */
pub(crate) opt_ins: TransactionPreviewRequestOptIns,
}
3 changes: 0 additions & 3 deletions crates/sargon/tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ mod integration_tests {
assert!(epoch > Epoch::from(0));
}

// Commented until GW 1.7.2 is released (which has `radix_engine_toolkit_receipt` inside the the Transaction Review response)
/*
#[actix_rt::test]
async fn dry_run_transaction() {
// ARRANGE
Expand Down Expand Up @@ -132,7 +130,6 @@ mod integration_tests {
)])
);
}
*/

async fn submit_tx_use_faucet(
private_key: impl Into<PrivateKey>,
Expand Down

0 comments on commit 72f1627

Please sign in to comment.