Skip to content

Commit b22bfba

Browse files
authored
Merge pull request #64 from mlabs-haskell/szg251/missing-derive-macros
Add missing derive macros + implement some v3 goldens
2 parents 42d6ed0 + a7108f7 commit b22bfba

File tree

7 files changed

+76
-7
lines changed

7 files changed

+76
-7
lines changed

plutus-ledger-api/Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plutus-ledger-api/Cargo.toml

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

plutus-ledger-api/src/goldens/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
//! Golden test data
22
pub mod v1;
33
pub mod v2;
4+
pub mod v3;

plutus-ledger-api/src/goldens/v2.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
//! Golden test data or Plutus V2 types
2+
3+
use num_bigint::BigInt;
4+
25
pub use super::v1::{
36
sample_address, sample_asset_class, sample_chain_pointer, sample_credential,
47
sample_currency_symbol, sample_datum, sample_datum_hash, sample_dcert,
@@ -14,7 +17,6 @@ use crate::v2::{
1417
script::ScriptHash,
1518
transaction::{ScriptContext, TransactionInfo, TransactionOutput, TxInInfo},
1619
};
17-
use num_bigint::BigInt;
1820

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

plutus-ledger-api/src/goldens/v3.rs

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//! Golden test data or Plutus V3 types (incomplete)
2+
use num_bigint::BigInt;
3+
4+
pub use super::v2::{
5+
sample_address, sample_asset_class, sample_chain_pointer, sample_credential,
6+
sample_currency_symbol, sample_datum, sample_datum_hash, sample_dcert,
7+
sample_ed25519_pub_key_hash, sample_output_datum, sample_payment_pub_key_hash,
8+
sample_plutus_data, sample_plutus_interval, sample_redeemer, sample_redeemer_hash,
9+
sample_script_hash, sample_staking_credential, sample_token_name, sample_transaction_output,
10+
sample_value,
11+
};
12+
use crate::v3::{
13+
crypto::LedgerBytes,
14+
transaction::{
15+
ColdCommitteeCredential, DRepCredential, HotCommitteeCredential, TransactionHash,
16+
TransactionInput, TxInInfo,
17+
},
18+
};
19+
20+
pub fn sample_transaction_hash() -> TransactionHash {
21+
TransactionHash(LedgerBytes([0].repeat(32).to_vec()))
22+
}
23+
24+
pub fn sample_transaction_input() -> TransactionInput {
25+
TransactionInput {
26+
transaction_id: sample_transaction_hash(),
27+
index: BigInt::from(3),
28+
}
29+
}
30+
31+
pub fn sample_tx_in_info() -> TxInInfo {
32+
TxInInfo {
33+
reference: sample_transaction_input(),
34+
output: sample_transaction_output(),
35+
}
36+
}
37+
38+
pub fn sample_cold_committee_credential() -> ColdCommitteeCredential {
39+
ColdCommitteeCredential(sample_credential())
40+
}
41+
42+
pub fn sample_hot_committee_credential() -> HotCommitteeCredential {
43+
HotCommitteeCredential(sample_credential())
44+
}
45+
46+
pub fn sample_drep_committee_credential() -> DRepCredential {
47+
DRepCredential(sample_credential())
48+
}
49+
50+
// TODO(szg251): Missing implementations
51+
// DRep
52+
// Delegatee
53+
// TxCert
54+
// Vote
55+
// Voter
56+
// GovernanceActionId
57+
// Committee
58+
// Constitution
59+
// ProtocolVersion
60+
// ChangedParameters
61+
// GovernanceAction
62+
// ProposalProcedure
63+
// ScriptPurpose
64+
// ScriptInfo
65+
// TransactionInfo
66+
// ScriptContext

plutus-ledger-api/src/v1/assoc_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::plutus_data::{IsPlutusData, PlutusData, PlutusDataError, PlutusType};
1212
// AssocMap //
1313
//////////////
1414

15-
#[derive(Debug, PartialEq, Eq, Clone, Default)]
15+
#[derive(Debug, PartialEq, Eq, Clone, Default, PartialOrd, Ord, Hash)]
1616
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
1717
pub struct AssocMap<K, V>(pub Vec<(K, V)>);
1818

plutus-ledger-api/src/v3/transaction.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pub struct ChangedParameters(pub PlutusData);
407407
// GovernanceAction //
408408
//////////////////////
409409

410-
#[derive(Clone, Debug, PartialEq, Eq, IsPlutusData)]
410+
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, IsPlutusData)]
411411
#[is_plutus_data_derive_strategy = "Constr"]
412412
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
413413
#[cfg_attr(feature = "lbf", derive(Json))]
@@ -448,7 +448,7 @@ pub enum GovernanceAction {
448448
// ProposalProcedure //
449449
///////////////////////
450450

451-
#[derive(Clone, Debug, PartialEq, Eq, IsPlutusData)]
451+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Hash, IsPlutusData)]
452452
#[is_plutus_data_derive_strategy = "Constr"]
453453
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
454454
#[cfg_attr(feature = "lbf", derive(Json))]
@@ -462,7 +462,7 @@ pub struct ProposalProcedure {
462462
// ScriptPurpose //
463463
///////////////////
464464

465-
#[derive(Clone, Debug, PartialEq, Eq, IsPlutusData)]
465+
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Hash, IsPlutusData)]
466466
#[is_plutus_data_derive_strategy = "Constr"]
467467
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
468468
#[cfg_attr(feature = "lbf", derive(Json))]

0 commit comments

Comments
 (0)