Skip to content
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

Add with_ prefix to ISA setters #1136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions sdk/src/client/api/block_builder/input_selection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,31 +194,31 @@ impl InputSelection {
}

/// Sets the required inputs of an [`InputSelection`].
pub fn required_inputs(mut self, inputs: impl Into<HashSet<OutputId>>) -> Self {
pub fn with_required_inputs(mut self, inputs: impl Into<HashSet<OutputId>>) -> Self {
self.required_inputs = inputs.into();
self
}

/// Sets the forbidden inputs of an [`InputSelection`].
pub fn forbidden_inputs(mut self, inputs: HashSet<OutputId>) -> Self {
pub fn with_forbidden_inputs(mut self, inputs: HashSet<OutputId>) -> Self {
self.forbidden_inputs = inputs;
self
}

/// Sets the burn of an [`InputSelection`].
pub fn burn(mut self, burn: impl Into<Option<Burn>>) -> Self {
pub fn with_burn(mut self, burn: impl Into<Option<Burn>>) -> Self {
self.burn = burn.into();
self
}

/// Sets the remainder address of an [`InputSelection`].
pub fn remainder_address(mut self, address: impl Into<Option<Address>>) -> Self {
pub fn with_remainder_address(mut self, address: impl Into<Option<Address>>) -> Self {
self.remainder_address = address.into();
self
}

/// Sets the slot index of an [`InputSelection`].
pub fn slot_index(mut self, slot_index: impl Into<SlotIndex>) -> Self {
pub fn with_slot_index(mut self, slot_index: impl Into<SlotIndex>) -> Self {
self.slot_index = slot_index.into();
self
}
Expand Down
22 changes: 11 additions & 11 deletions sdk/src/wallet/account/operations/transaction/input_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ where
addresses,
protocol_parameters.clone(),
)
.required_inputs(custom_inputs)
.forbidden_inputs(forbidden_inputs);
.with_required_inputs(custom_inputs)
.with_forbidden_inputs(forbidden_inputs);

if let Some(address) = remainder_address {
input_selection = input_selection.remainder_address(address);
input_selection = input_selection.with_remainder_address(address);
}

if let Some(burn) = burn {
input_selection = input_selection.burn(burn.clone());
input_selection = input_selection.with_burn(burn.clone());
}

let selected_transaction_data = input_selection.select()?;
Expand All @@ -135,15 +135,15 @@ where
addresses,
protocol_parameters.clone(),
)
.required_inputs(mandatory_inputs)
.forbidden_inputs(forbidden_inputs);
.with_required_inputs(mandatory_inputs)
.with_forbidden_inputs(forbidden_inputs);

if let Some(address) = remainder_address {
input_selection = input_selection.remainder_address(address);
input_selection = input_selection.with_remainder_address(address);
}

if let Some(burn) = burn {
input_selection = input_selection.burn(burn.clone());
input_selection = input_selection.with_burn(burn.clone());
}

let selected_transaction_data = input_selection.select()?;
Expand All @@ -167,14 +167,14 @@ where
addresses,
protocol_parameters.clone(),
)
.forbidden_inputs(forbidden_inputs);
.with_forbidden_inputs(forbidden_inputs);

if let Some(address) = remainder_address {
input_selection = input_selection.remainder_address(address);
input_selection = input_selection.with_remainder_address(address);
}

if let Some(burn) = burn {
input_selection = input_selection.burn(burn.clone());
input_selection = input_selection.with_burn(burn.clone());
}

let selected_transaction_data = match input_selection.select() {
Expand Down
22 changes: 11 additions & 11 deletions sdk/tests/client/input_selection/account_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ fn burn_account() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_2))
.with_burn(Burn::new().add_account(account_id_2))
.select()
.unwrap();

Expand Down Expand Up @@ -1160,7 +1160,7 @@ fn account_burn_should_not_validate_account_sender() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.with_burn(Burn::new().add_account(account_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -1205,7 +1205,7 @@ fn account_burn_should_not_validate_account_address() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.with_burn(Burn::new().add_account(account_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -1536,7 +1536,7 @@ fn state_controller_sender_required_already_selected() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -1590,7 +1590,7 @@ fn state_controller_sender_required_but_governance() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select();

assert!(matches!(
Expand Down Expand Up @@ -1702,7 +1702,7 @@ fn governor_sender_required_already_selected() {
addresses([BECH32_ADDRESS_ED25519_1]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -1744,7 +1744,7 @@ fn governance_transition_and_required() {
addresses([BECH32_ADDRESS_ED25519_1]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -1786,7 +1786,7 @@ fn state_transition_and_required() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -1840,7 +1840,7 @@ fn governor_sender_required_but_state() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select();

assert!(matches!(
Expand Down Expand Up @@ -1992,7 +1992,7 @@ fn remainder_address_in_governor() {
protocol_parameters,
)
// Add the basic output so it will be consumed
.required_inputs([*inputs[1].output_id()])
.with_required_inputs([*inputs[1].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -2216,7 +2216,7 @@ fn burn_account_but_governor_not_owned() {
addresses([BECH32_ADDRESS_ED25519_2]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.with_burn(Burn::new().add_account(account_id_1))
.select();

assert!(matches!(
Expand Down
6 changes: 3 additions & 3 deletions sdk/tests/client/input_selection/basic_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ fn input_amount_greater_than_output_amount_with_remainder_address() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.remainder_address(remainder_address)
.with_remainder_address(remainder_address)
.select()
.unwrap();

Expand Down Expand Up @@ -1196,7 +1196,7 @@ fn sender_already_selected() {
addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -1235,7 +1235,7 @@ fn single_mandatory_input() {
addresses([BECH32_ADDRESS_ED25519_0, BECH32_ADDRESS_ED25519_1]),
protocol_parameters,
)
.required_inputs([*inputs[0].output_id()])
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down
40 changes: 20 additions & 20 deletions sdk/tests/client/input_selection/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fn burn_account_present() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.with_burn(Burn::new().add_account(account_id_1))
.select()
.unwrap();

Expand Down Expand Up @@ -103,8 +103,8 @@ fn burn_account_present_and_required() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.required_inputs([*inputs[0].output_id()])
.with_burn(Burn::new().add_account(account_id_1))
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -150,7 +150,7 @@ fn burn_account_id_zero() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_nft(nft_id))
.with_burn(Burn::new().add_nft(nft_id))
.select()
.unwrap();

Expand Down Expand Up @@ -191,7 +191,7 @@ fn burn_account_absent() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.with_burn(Burn::new().add_account(account_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -248,7 +248,7 @@ fn burn_accounts_present() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().set_accounts(HashSet::from([account_id_1, account_id_2])))
.with_burn(Burn::new().set_accounts(HashSet::from([account_id_1, account_id_2])))
.select()
.unwrap();

Expand Down Expand Up @@ -296,7 +296,7 @@ fn burn_account_in_outputs() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id_1))
.with_burn(Burn::new().add_account(account_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -341,7 +341,7 @@ fn burn_nft_present() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_nft(nft_id_1))
.with_burn(Burn::new().add_nft(nft_id_1))
.select()
.unwrap();

Expand Down Expand Up @@ -386,8 +386,8 @@ fn burn_nft_present_and_required() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_nft(nft_id_1))
.required_inputs([*inputs[0].output_id()])
.with_burn(Burn::new().add_nft(nft_id_1))
.with_required_inputs([*inputs[0].output_id()])
.select()
.unwrap();

Expand Down Expand Up @@ -433,7 +433,7 @@ fn burn_nft_id_zero() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_account(account_id))
.with_burn(Burn::new().add_account(account_id))
.select()
.unwrap();

Expand Down Expand Up @@ -474,7 +474,7 @@ fn burn_nft_absent() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_nft(nft_id_1))
.with_burn(Burn::new().add_nft(nft_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -531,7 +531,7 @@ fn burn_nfts_present() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().set_nfts(HashSet::from([nft_id_1, nft_id_2])))
.with_burn(Burn::new().set_nfts(HashSet::from([nft_id_1, nft_id_2])))
.select()
.unwrap();

Expand Down Expand Up @@ -579,7 +579,7 @@ fn burn_nft_in_outputs() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_nft(nft_id_1))
.with_burn(Burn::new().add_nft(nft_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -631,7 +631,7 @@ fn burn_foundry_present() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_foundry(inputs[0].output.as_foundry().id()))
.with_burn(Burn::new().add_foundry(inputs[0].output.as_foundry().id()))
.select()
.unwrap();

Expand Down Expand Up @@ -717,7 +717,7 @@ fn burn_foundry_absent() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_foundry(foundry_id_1))
.with_burn(Burn::new().add_foundry(foundry_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -775,7 +775,7 @@ fn burn_foundries_present() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().set_foundries(HashSet::from([
.with_burn(Burn::new().set_foundries(HashSet::from([
inputs[0].output.as_foundry().id(),
inputs[1].output.as_foundry().id(),
])))
Expand Down Expand Up @@ -839,7 +839,7 @@ fn burn_foundry_in_outputs() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().add_foundry(foundry_id_1))
.with_burn(Burn::new().add_foundry(foundry_id_1))
.select();

assert!(matches!(
Expand Down Expand Up @@ -869,7 +869,7 @@ fn burn_native_tokens() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(Burn::new().set_native_tokens(HashMap::from([
.with_burn(Burn::new().set_native_tokens(HashMap::from([
(TokenId::from_str(TOKEN_ID_1).unwrap(), 20),
(TokenId::from_str(TOKEN_ID_2).unwrap(), 30),
])))
Expand Down Expand Up @@ -929,7 +929,7 @@ fn burn_foundry_and_its_account() {
addresses([BECH32_ADDRESS_ED25519_0]),
protocol_parameters,
)
.burn(
.with_burn(
Burn::new()
.add_foundry(inputs[0].output.as_foundry().id())
.add_account(account_id_1),
Expand Down
Loading
Loading