Skip to content

Add more information to SimulationOutput #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: feat/mt-burn-withdraw-info
Choose a base branch
from

Conversation

BonelessImpl
Copy link
Contributor

Replaces #74

This uses only the Inspector to get this data. This is why this is based on another branch as both have similar changes to the Inspector interface.

@@ -1,7 +1,7 @@
pub mod accounts;
mod deadline;
pub mod engine;
mod error;
pub mod error;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error::* is already re-exported below

@@ -112,9 +112,16 @@ pub enum ParseTokenIdError {

#[near(serializers = [borsh, json])]
#[autoimpl(Deref using self.0)]
#[autoimpl(DerefMut using self.0)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DerefMut was not implemented here on purpose: all mutations happen on Amounts level to enforce using .checked_...() operations

#[derive(Debug, Clone, Default, PartialEq, Eq)]
pub struct Amounts<T = BTreeMap<TokenId, u128>>(T);

impl<T> From<T> for Amounts<T> {
fn from(m: T) -> Self {
Amounts(m)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Amounts(m)
Self::new(m)

Comment on lines +58 to +60
pub ft_withdrawals: Option<Vec<FtWithdraw>>,
pub nft_withdrawals: Option<Vec<NftWithdraw>>,
pub mt_withdrawals: Option<Vec<MtWithdraw>>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub ft_withdrawals: Option<Vec<FtWithdraw>>,
pub nft_withdrawals: Option<Vec<NftWithdraw>>,
pub mt_withdrawals: Option<Vec<MtWithdraw>>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub ft_withdrawals: Vec<FtWithdraw>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub nft_withdrawals: Vec<NftWithdraw>,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub mt_withdrawals: Vec<MtWithdraw>,

.unwrap();
let sim_res = env.defuse.simulate_intents(signed.clone()).await.unwrap();
assert_eq!(sim_res.balance_diff, into_simulation_diff(accounts.clone()));
println!("Balance diff: {:#?}", sim_res.balance_diff);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe print the whole simulation output?

Suggested change
println!("Balance diff: {:#?}", sim_res.balance_diff);
println!("simulation_output: {}", serde_json::to_string(&sim_res).unwrap());

And do it before asserting?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants