plutus_ledger_api/goldens/
v2.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Golden test data or Plutus V2 types

use num_bigint::BigInt;

pub use super::v1::{
    sample_address, sample_asset_class, sample_chain_pointer, sample_credential,
    sample_currency_symbol, sample_datum, sample_datum_hash, sample_dcert,
    sample_ed25519_pub_key_hash, sample_payment_pub_key_hash, sample_plutus_data,
    sample_plutus_interval, sample_redeemer, sample_redeemer_hash, sample_script_hash,
    sample_script_purpose, sample_staking_credential, sample_token_name, sample_transaction_hash,
    sample_transaction_input, sample_value,
};
use crate::v2::{
    assoc_map::AssocMap,
    crypto::LedgerBytes,
    datum::OutputDatum,
    script::ScriptHash,
    transaction::{ScriptContext, TransactionInfo, TransactionOutput, TxInInfo},
};

pub fn sample_output_datum() -> OutputDatum {
    OutputDatum::InlineDatum(super::v1::sample_datum())
}

pub fn sample_transaction_output() -> TransactionOutput {
    TransactionOutput {
        address: super::v1::sample_address(),
        value: super::v1::sample_value(),
        datum: sample_output_datum(),
        reference_script: Some(ScriptHash(LedgerBytes([0].repeat(28).to_vec()))),
    }
}

pub fn sample_tx_in_info() -> TxInInfo {
    TxInInfo {
        reference: super::v1::sample_transaction_input(),
        output: sample_transaction_output(),
    }
}

pub fn sample_transaction_info() -> TransactionInfo {
    TransactionInfo {
        inputs: vec![sample_tx_in_info()],
        outputs: vec![sample_transaction_output()],
        fee: super::v1::sample_value(),
        mint: super::v1::sample_value(),
        d_cert: vec![super::v1::sample_dcert()],
        wdrl: AssocMap::from([(super::v1::sample_staking_credential(), BigInt::from(12))]),
        valid_range: super::v1::sample_plutus_interval(),
        signatories: vec![super::v1::sample_payment_pub_key_hash()],
        datums: AssocMap::from([(super::v1::sample_datum_hash(), super::v1::sample_datum())]),
        redeemers: AssocMap::from([(
            super::v1::sample_script_purpose(),
            super::v1::sample_redeemer(),
        )]),
        id: super::v1::sample_transaction_hash(),
        reference_inputs: vec![sample_tx_in_info()],
    }
}

pub fn sample_script_context() -> ScriptContext {
    ScriptContext {
        tx_info: sample_transaction_info(),
        purpose: super::v1::sample_script_purpose(),
    }
}