Start adjusting acceptance tests to the new Plutus V3 syntax.
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
use aiken/hash.{Blake2b_224, Hash}
|
||||
use aiken/interval.{Finite}
|
||||
use aiken/list
|
||||
use aiken/option
|
||||
use aiken/transaction.{
|
||||
Datum, InlineDatum, Input, Mint, Output, OutputReference, ScriptContext, Spend,
|
||||
Transaction, TransactionId, ValidityRange,
|
||||
use cardano/assets.{
|
||||
AssetName, PolicyId, Value, add, flatten, from_asset, negate, quantity_of,
|
||||
}
|
||||
use aiken/transaction/credential.{
|
||||
use cardano/credential.{
|
||||
Address, Script, ScriptCredential, VerificationKey, VerificationKeyCredential,
|
||||
}
|
||||
use aiken/transaction/value.{
|
||||
AssetName, PolicyId, Value, add, flatten, from_asset, negate, quantity_of,
|
||||
use cardano/hash.{Blake2b_224, Hash}
|
||||
use cardano/transaction.{
|
||||
Datum, InlineDatum, Input, Output, OutputReference, Transaction,
|
||||
TransactionId, ValidityRange,
|
||||
}
|
||||
|
||||
// Datum/Redeemer pool
|
||||
@@ -45,13 +45,13 @@ pub type CurrencySymbol {
|
||||
asset_name: AssetName,
|
||||
}
|
||||
|
||||
pub fn get_output(ctx: ScriptContext, address: Address) -> Option<Output> {
|
||||
list.find(ctx.transaction.outputs, fn(output) { output.address == address })
|
||||
pub fn get_output(transaction: Transaction, address: Address) -> Option<Output> {
|
||||
list.find(transaction.outputs, fn(output) { output.address == address })
|
||||
}
|
||||
|
||||
pub fn get_input(ctx: ScriptContext, address: Address) -> Option<Input> {
|
||||
pub fn get_input(transaction: Transaction, address: Address) -> Option<Input> {
|
||||
list.find(
|
||||
ctx.transaction.inputs,
|
||||
transaction.inputs,
|
||||
fn(input) { input.output.address == address },
|
||||
)
|
||||
}
|
||||
@@ -64,48 +64,40 @@ pub fn scripthash_address(scripthash: ByteArray) {
|
||||
}
|
||||
|
||||
pub fn validate_pool_deposit(
|
||||
ctx: ScriptContext,
|
||||
transaction: Transaction,
|
||||
output_reference: OutputReference,
|
||||
datum: PoolDatum,
|
||||
redeemer: PoolDepositRedeemer,
|
||||
) -> Bool {
|
||||
let validator_address = scripthash_address(#"ff")
|
||||
|
||||
expect Some(pool_output) = get_output(ctx, validator_address)
|
||||
expect Some(pool_input) = get_input(ctx, validator_address)
|
||||
expect Some(pool_output) = get_output(transaction, validator_address)
|
||||
expect Some(pool_input) = get_input(transaction, validator_address)
|
||||
|
||||
True
|
||||
}
|
||||
|
||||
pub fn validate_pool_borrow(
|
||||
ctx: ScriptContext,
|
||||
transaction: Transaction,
|
||||
output_reference: OutputReference,
|
||||
datum: PoolDatum,
|
||||
redeemer: PoolBorrowRedeemer,
|
||||
) -> Bool {
|
||||
let validator_address = scripthash_address(#"ff")
|
||||
|
||||
expect Some(pool_output) = get_output(ctx, validator_address)
|
||||
expect Some(pool_input) = get_input(ctx, validator_address)
|
||||
expect Some(pool_output) = get_output(transaction, validator_address)
|
||||
expect Some(pool_input) = get_input(transaction, validator_address)
|
||||
True
|
||||
}
|
||||
|
||||
validator {
|
||||
fn pool_contract(datum: PoolDatum, redeemer: PoolRedeemer, ctx: ScriptContext) {
|
||||
spend(datum: PoolDatum, redeemer: PoolRedeemer, output_ref: OutputReference, transaction: Transaction) {
|
||||
when redeemer.action is {
|
||||
PoolWithdraw(_) -> True
|
||||
PoolDeposit(pool_deposit_redeemer) ->
|
||||
when ctx.purpose is {
|
||||
Spend(output_ref) ->
|
||||
validate_pool_deposit(ctx, output_ref, datum, pool_deposit_redeemer)
|
||||
_ -> False
|
||||
}
|
||||
validate_pool_deposit(transaction, output_ref, datum, pool_deposit_redeemer)
|
||||
PoolBorrow(pool_borrow_redeemer) ->
|
||||
when ctx.purpose is {
|
||||
Spend(output_ref) ->
|
||||
validate_pool_borrow(ctx, output_ref, datum, pool_borrow_redeemer)
|
||||
_ -> False
|
||||
}
|
||||
validate_pool_borrow(transaction, output_ref, datum, pool_borrow_redeemer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user