Fixed reward account creation in ScriptContext

This commit is contained in:
alessandrokonrad
2023-01-05 12:26:59 +01:00
committed by Lucas
parent 542962a2ea
commit 3aba9baba5
4 changed files with 21 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
use pallas_addresses::{Address, ShelleyDelegationPart, ShelleyPaymentPart};
use pallas_addresses::{Address, ShelleyDelegationPart, ShelleyPaymentPart, StakePayload};
use pallas_codec::utils::{AnyUInt, Bytes, Int, KeyValuePairs};
use pallas_crypto::hash::Hash;
use pallas_primitives::babbage::{AssetName, BigInt, Constr, Mint, PlutusData, ScriptRef};
@@ -85,6 +85,17 @@ impl ToPlutusData for Address {
wrap_multiple_with_constr(0, vec![payment_part_plutus_data, stake_part_plutus_data])
}
Address::Stake(stake_address) => {
// This is right now only used in Withdrawals (Reward account)
match stake_address.payload() {
StakePayload::Stake(stake_keyhash) => {
StakeCredential::AddrKeyhash(*stake_keyhash).to_plutus_data()
}
StakePayload::Script(script_hash) => {
StakeCredential::Scripthash(*script_hash).to_plutus_data()
}
}
}
_ => unreachable!(),
}
}