fixed bugs
This commit is contained in:
commit
3eb4fb7523
|
@ -459,7 +459,7 @@ impl Value {
|
||||||
}
|
}
|
||||||
Constant::ByteString(b) => {
|
Constant::ByteString(b) => {
|
||||||
if b.is_empty() {
|
if b.is_empty() {
|
||||||
0
|
1
|
||||||
} else {
|
} else {
|
||||||
((b.len() as i64 - 1) / 8) + 1
|
((b.len() as i64 - 1) / 8) + 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ use super::{
|
||||||
ResolvedInput, ScriptContext, ScriptPurpose, SlotConfig, TimeRange, TxInInfo, TxInfo,
|
ResolvedInput, ScriptContext, ScriptPurpose, SlotConfig, TimeRange, TxInInfo, TxInfo,
|
||||||
TxInfoV1, TxInfoV2, TxOut,
|
TxInfoV1, TxInfoV2, TxOut,
|
||||||
},
|
},
|
||||||
to_plutus_data::ToPlutusData,
|
to_plutus_data::{MintValue, ToPlutusData},
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ fn get_tx_info_v1(
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
fee,
|
fee,
|
||||||
mint,
|
mint: MintValue { mint_value: mint },
|
||||||
dcert,
|
dcert,
|
||||||
wdrl,
|
wdrl,
|
||||||
valid_range,
|
valid_range,
|
||||||
|
@ -363,7 +363,7 @@ fn get_tx_info_v2(
|
||||||
reference_inputs,
|
reference_inputs,
|
||||||
outputs,
|
outputs,
|
||||||
fee,
|
fee,
|
||||||
mint,
|
mint: MintValue { mint_value: mint },
|
||||||
dcert,
|
dcert,
|
||||||
wdrl,
|
wdrl,
|
||||||
valid_range,
|
valid_range,
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
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, Mint, PlutusData, PolicyId, Redeemer, RewardAccount,
|
AddrKeyhash, Certificate, Coin, DatumHash, PlutusData, PolicyId, Redeemer, RewardAccount,
|
||||||
StakeCredential, TransactionInput, TransactionOutput, Value, Withdrawals,
|
StakeCredential, TransactionInput, TransactionOutput, Value, Withdrawals,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
use super::to_plutus_data::MintValue;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
||||||
pub struct ResolvedInput {
|
pub struct ResolvedInput {
|
||||||
pub input: TransactionInput,
|
pub input: TransactionInput,
|
||||||
|
@ -36,7 +38,7 @@ pub struct TxInfoV1 {
|
||||||
pub inputs: Vec<TxInInfo>,
|
pub inputs: Vec<TxInInfo>,
|
||||||
pub outputs: Vec<TxOut>,
|
pub outputs: Vec<TxOut>,
|
||||||
pub fee: Value,
|
pub fee: Value,
|
||||||
pub mint: Mint,
|
pub mint: MintValue,
|
||||||
pub dcert: Vec<Certificate>,
|
pub dcert: Vec<Certificate>,
|
||||||
pub wdrl: Vec<(RewardAccount, Coin)>,
|
pub wdrl: Vec<(RewardAccount, Coin)>,
|
||||||
pub valid_range: TimeRange,
|
pub valid_range: TimeRange,
|
||||||
|
@ -51,7 +53,7 @@ pub struct TxInfoV2 {
|
||||||
pub reference_inputs: Vec<TxInInfo>,
|
pub reference_inputs: Vec<TxInInfo>,
|
||||||
pub outputs: Vec<TxOut>,
|
pub outputs: Vec<TxOut>,
|
||||||
pub fee: Value,
|
pub fee: Value,
|
||||||
pub mint: Mint,
|
pub mint: MintValue,
|
||||||
pub dcert: Vec<Certificate>,
|
pub dcert: Vec<Certificate>,
|
||||||
pub wdrl: Withdrawals,
|
pub wdrl: Withdrawals,
|
||||||
pub valid_range: TimeRange,
|
pub valid_range: TimeRange,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,9 @@
|
||||||
use pallas_addresses::{Address, ShelleyDelegationPart, ShelleyPaymentPart};
|
use pallas_addresses::{Address, ShelleyDelegationPart, ShelleyPaymentPart};
|
||||||
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, PlutusData, ScriptRef};
|
use pallas_primitives::babbage::{AssetName, BigInt, Constr, Mint, PlutusData, ScriptRef};
|
||||||
use pallas_primitives::babbage::{
|
use pallas_primitives::babbage::{
|
||||||
Certificate, DatumOption, PolicyId, Redeemer, Script, StakeCredential, TransactionInput,
|
Certificate, DatumOption, Redeemer, Script, StakeCredential, TransactionInput,
|
||||||
TransactionOutput, Value,
|
TransactionOutput, Value,
|
||||||
};
|
};
|
||||||
use pallas_traverse::ComputeHash;
|
use pallas_traverse::ComputeHash;
|
||||||
|
@ -43,6 +43,11 @@ pub trait ToPlutusData {
|
||||||
fn to_plutus_data(&self) -> PlutusData;
|
fn to_plutus_data(&self) -> PlutusData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
pub struct MintValue {
|
||||||
|
pub mint_value: Mint,
|
||||||
|
}
|
||||||
|
|
||||||
impl ToPlutusData for Address {
|
impl ToPlutusData for Address {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
match self {
|
match self {
|
||||||
|
@ -201,7 +206,7 @@ impl ToPlutusData for Value {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
match self {
|
match self {
|
||||||
Value::Coin(coin) => PlutusData::Map(KeyValuePairs::Def(vec![(
|
Value::Coin(coin) => PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||||
PolicyId::from([0; 28]).to_plutus_data(),
|
Bytes::from(vec![]).to_plutus_data(),
|
||||||
PlutusData::Map(KeyValuePairs::Def(vec![(
|
PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||||
AssetName::from(vec![]).to_plutus_data(),
|
AssetName::from(vec![]).to_plutus_data(),
|
||||||
coin.to_plutus_data(),
|
coin.to_plutus_data(),
|
||||||
|
@ -209,7 +214,7 @@ impl ToPlutusData for Value {
|
||||||
)])),
|
)])),
|
||||||
Value::Multiasset(coin, multiassets) => {
|
Value::Multiasset(coin, multiassets) => {
|
||||||
let mut data_vec: Vec<(PlutusData, PlutusData)> = vec![(
|
let mut data_vec: Vec<(PlutusData, PlutusData)> = vec![(
|
||||||
PolicyId::from([0; 28]).to_plutus_data(),
|
Bytes::from(vec![]).to_plutus_data(),
|
||||||
PlutusData::Map(KeyValuePairs::Def(vec![(
|
PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||||
AssetName::from(vec![]).to_plutus_data(),
|
AssetName::from(vec![]).to_plutus_data(),
|
||||||
coin.to_plutus_data(),
|
coin.to_plutus_data(),
|
||||||
|
@ -233,6 +238,31 @@ impl ToPlutusData for Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToPlutusData for MintValue {
|
||||||
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
|
let mut data_vec: Vec<(PlutusData, PlutusData)> = vec![(
|
||||||
|
Bytes::from(vec![]).to_plutus_data(),
|
||||||
|
PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||||
|
AssetName::from(vec![]).to_plutus_data(),
|
||||||
|
0_i64.to_plutus_data(),
|
||||||
|
)])),
|
||||||
|
)];
|
||||||
|
|
||||||
|
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 {
|
impl ToPlutusData for ScriptRef {
|
||||||
fn to_plutus_data(&self) -> PlutusData {
|
fn to_plutus_data(&self) -> PlutusData {
|
||||||
match &self.0 {
|
match &self.0 {
|
||||||
|
|
Loading…
Reference in New Issue