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

MIN-1643: Remove some assert and redudant logic #46

Merged
merged 2 commits into from
Aug 2, 2024
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
9 changes: 0 additions & 9 deletions lib/lb_v2/validation.ak
Original file line number Diff line number Diff line change
Expand Up @@ -592,15 +592,6 @@ pub fn validate_seller_outputs(
} = seller_output
expect datum: SellerDatum = raw_datum
let SellerDatum { owner, .. } = datum
expect
datum == SellerDatum {
factory_policy_id,
base_asset,
raise_asset,
amount: 0,
penalty_amount: 0,
owner,
}
// all sellers have the same owner
and {
value.flatten(seller_value) == [
Expand Down
12 changes: 6 additions & 6 deletions plutus.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions plutus.ts

Large diffs are not rendered by default.

73 changes: 32 additions & 41 deletions validators/factory.ak
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ validator(
expect [factory_input] = factory_inputs
// finding exactly 2 Factory Outputs
expect [f_out_head, f_out_tail] = factory_outputs
// finding exactly 1 Treasury Input
// finding exactly 1 Treasury Output
let treasury_output =
validation.get_treasury_output(
outputs: outputs,
Expand Down Expand Up @@ -326,14 +326,12 @@ validator(
) == 1,
value.quantity_of(factory_out_value, factory_hash, factory_auth_an) == 1,
value.quantity_of(treasury_in_value, factory_hash, treasury_auth_an) == 1,
assert(
validate_factory_remove_node(
out_datum: factory_out_datum,
in_datum_1: factory_input_1_raw_datum,
in_datum_2: factory_input_2_raw_datum,
lp_asset_name: lp_asset_name,
),
@"Remove Factory Linked List must be correct!",
// Remove Factory Linked List must be correct!
validate_factory_remove_node(
out_datum: factory_out_datum,
in_datum_1: factory_input_1_raw_datum,
in_datum_2: factory_input_2_raw_datum,
lp_asset_name: lp_asset_name,
),
list.length(value.flatten(factory_out_value)) == 2,
factory_out_ref_script == None,
Expand All @@ -349,13 +347,14 @@ validator(
extra_signatories: extra_signatories,
inputs: inputs,
),
assert(is_cancelled, @"LBE should already cancelled"),
assert(
is_manager_collected,
@"All Manager, Sellers must be collected!",
),
assert(reserve_raise == 0, @"All Orders have been executed."),
assert(total_penalty == 0, @"All Penalty have been handled."),
// LBE should already cancelled
is_cancelled,
// All Manager, Sellers must be collected!
is_manager_collected,
// All Orders have been executed.
reserve_raise == 0,
// All Penalty have been handled.
total_penalty == 0,
}
}
_ -> False
Expand Down Expand Up @@ -508,32 +507,24 @@ fn validate_initialization(
and {
factory_reference_script == None,
list.length(value.flatten(out_value)) == 2,
assert(
list.any(
inputs,
fn(input) {
let Input { output_reference, .. } = input
output_reference == out_ref
},
),
@"Must spend @out_ref",
),
assert(
value.flatten(mint_value) == [(factory_policy_id, factory_auth_an, 1)],
@"Must mint 1 Factory Token",
),
assert(
value.quantity_of(out_value, factory_policy_id, factory_auth_an) == 1,
@"Factory Output must contain 1 Factory Token",
// Must spend @out_ref
list.any(
inputs,
fn(input) {
let Input { output_reference, .. } = input
output_reference == out_ref
},
),
assert(
datum == InlineDatum(
FactoryDatum {
head: #"00",
tail: #"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00",
},
),
@"Factory Datum must be correct!",
// Must mint 1 Factory Token
value.flatten(mint_value) == [(factory_policy_id, factory_auth_an, 1)],
// Factory Output must contain 1 Factory Token
value.quantity_of(out_value, factory_policy_id, factory_auth_an) == 1,
// Factory Datum must be correct!
datum == InlineDatum(
FactoryDatum {
head: #"00",
tail: #"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00",
},
),
}
}
Expand Down
Loading