fireblocks_sdk/models/policy_rule.rs
1// Fireblocks API
2//
3// Fireblocks provides a suite of applications to manage digital asset operations and a complete development platform to build your business on the blockchain. - Visit our website for more information: [Fireblocks Website](https://fireblocks.com) - Visit our developer docs: [Fireblocks DevPortal](https://developers.fireblocks.com)
4//
5// The version of the OpenAPI document: 1.8.0
6// Contact: developers@fireblocks.com
7// Generated by: https://openapi-generator.tech
8
9use {
10 crate::models,
11 serde::{Deserialize, Serialize},
12};
13
14/// PolicyRule : Policy rule which is enforced on transactions
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct PolicyRule {
17 /// (deprecated - replaced by \"operators\") | Defines users who can
18 /// initiate the type of transaction to which the rule applies. options are
19 /// * \"*\" - All users are allowed * Specific User id
20 #[serde(rename = "operator", skip_serializing_if = "Option::is_none")]
21 pub operator: Option<String>,
22 #[serde(rename = "operators", skip_serializing_if = "Option::is_none")]
23 pub operators: Option<models::PolicyRuleOperators>,
24 /// Defines the type of transaction to which the rule applies. * TRANSFER
25 /// - Default. Transfers funds from one account to another * CONTRACT_CALL
26 /// - Calls a smart contract, mainly for DeFi operations. * PROGRAM_CALL -
27 /// Calls a smart contract for web3 operations on the Solana blockchain.
28 /// * APPROVE - Allows a smart contract to withdraw from a designated
29 /// wallet. * MINT - Perform a mint operation (increase supply) on a
30 /// supported token * BURN - Perform a burn operation (reduce supply) on a
31 /// supported token * SUPPLY - Use for DeFi to lend assets * REDEEM -
32 /// Use for DeFi to get lending back * STAKE - Allows you to allocate and
33 /// lock certain assets for earning staking rewards. * RAW - An off-chain
34 /// message with no predefined format, use it to sign any message with your
35 /// private key. * TYPED_MESSAGE - An off-chain message type that follows
36 /// a predefined format, used to sign specific messages that are not actual
37 /// transactions.
38 #[serde(rename = "transactionType", skip_serializing_if = "Option::is_none")]
39 pub transaction_type: Option<TransactionType>,
40 /// (deprecated - replaced by \"designatedSigners\") Id representing the
41 /// user who signs transactions that match a specific rule
42 #[serde(rename = "designatedSigner", skip_serializing_if = "Option::is_none")]
43 pub designated_signer: Option<String>,
44 #[serde(rename = "designatedSigners", skip_serializing_if = "Option::is_none")]
45 pub designated_signers: Option<models::PolicyRuleDesignatedSigners>,
46 /// Policy rule type
47 #[serde(rename = "type")]
48 pub r#type: Type,
49 /// Defines what occurs when a transaction meets the rule's criteria * ALLOW
50 /// - The transaction goes through and can be signed without requiring
51 /// additional approvals * BLOCK - The transaction is automatically blocked
52 /// * 2-TIER - Only these users or user groups can approve If
53 /// any of them reject the transaction before the required approval
54 /// threshold is met, the transaction doesn't go through The list
55 /// of entities are set is \"authorizationGroups\" field
56 #[serde(rename = "action")]
57 pub action: Action,
58 /// Defines the type of asset being transacted, options are * \"*\" - All
59 /// assets * Specific asset
60 #[serde(rename = "asset")]
61 pub asset: String,
62 /// (deprecated - replaced by \"src\") source account type
63 #[serde(rename = "srcType", skip_serializing_if = "Option::is_none")]
64 pub src_type: Option<models::PolicySrcOrDestType>,
65 /// (deprecated - replaced by \"src\") source sub account type
66 #[serde(rename = "srcSubType", skip_serializing_if = "Option::is_none")]
67 pub src_sub_type: Option<models::PolicySrcOrDestSubType>,
68 /// (deprecated - replaced by \"src\") source account id
69 #[serde(rename = "srcId", skip_serializing_if = "Option::is_none")]
70 pub src_id: Option<String>,
71 #[serde(rename = "src", skip_serializing_if = "Option::is_none")]
72 pub src: Option<models::PolicyRuleSrc>,
73 /// (deprecated - replaced by \"dst\") destination account type
74 #[serde(rename = "dstType", skip_serializing_if = "Option::is_none")]
75 pub dst_type: Option<models::PolicySrcOrDestType>,
76 /// (deprecated - replaced by \"dst\") destination sub account type
77 #[serde(rename = "dstSubType", skip_serializing_if = "Option::is_none")]
78 pub dst_sub_type: Option<models::PolicySrcOrDestSubType>,
79 /// (deprecated - replaced by \"dst\") destination account id
80 #[serde(rename = "dstId", skip_serializing_if = "Option::is_none")]
81 pub dst_id: Option<String>,
82 #[serde(rename = "dst", skip_serializing_if = "Option::is_none")]
83 pub dst: Option<models::PolicyRuleDst>,
84 /// Defines whether the destination to which you are sending funds must be
85 /// whitelisted, to allow one-time transfers to non-whitelisted external
86 /// addresses, or both. By default, you can only transfer to an external
87 /// address after it’s whitelisted. * WHITELISTED - Can only be sent to
88 /// whitelisted addresses. * ONE_TIME - Can only be sent to
89 /// non-whitelisted external addresses. * \"*\" - can be sent to
90 /// whitelisted addresses or non-whitelisted external
91 #[serde(rename = "dstAddressType", skip_serializing_if = "Option::is_none")]
92 pub dst_address_type: Option<DstAddressType>,
93 /// * USD - Limits the amount of any asset users can transfer based on the
94 /// USD equivalent of the asset. * EUR - Limits the amount of any asset
95 /// users can transfer based on the EURO equivalent of the asset. * NATIVE
96 /// - Limits the amount of an asset a user can transfer when using a
97 /// specific asset.
98 #[serde(rename = "amountCurrency")]
99 pub amount_currency: AmountCurrency,
100 /// * SINGLE_TX - limit applies to a single transaction * TIMEFRAME - limit
101 /// applies to all transactions within the defined time period
102 #[serde(rename = "amountScope")]
103 pub amount_scope: AmountScope,
104 #[serde(rename = "amount")]
105 pub amount: models::PolicyRuleAmount,
106 /// Time period in seconds applied by the amountScope field to accumulate
107 /// transferred amounts in transactions that match the rule, until the total
108 /// exceeds the value you specify under Minimum. When the specified amount
109 /// is reached within that period, whether by one or many transactions,
110 /// further transactions in that period either fail or require more
111 /// approvals.
112 #[serde(rename = "periodSec")]
113 pub period_sec: f64,
114 /// (deprecated - replaced by \"authorizationGroups\") Allowed entities
115 /// which can approves a transaction
116 #[serde(rename = "authorizers", skip_serializing_if = "Option::is_none")]
117 pub authorizers: Option<Vec<String>>,
118 /// (deprecated - replaced by \"authorizationGroups\") Min amount of
119 /// entities which are needed to approve a transaction
120 #[serde(rename = "authorizersCount", skip_serializing_if = "Option::is_none")]
121 pub authorizers_count: Option<f64>,
122 #[serde(
123 rename = "authorizationGroups",
124 skip_serializing_if = "Option::is_none"
125 )]
126 pub authorization_groups: Option<models::PolicyRuleAuthorizationGroups>,
127 #[serde(rename = "amountAggregation", skip_serializing_if = "Option::is_none")]
128 pub amount_aggregation: Option<models::PolicyRuleAmountAggregation>,
129 #[serde(rename = "rawMessageSigning", skip_serializing_if = "Option::is_none")]
130 pub raw_message_signing: Option<models::PolicyRuleRawMessageSigning>,
131 /// Applying this rule over APPROVE type transactions (can only be enabled
132 /// when rule's transaction type is TRANSFER)
133 #[serde(rename = "applyForApprove", skip_serializing_if = "Option::is_none")]
134 pub apply_for_approve: Option<bool>,
135 /// Applying this rule over TYPED_MESSAGE type transactions (can only be
136 /// enabled when rule's transaction type is CONTRACT_CALL)
137 #[serde(
138 rename = "applyForTypedMessage",
139 skip_serializing_if = "Option::is_none"
140 )]
141 pub apply_for_typed_message: Option<bool>,
142 /// A unique id identifying the rule
143 #[serde(rename = "externalDescriptor", skip_serializing_if = "Option::is_none")]
144 pub external_descriptor: Option<String>,
145}
146
147impl PolicyRule {
148 /// Policy rule which is enforced on transactions
149 pub fn new(
150 r#type: Type,
151 action: Action,
152 asset: String,
153 amount_currency: AmountCurrency,
154 amount_scope: AmountScope,
155 amount: models::PolicyRuleAmount,
156 period_sec: f64,
157 ) -> PolicyRule {
158 PolicyRule {
159 operator: None,
160 operators: None,
161 transaction_type: None,
162 designated_signer: None,
163 designated_signers: None,
164 r#type,
165 action,
166 asset,
167 src_type: None,
168 src_sub_type: None,
169 src_id: None,
170 src: None,
171 dst_type: None,
172 dst_sub_type: None,
173 dst_id: None,
174 dst: None,
175 dst_address_type: None,
176 amount_currency,
177 amount_scope,
178 amount,
179 period_sec,
180 authorizers: None,
181 authorizers_count: None,
182 authorization_groups: None,
183 amount_aggregation: None,
184 raw_message_signing: None,
185 apply_for_approve: None,
186 apply_for_typed_message: None,
187 external_descriptor: None,
188 }
189 }
190}
191/// Defines the type of transaction to which the rule applies. * TRANSFER -
192/// Default. Transfers funds from one account to another * CONTRACT_CALL -
193/// Calls a smart contract, mainly for DeFi operations. * PROGRAM_CALL - Calls
194/// a smart contract for web3 operations on the Solana blockchain. * APPROVE
195/// - Allows a smart contract to withdraw from a designated wallet. * MINT -
196/// Perform a mint operation (increase supply) on a supported token * BURN -
197/// Perform a burn operation (reduce supply) on a supported token * SUPPLY -
198/// Use for DeFi to lend assets * REDEEM - Use for DeFi to get lending back
199/// * STAKE - Allows you to allocate and lock certain assets for earning staking
200/// rewards. * RAW - An off-chain message with no predefined format, use it to
201/// sign any message with your private key. * TYPED_MESSAGE - An off-chain
202/// message type that follows a predefined format, used to sign specific
203/// messages that are not actual transactions.
204#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
205pub enum TransactionType {
206 #[serde(rename = "TRANSFER")]
207 Transfer,
208 #[serde(rename = "CONTRACT_CALL")]
209 ContractCall,
210 #[serde(rename = "PROGRAM_CALL")]
211 ProgramCall,
212 #[serde(rename = "APPROVE")]
213 Approve,
214 #[serde(rename = "MINT")]
215 Mint,
216 #[serde(rename = "BURN")]
217 Burn,
218 #[serde(rename = "SUPPLY")]
219 Supply,
220 #[serde(rename = "REDEEM")]
221 Redeem,
222 #[serde(rename = "STAKE")]
223 Stake,
224 #[serde(rename = "RAW")]
225 Raw,
226 #[serde(rename = "TYPED_MESSAGE")]
227 TypedMessage,
228}
229
230impl Default for TransactionType {
231 fn default() -> TransactionType {
232 Self::Transfer
233 }
234}
235/// Policy rule type
236#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
237pub enum Type {
238 #[serde(rename = "TRANSFER")]
239 Transfer,
240}
241
242impl Default for Type {
243 fn default() -> Type {
244 Self::Transfer
245 }
246}
247/// Defines what occurs when a transaction meets the rule's criteria * ALLOW -
248/// The transaction goes through and can be signed without requiring additional
249/// approvals * BLOCK - The transaction is automatically blocked * 2-TIER - Only
250/// these users or user groups can approve If any of them reject the
251/// transaction before the required approval threshold is met, the transaction
252/// doesn't go through The list of entities are set is
253/// \"authorizationGroups\" field
254#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
255pub enum Action {
256 #[serde(rename = "ALLOW")]
257 Allow,
258 #[serde(rename = "BLOCK")]
259 Block,
260 #[serde(rename = "2-TIER")]
261 Variant2Tier,
262}
263
264impl Default for Action {
265 fn default() -> Action {
266 Self::Allow
267 }
268}
269/// Defines whether the destination to which you are sending funds must be
270/// whitelisted, to allow one-time transfers to non-whitelisted external
271/// addresses, or both. By default, you can only transfer to an external address
272/// after it’s whitelisted. * WHITELISTED - Can only be sent to whitelisted
273/// addresses. * ONE_TIME - Can only be sent to non-whitelisted external
274/// addresses. * \"*\" - can be sent to whitelisted addresses or
275/// non-whitelisted external
276#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
277pub enum DstAddressType {
278 #[serde(rename = "WHITELISTED")]
279 Whitelisted,
280 #[serde(rename = "ONE_TIME")]
281 OneTime,
282 #[serde(rename = "*")]
283 Star,
284}
285
286impl Default for DstAddressType {
287 fn default() -> DstAddressType {
288 Self::Whitelisted
289 }
290}
291/// * USD - Limits the amount of any asset users can transfer based on the USD
292/// equivalent of the asset. * EUR - Limits the amount of any asset users can
293/// transfer based on the EURO equivalent of the asset. * NATIVE - Limits the
294/// amount of an asset a user can transfer when using a specific asset.
295#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
296pub enum AmountCurrency {
297 #[serde(rename = "USD")]
298 Usd,
299 #[serde(rename = "EUR")]
300 Eur,
301 #[serde(rename = "NATIVE")]
302 Native,
303}
304
305impl Default for AmountCurrency {
306 fn default() -> AmountCurrency {
307 Self::Usd
308 }
309}
310/// * SINGLE_TX - limit applies to a single transaction * TIMEFRAME - limit
311/// applies to all transactions within the defined time period
312#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
313pub enum AmountScope {
314 #[serde(rename = "SINGLE_TX")]
315 SingleTx,
316 #[serde(rename = "TIMEFRAME")]
317 Timeframe,
318}
319
320impl Default for AmountScope {
321 fn default() -> AmountScope {
322 Self::SingleTx
323 }
324}