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