Skip to content

Commit e065f6d

Browse files
committed
Add V3.TransactionHash
1 parent 0426110 commit e065f6d

File tree

4 files changed

+311
-11
lines changed

4 files changed

+311
-11
lines changed

plutus-ledger-api/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plutus-ledger-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "plutus-ledger-api"
3-
version = "3.0.1-beta"
3+
version = "3.0.1-beta.2"
44
edition = "2021"
55
license = "Apache-2.0"
66
description = "Plutus Ledger types and utilities implemented in Rust"

plutus-ledger-api/src/generators/correct/v3.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::{
1414
primitive::arb_integer,
1515
v1::{
1616
arb_currency_symbol, arb_datum, arb_ed25519_pub_key_hash, arb_lovelace,
17-
arb_payment_pub_key_hash, arb_stake_pub_key_hash, arb_transaction_input,
17+
arb_payment_pub_key_hash, arb_stake_pub_key_hash,
1818
},
1919
},
2020
v3::{
@@ -23,21 +23,34 @@ use crate::{
2323
ChangedParameters, ColdCommitteeCredential, Committee, Constitution, DRep,
2424
DRepCredential, Delegatee, GovernanceAction, GovernanceActionId,
2525
HotCommitteeCredential, ProposalProcedure, ProtocolVersion, ScriptContext, ScriptInfo,
26-
ScriptPurpose, TransactionInfo, TxCert, Vote, Voter,
26+
ScriptPurpose, TransactionHash, TransactionInfo, TransactionInput, TxCert, TxInInfo,
27+
Vote, Voter,
2728
},
2829
},
2930
};
3031

3132
use super::{
3233
primitive::arb_natural,
3334
v1::{
34-
arb_assoc_map, arb_credential, arb_datum_hash, arb_plutus_data,
35-
arb_plutus_interval_posix_time, arb_redeemer, arb_script_hash, arb_transaction_hash,
36-
arb_value,
35+
arb_assoc_map, arb_credential, arb_datum_hash, arb_ledger_bytes, arb_plutus_data,
36+
arb_plutus_interval_posix_time, arb_redeemer, arb_script_hash, arb_value,
3737
},
38-
v2::{arb_transaction_output, arb_tx_in_info},
38+
v2::arb_transaction_output,
3939
};
4040

41+
/// Strategy to generate a transaction hash
42+
pub fn arb_transaction_hash() -> impl Strategy<Value = TransactionHash> {
43+
arb_ledger_bytes(32).prop_map(TransactionHash)
44+
}
45+
46+
/// Strategy to generate a transaction input
47+
pub fn arb_transaction_input() -> impl Strategy<Value = TransactionInput> {
48+
(arb_transaction_hash(), arb_natural(1)).prop_map(|(transaction_id, index)| TransactionInput {
49+
transaction_id,
50+
index,
51+
})
52+
}
53+
4154
/// Strategy to generate cold committee credentials
4255
pub fn arb_cold_committee_credential() -> impl Strategy<Value = ColdCommitteeCredential> {
4356
arb_credential().prop_map(ColdCommitteeCredential)
@@ -280,6 +293,12 @@ pub fn arb_transaction_info() -> impl Strategy<Value = TransactionInfo> {
280293
)
281294
}
282295

296+
/// Strategy to generate a TxInInfo
297+
pub fn arb_tx_in_info() -> impl Strategy<Value = TxInInfo> {
298+
(arb_transaction_input(), arb_transaction_output())
299+
.prop_map(|(reference, output)| TxInInfo { reference, output })
300+
}
301+
283302
/// Strategy to generate script contexts
284303
pub fn arb_script_context() -> impl Strategy<Value = ScriptContext> {
285304
(arb_transaction_info(), arb_redeemer(), arb_script_info()).prop_map(

0 commit comments

Comments
 (0)