Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
elRaulito committed Aug 20, 2024
1 parent 43094e1 commit b877e83
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions validators/feetank.ak
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Datum {
whitelistedAddresses: List<Address>,
exectutionTime: PosixTime,
destionationaAddress: Address,
scheduledAmount: CardanoToken,
reward: CardanoToken,
}

Expand Down Expand Up @@ -124,8 +125,24 @@ validator {

Withdraw -> must_be_signed_by(ctx.transaction, datum.tankOwner)

ScheduledTransaction ->
isWhitelisted(ctx.transaction, datum.whitelistedAddresses)
ScheduledTransaction -> {
expect Some(outputScheduled) = list.at(ctx.transaction.outputs, 0)
let outputPaymentAmount =
quantity_of(
outputScheduled.value,
datum.scheduledAmount.policyId,
datum.scheduledAmount.assetName,
)
and {
validate_scheduled_output(
outputScheduled,
outputPaymentAmount,
datum.scheduledAmount,
datum.destionationaAddress,
),
isWhitelisted(ctx.transaction, datum.whitelistedAddresses),
}
}
}

// Controlla se almeno uno è firmato
Expand Down Expand Up @@ -197,3 +214,18 @@ fn isWhitelisted(transaction: Transaction, whitelistedAddresses: List<Address>)
True
}
}

//Here is all scheduled new functions

fn validate_scheduled_output(
outputPayment: Output,
outputPaymentAmount: Int,
scheduledAmount: CardanoToken,
receiver: Address,
) {
and {
scheduledAmount.amount / scheduledAmount.divider == outputPaymentAmount,
outputPayment.address == receiver,
check_dos_protection(outputPayment.value),
}
}

0 comments on commit b877e83

Please sign in to comment.