Fixed reward account creation in ScriptContext
This commit is contained in:
parent
542962a2ea
commit
3aba9baba5
|
@ -8,7 +8,7 @@ N/A
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
N/A
|
- **uplc**: Reward accounts are now correctly turned into script credentials in ScriptContext.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -312,7 +312,8 @@ fn get_tx_info_v1(
|
||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect();
|
.map(|(reward_account, coin)| (Address::from_bytes(&reward_account).unwrap(), coin))
|
||||||
|
.collect_vec();
|
||||||
|
|
||||||
let valid_range = slot_range_to_posix_time_range(
|
let valid_range = slot_range_to_posix_time_range(
|
||||||
TimeRange {
|
TimeRange {
|
||||||
|
@ -388,6 +389,7 @@ fn get_tx_info_v2(
|
||||||
.clone()
|
.clone()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.sorted()
|
.sorted()
|
||||||
|
.map(|(reward_account, coin)| (Address::from_bytes(&reward_account).unwrap(), coin))
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
use pallas_addresses::Address;
|
||||||
use pallas_codec::utils::KeyValuePairs;
|
use pallas_codec::utils::KeyValuePairs;
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
use pallas_primitives::babbage::{
|
use pallas_primitives::babbage::{
|
||||||
AddrKeyhash, Certificate, Coin, DatumHash, PlutusData, PolicyId, Redeemer, RewardAccount,
|
AddrKeyhash, Certificate, Coin, DatumHash, PlutusData, PolicyId, Redeemer, StakeCredential,
|
||||||
StakeCredential, TransactionInput, TransactionOutput, Value, Withdrawals,
|
TransactionInput, TransactionOutput, Value,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ pub struct TxInfoV1 {
|
||||||
pub fee: Value,
|
pub fee: Value,
|
||||||
pub mint: MintValue,
|
pub mint: MintValue,
|
||||||
pub dcert: Vec<Certificate>,
|
pub dcert: Vec<Certificate>,
|
||||||
pub wdrl: Vec<(RewardAccount, Coin)>,
|
pub wdrl: Vec<(Address, Coin)>,
|
||||||
pub valid_range: TimeRange,
|
pub valid_range: TimeRange,
|
||||||
pub signatories: Vec<AddrKeyhash>,
|
pub signatories: Vec<AddrKeyhash>,
|
||||||
pub data: Vec<(DatumHash, PlutusData)>,
|
pub data: Vec<(DatumHash, PlutusData)>,
|
||||||
|
@ -55,7 +56,7 @@ pub struct TxInfoV2 {
|
||||||
pub fee: Value,
|
pub fee: Value,
|
||||||
pub mint: MintValue,
|
pub mint: MintValue,
|
||||||
pub dcert: Vec<Certificate>,
|
pub dcert: Vec<Certificate>,
|
||||||
pub wdrl: Withdrawals,
|
pub wdrl: KeyValuePairs<Address, Coin>,
|
||||||
pub valid_range: TimeRange,
|
pub valid_range: TimeRange,
|
||||||
pub signatories: Vec<AddrKeyhash>,
|
pub signatories: Vec<AddrKeyhash>,
|
||||||
pub redeemers: KeyValuePairs<ScriptPurpose, Redeemer>,
|
pub redeemers: KeyValuePairs<ScriptPurpose, Redeemer>,
|
||||||
|
|
|
@ -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_codec::utils::{AnyUInt, Bytes, Int, KeyValuePairs};
|
||||||
use pallas_crypto::hash::Hash;
|
use pallas_crypto::hash::Hash;
|
||||||
use pallas_primitives::babbage::{AssetName, BigInt, Constr, Mint, PlutusData, ScriptRef};
|
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])
|
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!(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue