-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathoptions.rs
76 lines (69 loc) · 2.59 KB
/
options.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2024 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use alloc::collections::{BTreeMap, BTreeSet};
use serde::{Deserialize, Serialize};
use crate::{
client::api::transaction_builder::{transition::Transitions, Burn},
types::block::{
address::Address,
output::{AccountId, OutputId},
payload::tagged_data::TaggedDataPayload,
},
};
/// Options for transactions
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[serde(default)]
pub struct TransactionOptions {
/// The strategy applied for base coin remainders.
pub remainder_value_strategy: RemainderValueStrategy,
/// An optional tagged data payload.
pub tagged_data_payload: Option<TaggedDataPayload>,
/// Inputs that must be used for the transaction.
pub required_inputs: BTreeSet<OutputId>,
/// Specifies what needs to be transitioned in the transaction and how.
pub transitions: Option<Transitions>,
/// Specifies what needs to be burned in the transaction.
pub burn: Option<Burn>,
/// A string attached to the transaction.
pub note: Option<String>,
/// Whether to allow sending a micro amount.
pub allow_micro_amount: bool,
/// Whether to allow the selection of additional inputs for this transaction.
pub allow_additional_input_selection: bool,
/// Mana allotments for the transaction.
pub mana_allotments: BTreeMap<AccountId, u64>,
/// Optional block issuer to which the transaction will have required mana allotted.
pub issuer_id: Option<AccountId>,
}
impl Default for TransactionOptions {
fn default() -> Self {
Self {
remainder_value_strategy: Default::default(),
tagged_data_payload: Default::default(),
required_inputs: Default::default(),
transitions: Default::default(),
burn: Default::default(),
note: Default::default(),
allow_micro_amount: false,
allow_additional_input_selection: true,
mana_allotments: Default::default(),
issuer_id: Default::default(),
}
}
}
#[allow(clippy::enum_variant_names)]
/// The strategy to use for the remainder value management when sending funds.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "strategy", content = "value")]
pub enum RemainderValueStrategy {
/// Keep the remainder value on the source address.
ReuseAddress,
/// Move the remainder value to any specified address.
CustomAddress(Address),
}
impl Default for RemainderValueStrategy {
fn default() -> Self {
Self::ReuseAddress
}
}