Skip to content

Commit

Permalink
fix third party deposit manifest (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
CyonAlexRDX authored May 27, 2024
1 parent 5358f14 commit 1195c5d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sargon"
version = "1.0.3"
version = "1.0.4"
edition = "2021"
build = "build.rs"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,36 @@ mod tests {
#[allow(clippy::upper_case_acronyms)]
type SUT = TransactionManifest;

#[test]
fn test_remove_depositor() {
let owner = AccountAddress::sample();
let manifest = SUT::third_party_deposit_update_by_delta(
&owner,
ThirdPartyDepositsDelta::sample(),
);
manifest_eq(
manifest,
r#"
CALL_METHOD
Address("account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr")
"set_default_deposit_rule"
Enum<1u8>()
;
CALL_METHOD
Address("account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr")
"remove_resource_preference"
Address("resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd")
;
CALL_METHOD
Address("account_rdx128y6j78mt0aqv6372evz28hrxp8mn06ccddkr7xppc88hyvynvjdwr")
"remove_authorized_depositor"
Enum<1u8>(
Address("resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd")
)
;"#,
);
}

#[test]
fn update_third_party_deposits() {
let owner:AccountAddress = "account_tdx_2_128x8q5es2dstqtcc8wqm843xdtfs0lgetfcdn62a54wxspj6yhpxkf".into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::prelude::*;

use radix_engine_interface::blueprints::account::{
AccountAddAuthorizedDepositorInput as ScryptoAccountAddAuthorizedDepositorInput,
AccountRemoveAuthorizedDepositorInput as ScryptoAccountRemoveAuthorizedDepositorInput,
AccountRemoveResourcePreferenceInput as ScryptoAccountRemoveResourcePreferenceInput,
AccountSetResourcePreferenceInput as ScryptoAccountSetResourcePreferenceInput,
};
Expand All @@ -13,7 +14,7 @@ pub struct ThirdPartyDepositsDelta {
pub(crate) asset_exceptions_to_add_or_update:
Vec<ScryptoAccountSetResourcePreferenceInput>,
pub(crate) depositor_addresses_to_remove:
Vec<ScryptoAccountRemoveResourcePreferenceInput>,
Vec<ScryptoAccountRemoveAuthorizedDepositorInput>,
pub(crate) depositor_addresses_to_add:
Vec<ScryptoAccountAddAuthorizedDepositorInput>,
}
Expand Down Expand Up @@ -69,7 +70,7 @@ impl ThirdPartyDepositsDelta {
.into_iter()
.contains(x)
})
.map(ScryptoAccountRemoveResourcePreferenceInput::from)
.map(ScryptoAccountRemoveAuthorizedDepositorInput::from)
.collect(),
depositor_addresses_to_add: to
.depositors_allow_list
Expand All @@ -90,9 +91,18 @@ impl ThirdPartyDepositsDelta {
}
}

impl From<ResourceOrNonFungible>
for ScryptoAccountRemoveAuthorizedDepositorInput
{
fn from(value: ResourceOrNonFungible) -> Self {
Self {
badge: value.into(),
}
}
}
impl From<ResourceOrNonFungible> for ScryptoAccountAddAuthorizedDepositorInput {
fn from(value: ResourceOrNonFungible) -> Self {
ScryptoAccountAddAuthorizedDepositorInput {
Self {
badge: value.into(),
}
}
Expand Down Expand Up @@ -395,7 +405,7 @@ mod tests {
depositor_addresses
.clone()
.into_iter()
.map(ScryptoAccountRemoveResourcePreferenceInput::from)
.map(ScryptoAccountRemoveAuthorizedDepositorInput::from)
.collect_vec()
);
}
Expand Down Expand Up @@ -440,7 +450,7 @@ mod tests {
expected_depositor_addresses_to_remove
.clone()
.into_iter()
.map(ScryptoAccountRemoveResourcePreferenceInput::from)
.map(ScryptoAccountRemoveAuthorizedDepositorInput::from)
.collect_vec()
);
}
Expand Down

0 comments on commit 1195c5d

Please sign in to comment.