Skip to content

Commit

Permalink
chore: fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
HinsonSIDAN committed Sep 5, 2024
1 parent f8dfa8a commit 06dd8dd
Showing 1 changed file with 70 additions and 70 deletions.
140 changes: 70 additions & 70 deletions validators/emergency_unlock.ak
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
use aiken_virtual_dex/types.{AccountOracleDatum, EmergencyUnlockDatum}
use cardano/assets.{PolicyId}
use cardano/transaction.{OutputReference, Transaction}
use vodka_extra_signatories.{key_signed}
use vodka_inputs.{inputs_with_policy, only_input_datum_with}
use vodka_mints.{only_minted_token}
use vodka_outputs.{output_inline_datum}
use vodka_validity_range.{valid_after}
use vodka_value.{value_policy_info}
validator emergency_unlock(oracle_nft: PolicyId) {
spend(
_datum: Option<Data>,
_redeemer: Data,
_input: OutputReference,
tx: Transaction,
) {
let Transaction {
reference_inputs,
inputs,
extra_signatories,
validity_range,
mint,
..
} = tx
expect AccountOracleDatum { emergency_token, operation_key, .. }: AccountOracleDatum =
only_input_datum_with(reference_inputs, oracle_nft, "")
let emergency_inputs = inputs_with_policy(inputs, emergency_token)
let is_admin_signed = key_signed(extra_signatories, operation_key)
when emergency_inputs is {
[emergency_input] -> {
let emergency_token_info =
value_policy_info(emergency_input.output.value, emergency_token)
when
(emergency_token_info, output_inline_datum(emergency_input.output))
is {
(Some((_, asset_name, _)), emergency_datum) -> {
let is_owner_signed = key_signed(extra_signatories, asset_name)
if emergency_datum is EmergencyUnlockDatum {
let is_after_2days =
valid_after(
validity_range,
emergency_datum.minted_at + 172_800_001,
)
let is_after_1days =
valid_after(
validity_range,
emergency_datum.minted_at + 86_400_001,
)
let is_emergency_token_burnt =
only_minted_token(mint, emergency_token, asset_name, -1)
let admin_unlock = is_after_2days? && is_admin_signed?
let user_unlock =
is_after_1days? && !is_after_2days && is_emergency_token_burnt? && is_owner_signed?
admin_unlock? || user_unlock?
} else {
is_admin_signed?
}
}
_ -> is_admin_signed?
}
}
_ -> is_admin_signed?
}
}
else(_) {
fail
}
}
use aiken_virtual_dex/types.{AccountOracleDatum, EmergencyUnlockDatum}
use cardano/assets.{PolicyId}
use cardano/transaction.{OutputReference, Transaction}
use vodka_extra_signatories.{key_signed}
use vodka_inputs.{inputs_with_policy, only_input_datum_with}
use vodka_mints.{only_minted_token}
use vodka_outputs.{output_inline_datum}
use vodka_validity_range.{valid_after}
use vodka_value.{value_policy_info}

validator emergency_unlock(oracle_nft: PolicyId) {
spend(
_datum: Option<Data>,
_redeemer: Data,
_input: OutputReference,
tx: Transaction,
) {
let Transaction {
reference_inputs,
inputs,
extra_signatories,
validity_range,
mint,
..
} = tx
expect AccountOracleDatum { emergency_token, operation_key, .. }: AccountOracleDatum =
only_input_datum_with(reference_inputs, oracle_nft, "")
let emergency_inputs = inputs_with_policy(inputs, emergency_token)
let is_admin_signed = key_signed(extra_signatories, operation_key)
when emergency_inputs is {
[emergency_input] -> {
let emergency_token_info =
value_policy_info(emergency_input.output.value, emergency_token)
when
(emergency_token_info, output_inline_datum(emergency_input.output))
is {
(Some((_, asset_name, _)), emergency_datum) -> {
let is_owner_signed = key_signed(extra_signatories, asset_name)
if emergency_datum is EmergencyUnlockDatum {
let is_after_2days =
valid_after(
validity_range,
emergency_datum.minted_at + 172_800_001,
)
let is_after_1days =
valid_after(
validity_range,
emergency_datum.minted_at + 86_400_001,
)
let is_emergency_token_burnt =
only_minted_token(mint, emergency_token, asset_name, -1)
let admin_unlock = is_after_2days? && is_admin_signed?
let user_unlock =
is_after_1days? && !is_after_2days && is_emergency_token_burnt? && is_owner_signed?
admin_unlock? || user_unlock?
} else {
is_admin_signed?
}
}
_ -> is_admin_signed?
}
}
_ -> is_admin_signed?
}
}

else(_) {
fail
}
}

0 comments on commit 06dd8dd

Please sign in to comment.