change how mint gets converted to plutus data
This commit is contained in:
parent
c45643bb01
commit
3bb5826b91
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
ast::{FakeNamedDeBruijn, NamedDeBruijn, Program},
|
||||
ast::{DeBruijn, FakeNamedDeBruijn, NamedDeBruijn, Program},
|
||||
machine::cost_model::ExBudget,
|
||||
PlutusData,
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ use super::{
|
|||
ResolvedInput, ScriptContext, ScriptPurpose, SlotConfig, TimeRange, TxInInfo, TxInfo,
|
||||
TxInfoV1, TxInfoV2, TxOut,
|
||||
},
|
||||
to_plutus_data::ToPlutusData,
|
||||
to_plutus_data::{MintValue, ToPlutusData},
|
||||
Error,
|
||||
};
|
||||
|
||||
|
@ -286,7 +286,7 @@ fn get_tx_info_v1(
|
|||
inputs,
|
||||
outputs,
|
||||
fee,
|
||||
mint,
|
||||
mint: MintValue { mint_value: mint },
|
||||
dcert,
|
||||
wdrl,
|
||||
valid_range,
|
||||
|
@ -363,7 +363,7 @@ fn get_tx_info_v2(
|
|||
reference_inputs,
|
||||
outputs,
|
||||
fee,
|
||||
mint,
|
||||
mint: MintValue { mint_value: mint },
|
||||
dcert,
|
||||
wdrl,
|
||||
valid_range,
|
||||
|
|
|
@ -6,6 +6,8 @@ use pallas_primitives::babbage::{
|
|||
};
|
||||
use serde::Deserialize;
|
||||
|
||||
use super::to_plutus_data::MintValue;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
||||
pub struct ResolvedInput {
|
||||
pub input: TransactionInput,
|
||||
|
@ -36,7 +38,7 @@ pub struct TxInfoV1 {
|
|||
pub inputs: Vec<TxInInfo>,
|
||||
pub outputs: Vec<TxOut>,
|
||||
pub fee: Value,
|
||||
pub mint: Mint,
|
||||
pub mint: MintValue,
|
||||
pub dcert: Vec<Certificate>,
|
||||
pub wdrl: Vec<(RewardAccount, Coin)>,
|
||||
pub valid_range: TimeRange,
|
||||
|
@ -51,7 +53,7 @@ pub struct TxInfoV2 {
|
|||
pub reference_inputs: Vec<TxInInfo>,
|
||||
pub outputs: Vec<TxOut>,
|
||||
pub fee: Value,
|
||||
pub mint: Mint,
|
||||
pub mint: MintValue,
|
||||
pub dcert: Vec<Certificate>,
|
||||
pub wdrl: Withdrawals,
|
||||
pub valid_range: TimeRange,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use pallas_addresses::{Address, ShelleyDelegationPart, ShelleyPaymentPart};
|
||||
use pallas_codec::utils::{AnyUInt, Bytes, Int, KeyValuePairs};
|
||||
use pallas_crypto::hash::Hash;
|
||||
use pallas_primitives::babbage::{AssetName, BigInt, Constr, PlutusData, ScriptRef};
|
||||
use pallas_primitives::babbage::{AssetName, BigInt, Constr, Mint, PlutusData, ScriptRef};
|
||||
use pallas_primitives::babbage::{
|
||||
Certificate, DatumOption, PolicyId, Redeemer, Script, StakeCredential, TransactionInput,
|
||||
TransactionOutput, Value,
|
||||
|
@ -43,6 +43,11 @@ pub trait ToPlutusData {
|
|||
fn to_plutus_data(&self) -> PlutusData;
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct MintValue {
|
||||
pub mint_value: Mint,
|
||||
}
|
||||
|
||||
impl ToPlutusData for Address {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
match self {
|
||||
|
@ -233,6 +238,25 @@ impl ToPlutusData for Value {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPlutusData for MintValue {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
let mut data_vec: Vec<(PlutusData, PlutusData)> = vec![];
|
||||
|
||||
for (policy_id, assets) in self.mint_value.iter() {
|
||||
let mut assets_vec = vec![];
|
||||
for (asset, amount) in assets.iter() {
|
||||
assets_vec.push((asset.to_plutus_data(), amount.to_plutus_data()));
|
||||
}
|
||||
data_vec.push((
|
||||
policy_id.to_plutus_data(),
|
||||
PlutusData::Map(KeyValuePairs::Def(assets_vec)),
|
||||
));
|
||||
}
|
||||
|
||||
PlutusData::Map(KeyValuePairs::Def(data_vec))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPlutusData for ScriptRef {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
match &self.0 {
|
||||
|
|
Loading…
Reference in New Issue