feat: use plutus version in address command

relates to #907
This commit is contained in:
rvcas 2024-05-21 17:04:25 -04:00
parent 3bc3792aa3
commit f306f1715a
No known key found for this signature in database
GPG Key ID: C09B64E263F7D68C
2 changed files with 16 additions and 5 deletions

View File

@ -434,9 +434,11 @@ where
Network::Testnet Network::Testnet
}; };
Ok(validator Ok(validator.program.address(
.program network,
.address(network, delegation_part.to_owned())) delegation_part.to_owned(),
&self.config.plutus_version.into(),
))
} }
}) })
} }

View File

@ -177,10 +177,19 @@ impl<'a> Deserialize<'a> for Program<DeBruijn> {
} }
impl Program<DeBruijn> { impl Program<DeBruijn> {
pub fn address(&self, network: Network, delegation: ShelleyDelegationPart) -> ShelleyAddress { pub fn address(
&self,
network: Network,
delegation: ShelleyDelegationPart,
plutus_version: &Language,
) -> ShelleyAddress {
let cbor = self.to_cbor().unwrap(); let cbor = self.to_cbor().unwrap();
let validator_hash = babbage::PlutusV2Script(cbor.into()).compute_hash(); let validator_hash = match plutus_version {
Language::PlutusV1 => conway::PlutusV1Script(cbor.into()).compute_hash(),
Language::PlutusV2 => conway::PlutusV2Script(cbor.into()).compute_hash(),
Language::PlutusV3 => conway::PlutusV3Script(cbor.into()).compute_hash(),
};
ShelleyAddress::new( ShelleyAddress::new(
network, network,