fix: changes from pallas bump
Co-authored-by: Kasey White <kwhitemsg@gmail.com>
This commit is contained in:
parent
336af376e1
commit
348ed3b719
|
@ -291,8 +291,7 @@ checksum = "029d8d0b2f198229de29dca79676f2738ff952edf3fde542eb8bf94d8c21b435"
|
|||
[[package]]
|
||||
name = "pallas-addresses"
|
||||
version = "0.14.0-alpha.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5caad3c874e1b6235c3a27a7e25497289392eabbd977e006863caf8ef3652e57"
|
||||
source = "git+https://github.com/txpipe/pallas#ac25b48797572925ba48ccb0a8f4603410613a75"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"bech32",
|
||||
|
@ -305,8 +304,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "pallas-codec"
|
||||
version = "0.14.0-alpha.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ac4f8895300b80ef2e624373f6421a9cb81523508bc48400f15db7876ec52ea"
|
||||
source = "git+https://github.com/txpipe/pallas#ac25b48797572925ba48ccb0a8f4603410613a75"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"minicbor",
|
||||
|
@ -316,8 +314,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "pallas-crypto"
|
||||
version = "0.14.0-alpha.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2c0a5b31037a97528e10feca6d208a21022f1c6d7837017915a43fae57be99dc"
|
||||
source = "git+https://github.com/txpipe/pallas#ac25b48797572925ba48ccb0a8f4603410613a75"
|
||||
dependencies = [
|
||||
"cryptoxide",
|
||||
"hex",
|
||||
|
@ -330,8 +327,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "pallas-primitives"
|
||||
version = "0.14.0-alpha.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8d2f217857eeccd37ad9fad3cdfc8288d8d2bc41e5c93e7f5f6b3c688873068"
|
||||
source = "git+https://github.com/txpipe/pallas#ac25b48797572925ba48ccb0a8f4603410613a75"
|
||||
dependencies = [
|
||||
"base58",
|
||||
"bech32",
|
||||
|
@ -346,8 +342,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "pallas-traverse"
|
||||
version = "0.14.0-alpha.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4d32519a431ecc6c02507608cee4b75e06518a1cfdfcdd1b13cb7d0b07f638a"
|
||||
source = "git+https://github.com/txpipe/pallas#ac25b48797572925ba48ccb0a8f4603410613a75"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"pallas-addresses",
|
||||
|
@ -679,7 +674,6 @@ dependencies = [
|
|||
"cryptoxide",
|
||||
"flat-rs",
|
||||
"hex",
|
||||
"minicbor",
|
||||
"pallas-codec",
|
||||
"pallas-primitives",
|
||||
"peg",
|
||||
|
|
|
@ -14,11 +14,11 @@ authors = ["Lucas Rosa <x@rvcas.dev>", "Kasey White <kwhitemsg@gmail.com>"]
|
|||
anyhow = "1.0.57"
|
||||
clap = { version = "3.1.14", features = ["derive"] }
|
||||
hex = "0.4.3"
|
||||
pallas-addresses = "0.14.0-alpha.2"
|
||||
pallas-codec = "0.14.0-alpha.2"
|
||||
pallas-crypto = "0.14.0-alpha.2"
|
||||
pallas-primitives = "0.14.0-alpha.2"
|
||||
pallas-traverse = "0.14.0-alpha.2"
|
||||
pallas-addresses = { git = "https://github.com/txpipe/pallas" }
|
||||
pallas-codec = { git = "https://github.com/txpipe/pallas" }
|
||||
pallas-crypto = { git = "https://github.com/txpipe/pallas" }
|
||||
pallas-primitives = { git = "https://github.com/txpipe/pallas" }
|
||||
pallas-traverse = { git = "https://github.com/txpipe/pallas" }
|
||||
serde = { version = "1.0.144", features = ["derive"] }
|
||||
serde_json = "1.0.85"
|
||||
uplc = { path = '../uplc', version = "0.0.12" }
|
||||
|
|
|
@ -2,8 +2,8 @@ use pallas_addresses::{
|
|||
Address, ScriptHash, ShelleyDelegationPart, ShelleyPaymentPart, StakePayload,
|
||||
};
|
||||
use pallas_codec::{
|
||||
minicbor::{bytes::ByteVec, data::Int},
|
||||
utils::{AnyUInt, KeyValuePairs, MaybeIndefArray},
|
||||
minicbor::{bytes::ByteVec},
|
||||
utils::{AnyUInt, KeyValuePairs, MaybeIndefArray, Bytes, Int},
|
||||
};
|
||||
use pallas_crypto::hash::{Hash, Hasher};
|
||||
use pallas_primitives::{
|
||||
|
@ -13,9 +13,9 @@ use pallas_primitives::{
|
|||
Redeemer, RedeemerTag, RewardAccount, Script, ScriptRef, StakeCredential, TransactionInput,
|
||||
TransactionOutput, Tx, Value, Withdrawals,
|
||||
},
|
||||
Fragment, ToHash,
|
||||
Fragment,
|
||||
};
|
||||
use pallas_traverse::{Era, MultiEraTx};
|
||||
use pallas_traverse::{Era, MultiEraTx, OriginalHash, ComputeHash};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
|
@ -55,7 +55,7 @@ pub fn get_tx_in_info_old(resolved_inputs: &[ResolvedInputOld]) -> anyhow::Resul
|
|||
let tx_out = PlutusData::Constr(Constr {
|
||||
tag: 0,
|
||||
any_constructor: None,
|
||||
fields: MaybeIndefArray::Indef(vec![
|
||||
fields: vec![
|
||||
// txOutAddress
|
||||
address.to_plutus_data(),
|
||||
// txOutValue
|
||||
|
@ -73,7 +73,7 @@ pub fn get_tx_in_info_old(resolved_inputs: &[ResolvedInputOld]) -> anyhow::Resul
|
|||
PlutusData::BoundedBytes(
|
||||
token.0.as_bytes().to_vec().into(),
|
||||
),
|
||||
PlutusData::BigInt(BigInt::Int((*token.1).into())),
|
||||
PlutusData::BigInt(BigInt::Int((*token.1 as i64).into())),
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
|
@ -82,13 +82,13 @@ pub fn get_tx_in_info_old(resolved_inputs: &[ResolvedInputOld]) -> anyhow::Resul
|
|||
})
|
||||
.collect(),
|
||||
)),
|
||||
]),
|
||||
],
|
||||
});
|
||||
|
||||
tx_in_info.push(PlutusData::Constr(Constr {
|
||||
tag: 0,
|
||||
any_constructor: None,
|
||||
fields: MaybeIndefArray::Indef(vec![tx_out_ref, tx_out]),
|
||||
fields: vec![tx_out_ref, tx_out],
|
||||
}));
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ fn wrap_with_constr(index: u64, data: PlutusData) -> PlutusData {
|
|||
PlutusData::Constr(Constr {
|
||||
tag: constr_index(index),
|
||||
any_constructor: None,
|
||||
fields: MaybeIndefArray::Indef(vec![data]),
|
||||
fields: vec![data],
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ fn wrap_multiple_with_constr(index: u64, data: Vec<PlutusData>) -> PlutusData {
|
|||
PlutusData::Constr(Constr {
|
||||
tag: constr_index(index),
|
||||
any_constructor: None,
|
||||
fields: MaybeIndefArray::Indef(data),
|
||||
fields: data,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ fn empty_constr(index: u64) -> PlutusData {
|
|||
PlutusData::Constr(Constr {
|
||||
tag: constr_index(index),
|
||||
any_constructor: None,
|
||||
fields: MaybeIndefArray::Indef(vec![]),
|
||||
fields: vec![],
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ impl ToPlutusData for TransactionInput {
|
|||
0,
|
||||
vec![
|
||||
wrap_with_constr(0, self.transaction_id.to_plutus_data()),
|
||||
PlutusData::BigInt(BigInt::Int(self.index.into())),
|
||||
PlutusData::BigInt(BigInt::Int((self.index as i64).into())),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ impl<const BYTES: usize> ToPlutusData for Hash<BYTES> {
|
|||
}
|
||||
}
|
||||
|
||||
impl ToPlutusData for ByteVec {
|
||||
impl ToPlutusData for Bytes {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
PlutusData::BoundedBytes(self.clone())
|
||||
}
|
||||
|
@ -202,15 +202,15 @@ impl<K: ToPlutusData, V: ToPlutusData> ToPlutusData for (K, V) {
|
|||
}
|
||||
}
|
||||
|
||||
impl<A: ToPlutusData> ToPlutusData for MaybeIndefArray<A> {
|
||||
impl<A> ToPlutusData for Vec<A> where A: ToPlutusData {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
PlutusData::Array(MaybeIndefArray::Indef(
|
||||
PlutusData::Array(
|
||||
self.iter().map(|p| p.to_plutus_data()).collect(),
|
||||
))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl<K: ToPlutusData, V: ToPlutusData> ToPlutusData for KeyValuePairs<K, V> {
|
||||
impl<K, V> ToPlutusData for KeyValuePairs<K, V> where K: ToPlutusData + Clone, V: ToPlutusData + Clone {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
let mut data_vec: Vec<(PlutusData, PlutusData)> = vec![];
|
||||
for (key, value) in self.iter() {
|
||||
|
@ -246,11 +246,11 @@ impl ToPlutusData for Option<DatumOption> {
|
|||
impl ToPlutusData for AnyUInt {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
match self {
|
||||
AnyUInt::U8(u8) => PlutusData::BigInt(BigInt::Int(Int::from(*u8))),
|
||||
AnyUInt::U16(u16) => PlutusData::BigInt(BigInt::Int(Int::from(*u16))),
|
||||
AnyUInt::U32(u32) => PlutusData::BigInt(BigInt::Int(Int::from(*u32))),
|
||||
AnyUInt::U64(u64) => PlutusData::BigInt(BigInt::Int(Int::from(*u64))),
|
||||
AnyUInt::MajorByte(u8) => PlutusData::BigInt(BigInt::Int(Int::from(*u8))), // is this correct? I don't know exactly what is does
|
||||
AnyUInt::U8(n) => PlutusData::BigInt(BigInt::Int(Int::from(*n as i64))),
|
||||
AnyUInt::U16(n) => PlutusData::BigInt(BigInt::Int(Int::from(*n as i64))),
|
||||
AnyUInt::U32(n) => PlutusData::BigInt(BigInt::Int(Int::from(*n as i64))),
|
||||
AnyUInt::U64(n) => PlutusData::BigInt(BigInt::Int(Int::from(*n as i64))),
|
||||
AnyUInt::MajorByte(n) => PlutusData::BigInt(BigInt::Int(Int::from(*n as i64))), // is this correct? I don't know exactly what is does
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ impl ToPlutusData for i64 {
|
|||
|
||||
impl ToPlutusData for u64 {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
PlutusData::BigInt(BigInt::Int(Int::from(*self)))
|
||||
PlutusData::BigInt(BigInt::Int(Int::from(*self as i64)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ impl ToPlutusData for Value {
|
|||
fn to_plutus_data(&self) -> PlutusData {
|
||||
match self {
|
||||
Value::Coin(coin) => PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||
PolicyId::from(vec![]).to_plutus_data(),
|
||||
PolicyId::from([0; 28]).to_plutus_data(),
|
||||
PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||
AssetName::from(vec![]).to_plutus_data(),
|
||||
coin.to_plutus_data(),
|
||||
|
@ -291,7 +291,7 @@ impl ToPlutusData for Value {
|
|||
)])),
|
||||
Value::Multiasset(coin, multiassets) => {
|
||||
let mut data_vec: Vec<(PlutusData, PlutusData)> = vec![(
|
||||
PolicyId::from(vec![]).to_plutus_data(),
|
||||
PolicyId::from([0; 28]).to_plutus_data(),
|
||||
PlutusData::Map(KeyValuePairs::Def(vec![(
|
||||
AssetName::from(vec![]).to_plutus_data(),
|
||||
coin.to_plutus_data(),
|
||||
|
@ -318,9 +318,9 @@ impl ToPlutusData for Value {
|
|||
impl ToPlutusData for ScriptRef {
|
||||
fn to_plutus_data(&self) -> PlutusData {
|
||||
match &self.0 {
|
||||
Script::NativeScript(native_script) => native_script.to_hash().to_plutus_data(),
|
||||
Script::PlutusV1Script(plutus_v1) => plutus_v1.to_hash().to_plutus_data(),
|
||||
Script::PlutusV2Script(plutus_v2) => plutus_v2.to_hash().to_plutus_data(),
|
||||
Script::NativeScript(native_script) => native_script.compute_hash().to_plutus_data(),
|
||||
Script::PlutusV1Script(plutus_v1) => plutus_v1.compute_hash().to_plutus_data(),
|
||||
Script::PlutusV2Script(plutus_v2) => plutus_v2.compute_hash().to_plutus_data(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -689,29 +689,29 @@ pub enum ScriptPurpose {
|
|||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct TxInfoV1 {
|
||||
inputs: MaybeIndefArray<TxInInfo>,
|
||||
outputs: MaybeIndefArray<TxOut>,
|
||||
inputs: Vec<TxInInfo>,
|
||||
outputs: Vec<TxOut>,
|
||||
fee: Value,
|
||||
mint: Mint,
|
||||
dcert: MaybeIndefArray<Certificate>,
|
||||
wdrl: MaybeIndefArray<(RewardAccount, Coin)>,
|
||||
dcert: Vec<Certificate>,
|
||||
wdrl: Vec<(RewardAccount, Coin)>,
|
||||
valid_range: TimeRange,
|
||||
signatories: MaybeIndefArray<AddrKeyhash>,
|
||||
data: MaybeIndefArray<(DatumHash, PlutusData)>,
|
||||
signatories: Vec<AddrKeyhash>,
|
||||
data: Vec<(DatumHash, PlutusData)>,
|
||||
id: Hash<32>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct TxInfoV2 {
|
||||
inputs: MaybeIndefArray<TxInInfo>,
|
||||
reference_inputs: MaybeIndefArray<TxInInfo>,
|
||||
outputs: MaybeIndefArray<TxOut>,
|
||||
inputs: Vec<TxInInfo>,
|
||||
reference_inputs: Vec<TxInInfo>,
|
||||
outputs: Vec<TxOut>,
|
||||
fee: Value,
|
||||
mint: Mint,
|
||||
dcert: MaybeIndefArray<Certificate>,
|
||||
dcert: Vec<Certificate>,
|
||||
wdrl: Withdrawals,
|
||||
valid_range: TimeRange,
|
||||
signatories: MaybeIndefArray<AddrKeyhash>,
|
||||
signatories: Vec<AddrKeyhash>,
|
||||
redeemers: KeyValuePairs<ScriptPurpose, Redeemer>,
|
||||
data: KeyValuePairs<DatumHash, PlutusData>,
|
||||
id: Hash<32>,
|
||||
|
@ -777,9 +777,9 @@ struct DataLookupTable {
|
|||
}
|
||||
|
||||
fn get_tx_in_info_v1(
|
||||
inputs: &MaybeIndefArray<TransactionInput>,
|
||||
utxos: &MaybeIndefArray<ResolvedInput>,
|
||||
) -> anyhow::Result<MaybeIndefArray<TxInInfo>> {
|
||||
inputs: &[TransactionInput],
|
||||
utxos: &[ResolvedInput],
|
||||
) -> anyhow::Result<Vec<TxInInfo>> {
|
||||
let result = inputs
|
||||
.iter()
|
||||
.map(|input| {
|
||||
|
@ -822,13 +822,13 @@ fn get_tx_in_info_v1(
|
|||
}
|
||||
})
|
||||
.collect::<Vec<TxInInfo>>();
|
||||
Ok(MaybeIndefArray::Indef(result))
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn get_tx_in_info_v2(
|
||||
inputs: &MaybeIndefArray<TransactionInput>,
|
||||
utxos: &MaybeIndefArray<ResolvedInput>,
|
||||
) -> anyhow::Result<MaybeIndefArray<TxInInfo>> {
|
||||
inputs: &[TransactionInput],
|
||||
utxos: &[ResolvedInput],
|
||||
) -> anyhow::Result<Vec<TxInInfo>> {
|
||||
let result = inputs
|
||||
.iter()
|
||||
.map(|input| {
|
||||
|
@ -856,14 +856,14 @@ fn get_tx_in_info_v2(
|
|||
}
|
||||
})
|
||||
.collect::<Vec<TxInInfo>>();
|
||||
Ok(MaybeIndefArray::Indef(result))
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn get_script_purpose(
|
||||
redeemer: &Redeemer,
|
||||
inputs: &MaybeIndefArray<TransactionInput>,
|
||||
inputs: &[TransactionInput],
|
||||
mint: &Option<Mint>,
|
||||
dcert: &Option<MaybeIndefArray<Certificate>>,
|
||||
dcert: &Option<Vec<Certificate>>,
|
||||
wdrl: &Option<Withdrawals>,
|
||||
) -> anyhow::Result<ScriptPurpose> {
|
||||
// sorting according to specs section 4.1: https://hydra.iohk.io/build/18583827/download/1/alonzo-changes.pdf
|
||||
|
@ -877,7 +877,7 @@ fn get_script_purpose(
|
|||
.unwrap_or(&KeyValuePairs::Indef(vec![]))
|
||||
.iter()
|
||||
.map(|(policy_id, _)| policy_id.clone())
|
||||
.collect::<Vec<ByteVec>>();
|
||||
.collect::<Vec<PolicyId>>();
|
||||
policy_ids.sort();
|
||||
match policy_ids.get(index as usize) {
|
||||
Some(policy_id) => Ok(ScriptPurpose::Minting(policy_id.clone())),
|
||||
|
@ -960,25 +960,26 @@ fn get_tx_info_v1(
|
|||
}
|
||||
|
||||
let inputs = get_tx_in_info_v1(&body.inputs, &utxos)?;
|
||||
let outputs = MaybeIndefArray::Indef(
|
||||
|
||||
let outputs =
|
||||
body.outputs
|
||||
.iter()
|
||||
.map(|output| TxOut::V1(output.clone()))
|
||||
.collect(),
|
||||
);
|
||||
let fee = Value::Coin(AnyUInt::U64(body.fee));
|
||||
.collect();
|
||||
|
||||
let fee = Value::Coin(body.fee);
|
||||
let mint = body.mint.clone().unwrap_or(KeyValuePairs::Indef(vec![]));
|
||||
let dcert = body
|
||||
.certificates
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
let wdrl = MaybeIndefArray::Indef(
|
||||
.unwrap_or(vec![]);
|
||||
let wdrl =
|
||||
body.withdrawals
|
||||
.clone()
|
||||
.unwrap_or(KeyValuePairs::Indef(vec![]))
|
||||
.deref()
|
||||
.clone(),
|
||||
);
|
||||
.clone();
|
||||
|
||||
let valid_range = slot_range_to_posix_time_range(
|
||||
TimeRange {
|
||||
lower_bound: body.validity_interval_start,
|
||||
|
@ -989,17 +990,18 @@ fn get_tx_info_v1(
|
|||
let signatories = body
|
||||
.required_signers
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
let data = MaybeIndefArray::Indef(
|
||||
.unwrap_or(vec![]);
|
||||
|
||||
let data =
|
||||
tx.transaction_witness_set
|
||||
.plutus_data
|
||||
.as_ref()
|
||||
.unwrap_or(&MaybeIndefArray::Indef(vec![]))
|
||||
.unwrap_or(&vec![])
|
||||
.iter()
|
||||
.map(|d| (d.to_hash(), d.clone()))
|
||||
.collect(),
|
||||
);
|
||||
let id = tx.transaction_body.to_hash();
|
||||
.map(|d| (d.original_hash(), d.unwrap()))
|
||||
.collect();
|
||||
|
||||
let id = tx.transaction_body.compute_hash();
|
||||
|
||||
Ok(TxInfo::V1(TxInfoV1 {
|
||||
inputs,
|
||||
|
@ -1027,21 +1029,20 @@ fn get_tx_info_v2(
|
|||
&body
|
||||
.reference_inputs
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![])),
|
||||
.unwrap_or(vec![]),
|
||||
&utxos,
|
||||
)?;
|
||||
let outputs = MaybeIndefArray::Indef(
|
||||
let outputs =
|
||||
body.outputs
|
||||
.iter()
|
||||
.map(|output| TxOut::V2(output.clone()))
|
||||
.collect(),
|
||||
);
|
||||
let fee = Value::Coin(AnyUInt::U64(body.fee));
|
||||
.collect();
|
||||
let fee = Value::Coin(body.fee);
|
||||
let mint = body.mint.clone().unwrap_or(KeyValuePairs::Indef(vec![]));
|
||||
let dcert = body
|
||||
.certificates
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
.unwrap_or(vec![]);
|
||||
let wdrl = body
|
||||
.withdrawals
|
||||
.clone()
|
||||
|
@ -1056,7 +1057,7 @@ fn get_tx_info_v2(
|
|||
let signatories = body
|
||||
.required_signers
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
.unwrap_or(vec![]);
|
||||
let redeemers = KeyValuePairs::Indef(
|
||||
tx.transaction_witness_set
|
||||
.redeemer
|
||||
|
@ -1082,12 +1083,12 @@ fn get_tx_info_v2(
|
|||
tx.transaction_witness_set
|
||||
.plutus_data
|
||||
.as_ref()
|
||||
.unwrap_or(&MaybeIndefArray::Indef(vec![]))
|
||||
.unwrap_or(&vec![])
|
||||
.iter()
|
||||
.map(|d| (d.to_hash(), d.clone()))
|
||||
.map(|d| (d.original_hash(), d.unwrap()))
|
||||
.collect(),
|
||||
);
|
||||
let id = tx.transaction_body.to_hash();
|
||||
let id = tx.transaction_body.compute_hash();
|
||||
|
||||
Ok(TxInfo::V2(TxInfoV2 {
|
||||
inputs,
|
||||
|
@ -1243,42 +1244,30 @@ fn get_script_and_datum_lookup_table(
|
|||
.transaction_witness_set
|
||||
.plutus_data
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
.unwrap_or(vec![]);
|
||||
|
||||
let scripts_v1_witnesses = tx
|
||||
.transaction_witness_set
|
||||
.plutus_v1_script
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
.unwrap_or(vec![]);
|
||||
|
||||
let scripts_v2_witnesses = tx
|
||||
.transaction_witness_set
|
||||
.plutus_v2_script
|
||||
.clone()
|
||||
.unwrap_or(MaybeIndefArray::Indef(vec![]));
|
||||
.unwrap_or(vec![]);
|
||||
|
||||
for plutus_data in plutus_data_witnesses.iter() {
|
||||
datum.insert(plutus_data.to_hash(), plutus_data.clone());
|
||||
datum.insert(plutus_data.original_hash(), plutus_data.clone());
|
||||
}
|
||||
|
||||
for script in scripts_v1_witnesses.iter() {
|
||||
// scripts.insert(script.to_hash(), ScriptVersion::PlutusV1(script.clone())); // TODO: fix hashing bug in pallas
|
||||
|
||||
let mut prefixed_script: Vec<u8> = vec![0x01];
|
||||
prefixed_script.extend(script.0.iter());
|
||||
|
||||
let hash = Hasher::<224>::hash(&prefixed_script);
|
||||
scripts.insert(hash, ScriptVersion::V1(script.clone()));
|
||||
scripts.insert(script.compute_hash(), ScriptVersion::V1(script.clone())); // TODO: fix hashing bug in pallas
|
||||
}
|
||||
|
||||
for script in scripts_v2_witnesses.iter() {
|
||||
// scripts.insert(script.to_hash(), ScriptVersion::PlutusV2(script.clone())); // TODO: fix hashing bug in pallas
|
||||
|
||||
let mut prefixed_script: Vec<u8> = vec![0x02];
|
||||
prefixed_script.extend(script.0.iter());
|
||||
|
||||
let hash = Hasher::<224>::hash(&prefixed_script);
|
||||
scripts.insert(hash, ScriptVersion::V2(script.clone()));
|
||||
scripts.insert(script.compute_hash(), ScriptVersion::V2(script.clone())); // TODO: fix hashing bug in pallas
|
||||
}
|
||||
|
||||
// discovery in utxos (script ref)
|
||||
|
|
|
@ -16,9 +16,8 @@ exclude = ["test_data/*"]
|
|||
cryptoxide = "0.4.2"
|
||||
flat-rs = { path = "../flat", version = "0.0.10" }
|
||||
hex = "0.4.3"
|
||||
minicbor = { version = "0.18.0", features = ["std"] }
|
||||
pallas-codec = "0.14.0-alpha.2"
|
||||
pallas-primitives = "0.14.0-alpha.2"
|
||||
pallas-codec = { git = "https://github.com/txpipe/pallas" }
|
||||
pallas-primitives = { git = "https://github.com/txpipe/pallas" }
|
||||
peg = "0.8.0"
|
||||
pretty = "0.11.3"
|
||||
thiserror = "1.0.31"
|
||||
|
|
|
@ -31,7 +31,7 @@ where
|
|||
T: Binder<'b> + Debug,
|
||||
{
|
||||
pub fn from_cbor(bytes: &'b [u8], buffer: &'b mut Vec<u8>) -> Result<Self, de::Error> {
|
||||
let mut cbor_decoder = minicbor::Decoder::new(bytes);
|
||||
let mut cbor_decoder = pallas_codec::minicbor::Decoder::new(bytes);
|
||||
|
||||
let flat_bytes = cbor_decoder
|
||||
.bytes()
|
||||
|
@ -63,7 +63,7 @@ where
|
|||
|
||||
let mut bytes = Vec::new();
|
||||
|
||||
let mut cbor_encoder = minicbor::Encoder::new(&mut bytes);
|
||||
let mut cbor_encoder = pallas_codec::minicbor::Encoder::new(&mut bytes);
|
||||
|
||||
cbor_encoder
|
||||
.bytes(&flat_bytes)
|
||||
|
|
|
@ -489,8 +489,8 @@ impl Value {
|
|||
let mut new_stack: VecDeque<&PlutusData>;
|
||||
// create new stack with of items from the list of pairs of data
|
||||
new_stack = m.iter().fold(VecDeque::new(), |mut acc, d| {
|
||||
acc.push_back(d.0);
|
||||
acc.push_back(d.1);
|
||||
acc.push_back(&d.0);
|
||||
acc.push_back(&d.1);
|
||||
acc
|
||||
});
|
||||
// Append old stack to the back of the new stack
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::BTreeMap, ops::Deref};
|
||||
use std::ops::Deref;
|
||||
|
||||
use pallas_primitives::babbage::{BigInt, Constr, PlutusData};
|
||||
|
||||
|
@ -693,14 +693,14 @@ impl DefaultFunction {
|
|||
},
|
||||
DefaultFunction::MapData => match &args[0] {
|
||||
Value::Con(Constant::ProtoList(_, list)) => {
|
||||
let mut map = BTreeMap::new();
|
||||
let mut map = Vec::new();
|
||||
|
||||
for item in list {
|
||||
match item {
|
||||
Constant::ProtoPair(Type::Data, Type::Data, left, right) => {
|
||||
match (*left.clone(), *right.clone()) {
|
||||
(Constant::Data(key), Constant::Data(value)) => {
|
||||
map.insert(key, value);
|
||||
map.push((key, value));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ impl DefaultFunction {
|
|||
}
|
||||
}
|
||||
|
||||
Ok(Value::Con(Constant::Data(PlutusData::Map(map))))
|
||||
Ok(Value::Con(Constant::Data(PlutusData::Map(map.into()))))
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue