Fix remaining acceptance tests to be V3-compatible
This commit is contained in:
@@ -3,14 +3,14 @@
|
||||
|
||||
[[requirements]]
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "main"
|
||||
version = "v2"
|
||||
source = "github"
|
||||
|
||||
[[packages]]
|
||||
name = "aiken-lang/stdlib"
|
||||
version = "main"
|
||||
version = "v2"
|
||||
requirements = []
|
||||
source = "github"
|
||||
|
||||
[etags]
|
||||
"aiken-lang/stdlib@main" = [{ secs_since_epoch = 1714852860, nanos_since_epoch = 160588000 }, "5ee55dc5ccf269bb493f4cacb32096f0191a6adb2ef39d62a1f79b8c5a8fcc7f"]
|
||||
"aiken-lang/stdlib@v2" = [{ secs_since_epoch = 1724778883, nanos_since_epoch = 61117000 }, "cdbbce58b61deb385e7ea787a2e0fc2dc8fe94db9999e0e6275bc9c70e5796be"]
|
||||
|
||||
@@ -10,5 +10,5 @@ platform = 'github'
|
||||
|
||||
[[dependencies]]
|
||||
name = 'aiken-lang/stdlib'
|
||||
version = 'main'
|
||||
version = 'v2'
|
||||
source = 'github'
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
use aiken/builtin
|
||||
use aiken/bytearray
|
||||
use aiken/dict
|
||||
use aiken/collection/dict
|
||||
use aiken/collection/list
|
||||
use aiken/hash.{blake2b_256}
|
||||
use aiken/list
|
||||
use aiken/transaction.{
|
||||
InlineDatum, Input, Output, ScriptContext, Spend, Transaction,
|
||||
use aiken/primitive/bytearray
|
||||
use cardano/assets.{PolicyId}
|
||||
use cardano/credential.{Address, PaymentCredential, Script}
|
||||
use cardano/transaction.{
|
||||
InlineDatum, Input, Output, OutputReference, Transaction,
|
||||
} as tx
|
||||
use aiken/transaction/credential.{Address, PaymentCredential, ScriptCredential}
|
||||
use aiken/transaction/value
|
||||
|
||||
type Action {
|
||||
pub type Action {
|
||||
Mint(Int)
|
||||
Burn
|
||||
}
|
||||
|
||||
type SpendTokenName =
|
||||
pub type SpendTokenName =
|
||||
ByteArray
|
||||
|
||||
validator redeem(creator: ByteArray) {
|
||||
spend(
|
||||
// Each spend input checks for a token name matching the datum being burned
|
||||
datum: SpendTokenName,
|
||||
datum: Option<SpendTokenName>,
|
||||
_r: Data,
|
||||
own_ref: OutputReference,
|
||||
transaction: Transaction,
|
||||
@@ -35,23 +35,22 @@ validator redeem(creator: ByteArray) {
|
||||
..
|
||||
} = own_input
|
||||
|
||||
expect ScriptCredential(own_validator_hash) = payment_credential
|
||||
expect Script(own_validator_hash) = payment_credential
|
||||
expect Some(datum) = datum
|
||||
|
||||
(
|
||||
mint
|
||||
|> value.from_minted_value
|
||||
|> value.quantity_of(own_validator_hash, datum)
|
||||
|> assets.quantity_of(own_validator_hash, datum)
|
||||
) == -1
|
||||
}
|
||||
|
||||
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) -> Bool {
|
||||
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) {
|
||||
let Transaction { inputs, mint, extra_signatories, outputs, .. } =
|
||||
transaction
|
||||
|
||||
let minted_assets =
|
||||
mint
|
||||
|> value.from_minted_value
|
||||
|> value.tokens(policy_id)
|
||||
|> assets.tokens(policy_id)
|
||||
|> dict.to_pairs()
|
||||
|
||||
when rdmr is {
|
||||
@@ -75,7 +74,7 @@ validator redeem(creator: ByteArray) {
|
||||
minted_assets,
|
||||
outputs,
|
||||
expected_minted_token_names,
|
||||
ScriptCredential(policy_id),
|
||||
Script(policy_id),
|
||||
)
|
||||
}
|
||||
Burn ->
|
||||
@@ -88,6 +87,10 @@ validator redeem(creator: ByteArray) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
else(_) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
fn insert(self: List<a>, e: a, compare: fn(a, a) -> Ordering) -> List<a> {
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
use aiken/dict
|
||||
use aiken/list
|
||||
use aiken/transaction.{OutputReference, ScriptContext, Transaction} as tx
|
||||
use aiken/transaction/value
|
||||
use aiken/collection/dict
|
||||
use aiken/collection/list
|
||||
use cardano/assets.{PolicyId}
|
||||
use cardano/transaction.{OutputReference, Transaction} as tx
|
||||
|
||||
type Action {
|
||||
pub type Action {
|
||||
Mint
|
||||
Burn
|
||||
}
|
||||
|
||||
validator gift_card(token_name: ByteArray, utxo_ref: OutputReference) {
|
||||
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) -> Bool {
|
||||
mint(rdmr: Action, policy_id: PolicyId, transaction: Transaction) {
|
||||
let Transaction { inputs, mint, .. } = transaction
|
||||
|
||||
expect [Pair(asset_name, amount)] =
|
||||
mint
|
||||
|> value.from_minted_value
|
||||
|> value.tokens(policy_id)
|
||||
|> assets.tokens(policy_id)
|
||||
|> dict.to_pairs()
|
||||
|
||||
when rdmr is {
|
||||
@@ -28,18 +27,25 @@ validator gift_card(token_name: ByteArray, utxo_ref: OutputReference) {
|
||||
Burn -> amount == -1 && asset_name == token_name
|
||||
}
|
||||
}
|
||||
|
||||
else(_) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
validator redeem(token_name: ByteArray, policy_id: ByteArray) {
|
||||
spend(_d: Data, _r: Data, _o_ref: Data, transaction: Transaction) -> Bool {
|
||||
spend(_d, _r, _o_ref: Data, transaction: Transaction) {
|
||||
let Transaction { mint, .. } = transaction
|
||||
|
||||
expect [Pair(asset_name, amount)] =
|
||||
mint
|
||||
|> value.from_minted_value
|
||||
|> value.tokens(policy_id)
|
||||
|> assets.tokens(policy_id)
|
||||
|> dict.to_pairs()
|
||||
|
||||
amount == -1 && asset_name == token_name
|
||||
}
|
||||
|
||||
else(_) {
|
||||
fail
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user