parent
50c37c7a14
commit
d18caaeecb
|
@ -359,6 +359,7 @@ where
|
||||||
&self,
|
&self,
|
||||||
title: Option<&String>,
|
title: Option<&String>,
|
||||||
stake_address: Option<&String>,
|
stake_address: Option<&String>,
|
||||||
|
mainnet: bool,
|
||||||
) -> Result<ShelleyAddress, Error> {
|
) -> Result<ShelleyAddress, Error> {
|
||||||
// Parse stake address
|
// Parse stake address
|
||||||
let stake_address = stake_address
|
let stake_address = stake_address
|
||||||
|
@ -398,9 +399,15 @@ where
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
Err(blueprint::error::Error::ParameterizedValidator { n }.into())
|
Err(blueprint::error::Error::ParameterizedValidator { n }.into())
|
||||||
} else {
|
} else {
|
||||||
|
let network = if mainnet {
|
||||||
|
Network::Mainnet
|
||||||
|
} else {
|
||||||
|
Network::Testnet
|
||||||
|
};
|
||||||
|
|
||||||
Ok(validator
|
Ok(validator
|
||||||
.program
|
.program
|
||||||
.address(Network::Testnet, delegation_part.to_owned()))
|
.address(network, delegation_part.to_owned()))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,10 @@ pub struct Args {
|
||||||
/// Force the project to be rebuilt, otherwise relies on existing artifacts (i.e. plutus.json)
|
/// Force the project to be rebuilt, otherwise relies on existing artifacts (i.e. plutus.json)
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
rebuild: bool,
|
rebuild: bool,
|
||||||
|
|
||||||
|
/// Output the address for mainnet (this command defaults to testnet)
|
||||||
|
#[clap(long)]
|
||||||
|
mainnet: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exec(
|
pub fn exec(
|
||||||
|
@ -32,6 +36,7 @@ pub fn exec(
|
||||||
validator,
|
validator,
|
||||||
delegated_to,
|
delegated_to,
|
||||||
rebuild,
|
rebuild,
|
||||||
|
mainnet,
|
||||||
}: Args,
|
}: Args,
|
||||||
) -> miette::Result<()> {
|
) -> miette::Result<()> {
|
||||||
with_project(directory.as_deref(), false, |p| {
|
with_project(directory.as_deref(), false, |p| {
|
||||||
|
@ -51,7 +56,7 @@ pub fn exec(
|
||||||
|
|
||||||
let title = title.as_ref().or(validator.as_ref());
|
let title = title.as_ref().or(validator.as_ref());
|
||||||
|
|
||||||
let address = p.address(title, delegated_to.as_ref())?;
|
let address = p.address(title, delegated_to.as_ref(), mainnet)?;
|
||||||
|
|
||||||
println!("{}", address.to_bech32().unwrap());
|
println!("{}", address.to_bech32().unwrap());
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ pub fn exec(
|
||||||
|
|
||||||
let title = title.as_ref().or(validator.as_ref());
|
let title = title.as_ref().or(validator.as_ref());
|
||||||
|
|
||||||
let address = p.address(title, None)?;
|
let address = p.address(title, None, false)?;
|
||||||
|
|
||||||
println!("{}", address.payment().to_hex());
|
println!("{}", address.payment().to_hex());
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,9 @@ 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) -> 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 = babbage::PlutusV2Script(cbor.into()).compute_hash();
|
||||||
|
|
||||||
ShelleyAddress::new(
|
ShelleyAddress::new(
|
||||||
network,
|
network,
|
||||||
ShelleyPaymentPart::Script(validator_hash),
|
ShelleyPaymentPart::Script(validator_hash),
|
||||||
|
|
Loading…
Reference in New Issue