chore: apply new lint warnings from latest clippy (#561)

This commit is contained in:
Santiago Carmuega 2024-12-14 17:37:33 -03:00 committed by GitHub
parent 106d8676b6
commit 3a614d2c91
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 185 additions and 171 deletions

View file

@ -1,7 +1,6 @@
pub mod common; pub mod common;
use common::*; use common::*;
use hex;
use pallas_addresses::{Address, Network, ShelleyAddress, ShelleyPaymentPart}; use pallas_addresses::{Address, Network, ShelleyAddress, ShelleyPaymentPart};
use pallas_applying::{ use pallas_applying::{
utils::{ utils::{
@ -598,7 +597,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -675,7 +674,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -725,7 +724,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -857,7 +856,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -1019,7 +1018,7 @@ mod babbage_tests {
}; };
let altered_address: ShelleyAddress = ShelleyAddress::new( let altered_address: ShelleyAddress = ShelleyAddress::new(
old_shelley_address.network(), old_shelley_address.network(),
ShelleyPaymentPart::Script(old_shelley_address.payment().as_hash().clone()), ShelleyPaymentPart::Script(*old_shelley_address.payment().as_hash()),
old_shelley_address.delegation().clone(), old_shelley_address.delegation().clone(),
); );
let tx_in = mtx let tx_in = mtx
@ -1303,7 +1302,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -1346,11 +1345,11 @@ mod babbage_tests {
)]; )];
let utxos: UTxOs = mk_utxo_for_babbage_tx(&mtx.transaction_body, tx_outs_info); let utxos: UTxOs = mk_utxo_for_babbage_tx(&mtx.transaction_body, tx_outs_info);
let mut tx_body: MintedTransactionBody = (*mtx.transaction_body).clone(); let mut tx_body: MintedTransactionBody = (*mtx.transaction_body).clone();
tx_body.fee = tx_body.fee - 1; tx_body.fee -= 1;
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -1480,7 +1479,7 @@ mod babbage_tests {
let utxos: UTxOs = mk_utxo_for_babbage_tx(&mtx.transaction_body, tx_outs_info); let utxos: UTxOs = mk_utxo_for_babbage_tx(&mtx.transaction_body, tx_outs_info);
let mut tx_body: MintedTransactionBody = (*mtx.transaction_body).clone(); let mut tx_body: MintedTransactionBody = (*mtx.transaction_body).clone();
let (first_output, rest): (&MintedTransactionOutput, &[MintedTransactionOutput]) = let (first_output, rest): (&MintedTransactionOutput, &[MintedTransactionOutput]) =
(&tx_body.outputs).split_first().unwrap(); tx_body.outputs.split_first().unwrap();
let (address_bytes, val): (Bytes, Value) = match first_output { let (address_bytes, val): (Bytes, Value) = match first_output {
PseudoTransactionOutput::Legacy(output) => { PseudoTransactionOutput::Legacy(output) => {
(output.address.clone(), output.amount.clone()) (output.address.clone(), output.amount.clone())
@ -1511,7 +1510,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -1561,7 +1560,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_body, &mut tx_buf); let _ = encode(tx_body, &mut tx_buf);
mtx.transaction_body = mtx.transaction_body =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -1809,7 +1808,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf); let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set = mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -1977,7 +1976,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf); let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set = mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -2066,7 +2065,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf); let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set = mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -2156,12 +2155,12 @@ mod babbage_tests {
let mut new_datum_buf: Vec<u8> = Vec::new(); let mut new_datum_buf: Vec<u8> = Vec::new();
let _ = encode(new_datum, &mut new_datum_buf); let _ = encode(new_datum, &mut new_datum_buf);
let keep_raw_new_datum: KeepRaw<PlutusData> = let keep_raw_new_datum: KeepRaw<PlutusData> =
Decode::decode(&mut Decoder::new(&new_datum_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(new_datum_buf.as_slice()), &mut ()).unwrap();
tx_wits.plutus_data = Some(vec![old_datum, keep_raw_new_datum]); tx_wits.plutus_data = Some(vec![old_datum, keep_raw_new_datum]);
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf); let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set = mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -2254,7 +2253,7 @@ mod babbage_tests {
let mut tx_buf: Vec<u8> = Vec::new(); let mut tx_buf: Vec<u8> = Vec::new();
let _ = encode(tx_wits, &mut tx_buf); let _ = encode(tx_wits, &mut tx_buf);
mtx.transaction_witness_set = mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,
@ -2344,7 +2343,7 @@ mod babbage_tests {
let mut tx_witness_set_buf: Vec<u8> = Vec::new(); let mut tx_witness_set_buf: Vec<u8> = Vec::new();
let _ = encode(tx_witness_set, &mut tx_witness_set_buf); let _ = encode(tx_witness_set, &mut tx_witness_set_buf);
mtx.transaction_witness_set = mtx.transaction_witness_set =
Decode::decode(&mut Decoder::new(&tx_witness_set_buf.as_slice()), &mut ()).unwrap(); Decode::decode(&mut Decoder::new(tx_witness_set_buf.as_slice()), &mut ()).unwrap();
let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx); let metx: MultiEraTx = MultiEraTx::from_babbage(&mtx);
let acnt = AccountState { let acnt = AccountState {
treasury: 261_254_564_000_000, treasury: 261_254_564_000_000,

View file

@ -24,11 +24,11 @@ pub fn minted_tx_from_cbor(tx_cbor: &[u8]) -> MintedTx<'_> {
} }
pub fn babbage_minted_tx_from_cbor(tx_cbor: &[u8]) -> BabbageMintedTx<'_> { pub fn babbage_minted_tx_from_cbor(tx_cbor: &[u8]) -> BabbageMintedTx<'_> {
pallas_codec::minicbor::decode::<BabbageMintedTx>(&tx_cbor[..]).unwrap() pallas_codec::minicbor::decode::<BabbageMintedTx>(tx_cbor).unwrap()
} }
pub fn minted_tx_payload_from_cbor<'a>(tx_cbor: &'a Vec<u8>) -> MintedTxPayload<'a> { pub fn minted_tx_payload_from_cbor(tx_cbor: &[u8]) -> MintedTxPayload<'_> {
pallas_codec::minicbor::decode::<MintedTxPayload>(&tx_cbor[..]).unwrap() pallas_codec::minicbor::decode::<MintedTxPayload>(tx_cbor).unwrap()
} }
pub fn mk_utxo_for_byron_tx<'a>(tx: &Tx, tx_outs_info: &[(String, u64)]) -> UTxOs<'a> { pub fn mk_utxo_for_byron_tx<'a>(tx: &Tx, tx_outs_info: &[(String, u64)]) -> UTxOs<'a> {

View file

@ -13,7 +13,7 @@ pub struct Decoder<'b> {
} }
impl<'b> Decoder<'b> { impl<'b> Decoder<'b> {
pub fn new(bytes: &'b [u8]) -> Decoder { pub fn new(bytes: &'b [u8]) -> Decoder<'b> {
Decoder { Decoder {
buffer: bytes, buffer: bytes,
pos: 0, pos: 0,

View file

@ -1120,7 +1120,7 @@ impl<'b, T> KeepRaw<'b, T> {
} }
} }
impl<'b, T> Deref for KeepRaw<'b, T> { impl<T> Deref for KeepRaw<'_, T> {
type Target = T; type Target = T;
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {

View file

@ -134,7 +134,7 @@ impl<const BITS: usize> Write for Hasher<BITS> {
} }
*/ */
impl<'a, const BITS: usize> minicbor::encode::Write for &'a mut Hasher<BITS> { impl<const BITS: usize> minicbor::encode::Write for &mut Hasher<BITS> {
type Error = std::convert::Infallible; type Error = std::convert::Infallible;
#[inline] #[inline]

View file

@ -17,7 +17,7 @@ impl<const BYTES: usize> Serialize for Hash<BYTES> {
struct HashVisitor<const BYTES: usize> {} struct HashVisitor<const BYTES: usize> {}
impl<'de, const BYTES: usize> Visitor<'de> for HashVisitor<BYTES> { impl<const BYTES: usize> Visitor<'_> for HashVisitor<BYTES> {
type Value = Hash<BYTES>; type Value = Hash<BYTES>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {

View file

@ -48,13 +48,13 @@ mod tests {
#[test] #[test]
fn test_epoch_nonce() { fn test_epoch_nonce() {
let nc_values = vec![ let nc_values = [
hex::decode("e86e133bd48ff5e79bec43af1ac3e348b539172f33e502d2c96735e8c51bd04d") hex::decode("e86e133bd48ff5e79bec43af1ac3e348b539172f33e502d2c96735e8c51bd04d")
.unwrap(), .unwrap(),
hex::decode("d1340a9c1491f0face38d41fd5c82953d0eb48320d65e952414a0c5ebaf87587") hex::decode("d1340a9c1491f0face38d41fd5c82953d0eb48320d65e952414a0c5ebaf87587")
.unwrap(), .unwrap(),
]; ];
let nh_values = vec![ let nh_values = [
hex::decode("d7a1ff2a365abed59c9ae346cba842b6d3df06d055dba79a113e0704b44cc3e9") hex::decode("d7a1ff2a365abed59c9ae346cba842b6d3df06d055dba79a113e0704b44cc3e9")
.unwrap(), .unwrap(),
hex::decode("ee91d679b0a6ce3015b894c575c799e971efac35c7a8cbdc2b3f579005e69abd") hex::decode("ee91d679b0a6ce3015b894c575c799e971efac35c7a8cbdc2b3f579005e69abd")
@ -63,7 +63,7 @@ mod tests {
let ee = hex::decode("d982e06fd33e7440b43cefad529b7ecafbaa255e38178ad4189a37e4ce9bf1fa") let ee = hex::decode("d982e06fd33e7440b43cefad529b7ecafbaa255e38178ad4189a37e4ce9bf1fa")
.unwrap(); .unwrap();
let extra_entropy_values: Vec<Option<&[u8]>> = vec![None, Some(&ee)]; let extra_entropy_values: Vec<Option<&[u8]>> = vec![None, Some(&ee)];
let expected_epoch_nonces = vec![ let expected_epoch_nonces = [
hex::decode("e536a0081ddd6d19786e9d708a85819a5c3492c0da7349f59c8ad3e17e4acd98") hex::decode("e536a0081ddd6d19786e9d708a85819a5c3492c0da7349f59c8ad3e17e4acd98")
.unwrap(), .unwrap(),
hex::decode("0022cfa563a5328c4fb5c8017121329e964c26ade5d167b1bd9b2ec967772b60") hex::decode("0022cfa563a5328c4fb5c8017121329e964c26ade5d167b1bd9b2ec967772b60")

View file

@ -565,7 +565,7 @@ mod tests {
} }
fn read_full_snapshot(path: &Path) { fn read_full_snapshot(path: &Path) {
let reader = super::read_blocks(&path).unwrap(); let reader = super::read_blocks(path).unwrap();
let mut count = 0; let mut count = 0;
let mut last_slot = None; let mut last_slot = None;

View file

@ -117,7 +117,7 @@ impl Neg for Decimal {
} }
// Implement Neg for a reference to Decimal // Implement Neg for a reference to Decimal
impl<'a> Neg for &'a Decimal { impl Neg for &Decimal {
type Output = Decimal; type Output = Decimal;
fn neg(self) -> Self::Output { fn neg(self) -> Self::Output {
@ -138,7 +138,7 @@ impl Abs for Decimal {
} }
// Implement Abs for a reference to Decimal // Implement Abs for a reference to Decimal
impl<'a> Abs for &'a Decimal { impl Abs for &Decimal {
type Output = Decimal; type Output = Decimal;
fn abs(self) -> Self::Output { fn abs(self) -> Self::Output {
@ -167,7 +167,7 @@ impl MulAssign for Decimal {
} }
// Implement Mul for a reference to Decimal // Implement Mul for a reference to Decimal
impl<'a, 'b> Mul<&'b Decimal> for &'a Decimal { impl<'b> Mul<&'b Decimal> for &Decimal {
type Output = Decimal; type Output = Decimal;
fn mul(self, rhs: &'b Decimal) -> Self::Output { fn mul(self, rhs: &'b Decimal) -> Self::Output {
@ -178,7 +178,7 @@ impl<'a, 'b> Mul<&'b Decimal> for &'a Decimal {
} }
} }
impl<'a, 'b> MulAssign<&'b Decimal> for &'a mut Decimal { impl<'b> MulAssign<&'b Decimal> for &mut Decimal {
fn mul_assign(&mut self, rhs: &'b Decimal) { fn mul_assign(&mut self, rhs: &'b Decimal) {
self.data *= &rhs.data; self.data *= &rhs.data;
scale(&mut self.data); scale(&mut self.data);
@ -203,7 +203,7 @@ impl DivAssign for Decimal {
} }
// Implement Div for a reference to Decimal // Implement Div for a reference to Decimal
impl<'a, 'b> Div<&'b Decimal> for &'a Decimal { impl<'b> Div<&'b Decimal> for &Decimal {
type Output = Decimal; type Output = Decimal;
fn div(self, rhs: &'b Decimal) -> Self::Output { fn div(self, rhs: &'b Decimal) -> Self::Output {
@ -213,7 +213,7 @@ impl<'a, 'b> Div<&'b Decimal> for &'a Decimal {
} }
} }
impl<'a, 'b> DivAssign<&'b Decimal> for &'a mut Decimal { impl<'b> DivAssign<&'b Decimal> for &mut Decimal {
fn div_assign(&mut self, rhs: &'b Decimal) { fn div_assign(&mut self, rhs: &'b Decimal) {
let temp = self.data.clone(); let temp = self.data.clone();
div(&mut self.data, &temp, &rhs.data); div(&mut self.data, &temp, &rhs.data);
@ -237,7 +237,7 @@ impl SubAssign for Decimal {
} }
// Implement Sub for a reference to Decimal // Implement Sub for a reference to Decimal
impl<'a, 'b> Sub<&'b Decimal> for &'a Decimal { impl<'b> Sub<&'b Decimal> for &Decimal {
type Output = Decimal; type Output = Decimal;
fn sub(self, rhs: &'b Decimal) -> Self::Output { fn sub(self, rhs: &'b Decimal) -> Self::Output {
@ -247,7 +247,7 @@ impl<'a, 'b> Sub<&'b Decimal> for &'a Decimal {
} }
} }
impl<'a, 'b> SubAssign<&'b Decimal> for &'a mut Decimal { impl<'b> SubAssign<&'b Decimal> for &mut Decimal {
fn sub_assign(&mut self, rhs: &'b Decimal) { fn sub_assign(&mut self, rhs: &'b Decimal) {
self.data -= &rhs.data; self.data -= &rhs.data;
} }
@ -270,7 +270,7 @@ impl AddAssign for Decimal {
} }
// Implement Add for a reference to Decimal // Implement Add for a reference to Decimal
impl<'a, 'b> Add<&'b Decimal> for &'a Decimal { impl<'b> Add<&'b Decimal> for &Decimal {
type Output = Decimal; type Output = Decimal;
fn add(self, rhs: &'b Decimal) -> Self::Output { fn add(self, rhs: &'b Decimal) -> Self::Output {
@ -280,7 +280,7 @@ impl<'a, 'b> Add<&'b Decimal> for &'a Decimal {
} }
} }
impl<'a, 'b> AddAssign<&'b Decimal> for &'a mut Decimal { impl<'b> AddAssign<&'b Decimal> for &mut Decimal {
fn add_assign(&mut self, rhs: &'b Decimal) { fn add_assign(&mut self, rhs: &'b Decimal) {
self.data += &rhs.data; self.data += &rhs.data;
} }

View file

@ -267,9 +267,7 @@ pub type UTxOByTxin = UTxOByAddress;
pub type Datum = (Era, TagWrap<Bytes, 24>); pub type Datum = (Era, TagWrap<Bytes, 24>);
// From `pallas-primitives`, with fewer `derive`s // From `pallas-primitives`, with fewer `derive`s
#[derive( #[derive(Encode, Decode, Debug, PartialEq, Eq, PartialOrd, Ord, Clone)]
Encode, Decode, Debug, PartialEq, Eq, PartialOrd, Ord, Clone,
)]
pub struct TransactionInput { pub struct TransactionInput {
#[n(0)] #[n(0)]
pub transaction_id: Hash<32>, pub transaction_id: Hash<32>,

View file

@ -1,28 +1,34 @@
use std::{ use hex::FromHex;
fs, collections::BTreeSet, net::{Ipv4Addr, SocketAddrV4},
time::Duration, path::Path
};
use pallas_codec::utils::{AnyCbor, AnyUInt, Bytes, KeyValuePairs, TagWrap}; use pallas_codec::utils::{AnyCbor, AnyUInt, Bytes, KeyValuePairs, TagWrap};
use pallas_crypto::hash::Hash; use pallas_crypto::hash::Hash;
use pallas_network::miniprotocols::localstate::queries_v16::{
self, Addr, Addrs, ChainBlockNumber, Fraction, GenesisConfig, RationalNumber, Snapshots,
StakeAddr, Stakes, SystemStart, UnitInterval, Value,
};
use pallas_network::{ use pallas_network::{
facades::{NodeClient, PeerClient, PeerServer}, facades::{NodeClient, PeerClient, PeerServer},
multiplexer::{Bearer, Plexer},
miniprotocols::{ miniprotocols::{
blockfetch,
blockfetch::BlockRequest, blockfetch::BlockRequest,
chainsync::{ClientRequest, HeaderContent, Tip},
handshake::n2n::VersionData,
chainsync::{self, NextResponse}, chainsync::{self, NextResponse},
txsubmission::{EraTxBody, TxIdAndSize}, chainsync::{ClientRequest, HeaderContent, Tip},
handshake,
handshake::n2n::VersionData,
localstate,
localstate::ClientQueryRequest, localstate::ClientQueryRequest,
handshake, localstate, txsubmission, MAINNET_MAGIC, blockfetch, txsubmission,
Point, txsubmission::{EraTxBody, TxIdAndSize},
Point, MAINNET_MAGIC,
}, },
multiplexer::{Bearer, Plexer},
}; };
use pallas_network::miniprotocols::localstate::queries_v16::{ use std::{
self, Addr, Addrs, ChainBlockNumber, Fraction, GenesisConfig, Snapshots, Stakes, collections::BTreeSet,
SystemStart, UnitInterval, Value, StakeAddr, RationalNumber, fs,
net::{Ipv4Addr, SocketAddrV4},
path::Path,
time::Duration,
}; };
use hex::FromHex;
use tokio::net::TcpListener; use tokio::net::TcpListener;
@ -494,8 +500,10 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetSystemStart`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetSystemStart`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!(query, queries_v16::Request::GetSystemStart); assert_eq!(query, queries_v16::Request::GetSystemStart);
@ -515,8 +523,10 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetChainBlockNo`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetChainBlockNo`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!(query, queries_v16::Request::GetChainBlockNo); assert_eq!(query, queries_v16::Request::GetChainBlockNo);
@ -536,22 +546,25 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetStakeDistribution`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetStakeDistribution`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!( assert_eq!(
query, query,
queries_v16::Request::LedgerQuery( queries_v16::Request::LedgerQuery(queries_v16::LedgerQuery::BlockQuery(
queries_v16::LedgerQuery::BlockQuery( 5,
5, queries_v16::BlockQuery::GetStakeDistribution,
queries_v16::BlockQuery::GetStakeDistribution, ),)
),
)
); );
assert_eq!(*server.statequery().state(), localstate::State::Querying); assert_eq!(*server.statequery().state(), localstate::State::Querying);
let rational = RationalNumber { numerator: 10, denominator: 20 }; let rational = RationalNumber {
numerator: 10,
denominator: 20,
};
let pool = localstate::queries_v16::Pool { let pool = localstate::queries_v16::Pool {
stakes: rational.clone(), stakes: rational.clone(),
hashes: b"pool1qv4qgv62s3ha74p0643nexee9zvcdydcyahqqnavhj90zheuykz" hashes: b"pool1qv4qgv62s3ha74p0643nexee9zvcdydcyahqqnavhj90zheuykz"
@ -576,8 +589,10 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetUTxOByAddress`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetUTxOByAddress`) \
Unexpected message from client: {x:?}"
),
}; };
let addr_hex = let addr_hex =
@ -589,12 +604,10 @@ pub async fn local_state_query_server_and_client_happy_path() {
assert_eq!( assert_eq!(
query, query,
queries_v16::Request::LedgerQuery( queries_v16::Request::LedgerQuery(queries_v16::LedgerQuery::BlockQuery(
queries_v16::LedgerQuery::BlockQuery( 5,
5, queries_v16::BlockQuery::GetUTxOByAddress(addrs),
queries_v16::BlockQuery::GetUTxOByAddress(addrs), ),)
),
)
); );
assert_eq!(*server.statequery().state(), localstate::State::Querying); assert_eq!(*server.statequery().state(), localstate::State::Querying);
@ -608,16 +621,15 @@ pub async fn local_state_query_server_and_client_happy_path() {
let datum = hex::decode(hex_datum).unwrap().into(); let datum = hex::decode(hex_datum).unwrap().into();
let tag = TagWrap::<_, 24>::new(datum); let tag = TagWrap::<_, 24>::new(datum);
let inline_datum = Some((1_u16, tag)); let inline_datum = Some((1_u16, tag));
let values = queries_v16::TransactionOutput::Current( let values =
queries_v16::PostAlonsoTransactionOutput { queries_v16::TransactionOutput::Current(queries_v16::PostAlonsoTransactionOutput {
address: b"addr_test1vr80076l3x5uw6n94nwhgmv7ssgy6muzf47ugn6z0l92rhg2mgtu0" address: b"addr_test1vr80076l3x5uw6n94nwhgmv7ssgy6muzf47ugn6z0l92rhg2mgtu0"
.to_vec() .to_vec()
.into(), .into(),
amount: Value::Coin(lovelace), amount: Value::Coin(lovelace),
inline_datum, inline_datum,
script_ref: None, script_ref: None,
}, });
);
let utxo = KeyValuePairs::from(vec![( let utxo = KeyValuePairs::from(vec![(
queries_v16::UTxO { queries_v16::UTxO {
@ -635,17 +647,17 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetCurrentPParams`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetCurrentPParams`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!( assert_eq!(
query, query,
queries_v16::Request::LedgerQuery( queries_v16::Request::LedgerQuery(queries_v16::LedgerQuery::BlockQuery(
queries_v16::LedgerQuery::BlockQuery( 5,
5, queries_v16::BlockQuery::GetCurrentPParams,
queries_v16::BlockQuery::GetCurrentPParams, ),)
),
)
); );
assert_eq!(*server.statequery().state(), localstate::State::Querying); assert_eq!(*server.statequery().state(), localstate::State::Querying);
@ -671,7 +683,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
numerator: 3, numerator: 3,
denominator: 1000000, denominator: 1000000,
}), }),
protocol_version: Some((5,0)), protocol_version: Some((5, 0)),
min_pool_cost: Some(AnyUInt::U32(340000000)), min_pool_cost: Some(AnyUInt::U32(340000000)),
ada_per_utxo_byte: Some(AnyUInt::U16(44)), ada_per_utxo_byte: Some(AnyUInt::U16(44)),
cost_models_for_script_languages: None, cost_models_for_script_languages: None,
@ -690,18 +702,18 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetStakeSnapshots`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetStakeSnapshots`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!( assert_eq!(
query, query,
queries_v16::Request::LedgerQuery( queries_v16::Request::LedgerQuery(queries_v16::LedgerQuery::BlockQuery(
queries_v16::LedgerQuery::BlockQuery( 5,
5, queries_v16::BlockQuery::GetStakeSnapshots(BTreeSet::new()),
queries_v16::BlockQuery::GetStakeSnapshots(BTreeSet::new()), ),)
),
)
); );
assert_eq!(*server.statequery().state(), localstate::State::Querying); assert_eq!(*server.statequery().state(), localstate::State::Querying);
@ -734,18 +746,18 @@ pub async fn local_state_query_server_and_client_happy_path() {
let query: queries_v16::Request = let query: queries_v16::Request =
match server.statequery().recv_while_acquired().await.unwrap() { match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::Query(q) => q.into_decode().unwrap(), ClientQueryRequest::Query(q) => q.into_decode().unwrap(),
x => panic!("(While expecting `GetGenesisConfig`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `GetGenesisConfig`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!( assert_eq!(
query, query,
queries_v16::Request::LedgerQuery( queries_v16::Request::LedgerQuery(queries_v16::LedgerQuery::BlockQuery(
queries_v16::LedgerQuery::BlockQuery( 5,
5, queries_v16::BlockQuery::GetGenesisConfig,
queries_v16::BlockQuery::GetGenesisConfig, ),)
),
)
); );
assert_eq!(*server.statequery().state(), localstate::State::Querying); assert_eq!(*server.statequery().state(), localstate::State::Querying);
@ -777,8 +789,10 @@ pub async fn local_state_query_server_and_client_happy_path() {
let maybe_point = match server.statequery().recv_while_acquired().await.unwrap() { let maybe_point = match server.statequery().recv_while_acquired().await.unwrap() {
ClientQueryRequest::ReAcquire(p) => p, ClientQueryRequest::ReAcquire(p) => p,
x => panic!("(While expecting `ReAcquire`) \ x => panic!(
Unexpected message from client: {x:?}"), "(While expecting `ReAcquire`) \
Unexpected message from client: {x:?}"
),
}; };
assert_eq!(maybe_point, Some(Point::Specific(1337, vec![1, 2, 3]))); assert_eq!(maybe_point, Some(Point::Specific(1337, vec![1, 2, 3])));
@ -787,16 +801,19 @@ pub async fn local_state_query_server_and_client_happy_path() {
server.statequery().send_acquired().await.unwrap(); server.statequery().send_acquired().await.unwrap();
// server receives query from client // server receives query from client
let query: Vec<u8> = let query: Vec<u8> = match server.statequery().recv_while_acquired().await.unwrap() {
match server.statequery().recv_while_acquired().await.unwrap() { ClientQueryRequest::Query(q) => q.unwrap(),
ClientQueryRequest::Query(q) => q.unwrap(), x => panic!(
x => panic!("(While expecting `GetFilteredDeleg...`) \ "(While expecting `GetFilteredDeleg...`) \
Unexpected message from client: {x:?}"), Unexpected message from client: {x:?}"
}; ),
};
let addr: Addr = <[u8; 28]>::from_hex( let addr: Addr =
"1218F563E4E10958FDABBDFB470B2F9D386215763CC89273D9BDFFFA" <[u8; 28]>::from_hex("1218F563E4E10958FDABBDFB470B2F9D386215763CC89273D9BDFFFA")
).unwrap().to_vec().into(); .unwrap()
.to_vec()
.into();
// CBOR got from preprod node. Mind the stripped `8203`. // CBOR got from preprod node. Mind the stripped `8203`.
let cbor_query = Vec::<u8>::from_hex( let cbor_query = Vec::<u8>::from_hex(
"820082008206820a818200581c1218f563e4e10958fdabbdfb470b2f9d386215763cc89273d9bdfffa" "820082008206820a818200581c1218f563e4e10958fdabbdfb470b2f9d386215763cc89273d9bdfffa"
@ -805,9 +822,11 @@ pub async fn local_state_query_server_and_client_happy_path() {
assert_eq!(query, cbor_query); assert_eq!(query, cbor_query);
assert_eq!(*server.statequery().state(), localstate::State::Querying); assert_eq!(*server.statequery().state(), localstate::State::Querying);
let pool_addr: Addr = <[u8; 28]>::from_hex( let pool_addr: Addr =
"1E3105F23F2AC91B3FB4C35FA4FE301421028E356E114944E902005B" <[u8; 28]>::from_hex("1E3105F23F2AC91B3FB4C35FA4FE301421028E356E114944E902005B")
).unwrap().to_vec().into(); .unwrap()
.to_vec()
.into();
let delegs = KeyValuePairs::from(vec![(StakeAddr::from((0, addr.clone())), pool_addr)]); let delegs = KeyValuePairs::from(vec![(StakeAddr::from((0, addr.clone())), pool_addr)]);
let rewards = KeyValuePairs::from(vec![(StakeAddr::from((0, addr)), 250526523)]); let rewards = KeyValuePairs::from(vec![(StakeAddr::from((0, addr)), 250526523)]);
@ -893,10 +912,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
); );
let request = AnyCbor::from_encode(queries_v16::Request::LedgerQuery( let request = AnyCbor::from_encode(queries_v16::Request::LedgerQuery(
queries_v16::LedgerQuery::BlockQuery( queries_v16::LedgerQuery::BlockQuery(5, queries_v16::BlockQuery::GetStakeDistribution),
5,
queries_v16::BlockQuery::GetStakeDistribution,
),
)); ));
client.statequery().send_query(request).await.unwrap(); client.statequery().send_query(request).await.unwrap();
@ -909,7 +925,10 @@ pub async fn local_state_query_server_and_client_happy_path() {
.into_decode() .into_decode()
.unwrap(); .unwrap();
let rational = RationalNumber { numerator: 10, denominator: 20 }; let rational = RationalNumber {
numerator: 10,
denominator: 20,
};
let pool = localstate::queries_v16::Pool { let pool = localstate::queries_v16::Pool {
stakes: rational.clone(), stakes: rational.clone(),
hashes: b"pool1qv4qgv62s3ha74p0643nexee9zvcdydcyahqqnavhj90zheuykz" hashes: b"pool1qv4qgv62s3ha74p0643nexee9zvcdydcyahqqnavhj90zheuykz"
@ -961,16 +980,15 @@ pub async fn local_state_query_server_and_client_happy_path() {
let datum = hex::decode(hex_datum).unwrap().into(); let datum = hex::decode(hex_datum).unwrap().into();
let tag = TagWrap::<_, 24>::new(datum); let tag = TagWrap::<_, 24>::new(datum);
let inline_datum = Some((1_u16, tag)); let inline_datum = Some((1_u16, tag));
let values = queries_v16::TransactionOutput::Current( let values =
queries_v16::PostAlonsoTransactionOutput { queries_v16::TransactionOutput::Current(queries_v16::PostAlonsoTransactionOutput {
address: b"addr_test1vr80076l3x5uw6n94nwhgmv7ssgy6muzf47ugn6z0l92rhg2mgtu0" address: b"addr_test1vr80076l3x5uw6n94nwhgmv7ssgy6muzf47ugn6z0l92rhg2mgtu0"
.to_vec() .to_vec()
.into(), .into(),
amount: Value::Coin(lovelace), amount: Value::Coin(lovelace),
inline_datum, inline_datum,
script_ref: None, script_ref: None,
}, });
);
let utxo = KeyValuePairs::from(vec![( let utxo = KeyValuePairs::from(vec![(
queries_v16::UTxO { queries_v16::UTxO {
@ -983,10 +1001,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
assert_eq!(result, queries_v16::UTxOByAddress { utxo }); assert_eq!(result, queries_v16::UTxOByAddress { utxo });
let request = AnyCbor::from_encode(queries_v16::Request::LedgerQuery( let request = AnyCbor::from_encode(queries_v16::Request::LedgerQuery(
queries_v16::LedgerQuery::BlockQuery( queries_v16::LedgerQuery::BlockQuery(5, queries_v16::BlockQuery::GetCurrentPParams),
5,
queries_v16::BlockQuery::GetCurrentPParams,
),
)); ));
client.statequery().send_query(request).await.unwrap(); client.statequery().send_query(request).await.unwrap();
@ -1023,7 +1038,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
numerator: 3, numerator: 3,
denominator: 1000000, denominator: 1000000,
}), }),
protocol_version: Some((5,0)), protocol_version: Some((5, 0)),
min_pool_cost: Some(AnyUInt::U32(340000000)), min_pool_cost: Some(AnyUInt::U32(340000000)),
ada_per_utxo_byte: Some(AnyUInt::U16(44)), ada_per_utxo_byte: Some(AnyUInt::U16(44)),
cost_models_for_script_languages: None, cost_models_for_script_languages: None,
@ -1077,10 +1092,7 @@ pub async fn local_state_query_server_and_client_happy_path() {
assert_eq!(result, queries_v16::StakeSnapshot { snapshots }); assert_eq!(result, queries_v16::StakeSnapshot { snapshots });
let request = AnyCbor::from_encode(queries_v16::Request::LedgerQuery( let request = AnyCbor::from_encode(queries_v16::Request::LedgerQuery(
queries_v16::LedgerQuery::BlockQuery( queries_v16::LedgerQuery::BlockQuery(5, queries_v16::BlockQuery::GetGenesisConfig),
5,
queries_v16::BlockQuery::GetGenesisConfig,
),
)); ));
client.statequery().send_query(request).await.unwrap(); client.statequery().send_query(request).await.unwrap();
@ -1122,9 +1134,11 @@ pub async fn local_state_query_server_and_client_happy_path() {
client.statequery().recv_while_acquiring().await.unwrap(); client.statequery().recv_while_acquiring().await.unwrap();
let addr: Addr = <[u8; 28]>::from_hex( let addr: Addr =
"1218F563E4E10958FDABBDFB470B2F9D386215763CC89273D9BDFFFA" <[u8; 28]>::from_hex("1218F563E4E10958FDABBDFB470B2F9D386215763CC89273D9BDFFFA")
).unwrap().to_vec().into(); .unwrap()
.to_vec()
.into();
let mut addrs = BTreeSet::new(); let mut addrs = BTreeSet::new();
addrs.insert(StakeAddr::from((0x00, addr.clone()))); addrs.insert(StakeAddr::from((0x00, addr.clone())));
@ -1147,8 +1161,9 @@ pub async fn local_state_query_server_and_client_happy_path() {
"8182a18200581c1218f563e4e10958fdabbdfb470b2f9d386215763cc89273d9bd\ "8182a18200581c1218f563e4e10958fdabbdfb470b2f9d386215763cc89273d9bd\
fffa581c1e3105f23f2ac91b3fb4c35fa4fe301421028e356e114944e902005ba1\ fffa581c1e3105f23f2ac91b3fb4c35fa4fe301421028e356e114944e902005ba1\
8200581c1218f563e4e10958fdabbdfb470b2f9d386215763cc89273d9bdfffa1a\ 8200581c1218f563e4e10958fdabbdfb470b2f9d386215763cc89273d9bdfffa1a\
0eeebb3b" 0eeebb3b",
).unwrap(); )
.unwrap();
assert_eq!(result, delegs_rewards_cbor); assert_eq!(result, delegs_rewards_cbor);

View file

@ -2,7 +2,7 @@ use pallas_crypto::hash::Hash;
use crate::{MultiEraAsset, MultiEraPolicyAssets}; use crate::{MultiEraAsset, MultiEraPolicyAssets};
impl<'b> MultiEraPolicyAssets<'b> { impl MultiEraPolicyAssets<'_> {
pub fn policy(&self) -> &Hash<28> { pub fn policy(&self) -> &Hash<28> {
match self { match self {
MultiEraPolicyAssets::AlonzoCompatibleMint(x, _) => x, MultiEraPolicyAssets::AlonzoCompatibleMint(x, _) => x,
@ -74,7 +74,7 @@ impl<'b> MultiEraPolicyAssets<'b> {
} }
} }
impl<'b> MultiEraAsset<'b> { impl MultiEraAsset<'_> {
pub fn policy(&self) -> &Hash<28> { pub fn policy(&self) -> &Hash<28> {
match self { match self {
MultiEraAsset::AlonzoCompatibleMint(x, ..) => x, MultiEraAsset::AlonzoCompatibleMint(x, ..) => x,

View file

@ -4,7 +4,7 @@ use pallas_primitives::alonzo;
use crate::MultiEraTx; use crate::MultiEraTx;
impl<'b> MultiEraTx<'b> { impl MultiEraTx<'_> {
pub fn aux_plutus_v1_scripts(&self) -> &[alonzo::PlutusScript<1>] { pub fn aux_plutus_v1_scripts(&self) -> &[alonzo::PlutusScript<1>] {
if let Some(aux_data) = self.aux_data() { if let Some(aux_data) = self.aux_data() {
if let alonzo::AuxiliaryData::PostAlonzo(x) = aux_data.deref() { if let alonzo::AuxiliaryData::PostAlonzo(x) = aux_data.deref() {

View file

@ -2,7 +2,7 @@ use pallas_primitives::{alonzo, conway};
use crate::MultiEraCert; use crate::MultiEraCert;
impl<'b> MultiEraCert<'b> { impl MultiEraCert<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::Certificate> { pub fn as_alonzo(&self) -> Option<&alonzo::Certificate> {
match self { match self {
MultiEraCert::AlonzoCompatible(x) => Some(x), MultiEraCert::AlonzoCompatible(x) => Some(x),

View file

@ -2,7 +2,7 @@ use pallas_primitives::alonzo;
use crate::MultiEraMeta; use crate::MultiEraMeta;
impl<'b> MultiEraMeta<'b> { impl MultiEraMeta<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::Metadata> { pub fn as_alonzo(&self) -> Option<&alonzo::Metadata> {
match self { match self {
Self::AlonzoCompatible(x) => Some(x), Self::AlonzoCompatible(x) => Some(x),

View file

@ -9,7 +9,7 @@ impl Default for MultiEraSigners<'_> {
} }
} }
impl<'b> MultiEraSigners<'b> { impl MultiEraSigners<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::RequiredSigners> { pub fn as_alonzo(&self) -> Option<&alonzo::RequiredSigners> {
match self { match self {
Self::AlonzoCompatible(x) => Some(x), Self::AlonzoCompatible(x) => Some(x),

View file

@ -2,7 +2,7 @@ use pallas_codec::utils::Nullable;
use crate::{MultiEraBlock, MultiEraTx}; use crate::{MultiEraBlock, MultiEraTx};
impl<'b> MultiEraTx<'b> { impl MultiEraTx<'_> {
fn aux_data_size(&self) -> usize { fn aux_data_size(&self) -> usize {
match self { match self {
MultiEraTx::AlonzoCompatible(x, _) => match &x.auxiliary_data { MultiEraTx::AlonzoCompatible(x, _) => match &x.auxiliary_data {
@ -44,7 +44,7 @@ impl<'b> MultiEraTx<'b> {
} }
} }
impl<'b> MultiEraBlock<'b> { impl MultiEraBlock<'_> {
pub fn body_size(&self) -> Option<usize> { pub fn body_size(&self) -> Option<usize> {
match self { match self {
MultiEraBlock::AlonzoCompatible(x, _) => { MultiEraBlock::AlonzoCompatible(x, _) => {

View file

@ -117,7 +117,7 @@ impl GenesisValues {
} }
} }
impl<'a> MultiEraBlock<'a> { impl MultiEraBlock<'_> {
pub fn epoch(&self, genesis: &GenesisValues) -> (Epoch, SubSlot) { pub fn epoch(&self, genesis: &GenesisValues) -> (Epoch, SubSlot) {
match self { match self {
MultiEraBlock::EpochBoundary(x) => (x.header.consensus_data.epoch_id, 0), MultiEraBlock::EpochBoundary(x) => (x.header.consensus_data.epoch_id, 0),

View file

@ -2,7 +2,7 @@ use pallas_primitives::alonzo;
use crate::MultiEraWithdrawals; use crate::MultiEraWithdrawals;
impl<'b> MultiEraWithdrawals<'b> { impl MultiEraWithdrawals<'_> {
pub fn as_alonzo(&self) -> Option<&alonzo::Withdrawals> { pub fn as_alonzo(&self) -> Option<&alonzo::Withdrawals> {
match self { match self {
Self::AlonzoCompatible(x) => Some(x), Self::AlonzoCompatible(x) => Some(x),

View file

@ -121,7 +121,7 @@ mod tests {
}); });
fn assert_script_data_hash_matches(bytes: &[u8], language_view: &LanguageView) { fn assert_script_data_hash_matches(bytes: &[u8], language_view: &LanguageView) {
let tx = MultiEraTx::decode(&bytes).unwrap(); let tx = MultiEraTx::decode(bytes).unwrap();
let tx = tx.as_conway().unwrap(); let tx = tx.as_conway().unwrap();
let witness = conway::WitnessSet::from(tx.transaction_witness_set.clone().unwrap()); let witness = conway::WitnessSet::from(tx.transaction_witness_set.clone().unwrap());

View file

@ -696,7 +696,8 @@ impl BuiltTransaction {
signature: Vec::from(signature.as_ref()).into(), signature: Vec::from(signature.as_ref()).into(),
}); });
tx.transaction_witness_set.vkeywitness = Some(NonEmptySet::from_vec(vkey_witnesses).unwrap()); tx.transaction_witness_set.vkeywitness =
Some(NonEmptySet::from_vec(vkey_witnesses).unwrap());
self.tx_bytes = tx.encode_fragment().unwrap().into(); self.tx_bytes = tx.encode_fragment().unwrap().into();
} }
@ -726,7 +727,7 @@ impl BuiltTransaction {
let mut tx = conway::Tx::decode_fragment(&self.tx_bytes.0) let mut tx = conway::Tx::decode_fragment(&self.tx_bytes.0)
.map_err(|_| TxBuilderError::CorruptedTxBytes)?; .map_err(|_| TxBuilderError::CorruptedTxBytes)?;
let mut vkey_witnesses = tx let mut vkey_witnesses = tx
.transaction_witness_set .transaction_witness_set
.vkeywitness .vkeywitness
.map(|x| x.to_vec()) .map(|x| x.to_vec())
@ -734,7 +735,8 @@ impl BuiltTransaction {
vkey_witnesses.retain(|x| *x.vkey != pk.0.to_vec()); vkey_witnesses.retain(|x| *x.vkey != pk.0.to_vec());
tx.transaction_witness_set.vkeywitness = Some(NonEmptySet::from_vec(vkey_witnesses).unwrap()); tx.transaction_witness_set.vkeywitness =
Some(NonEmptySet::from_vec(vkey_witnesses).unwrap());
self.tx_bytes = tx.encode_fragment().unwrap().into(); self.tx_bytes = tx.encode_fragment().unwrap().into();
} }

View file

@ -33,7 +33,7 @@ impl<'de> Deserialize<'de> for Bytes32 {
struct Bytes32Visitor; struct Bytes32Visitor;
impl<'de> Visitor<'de> for Bytes32Visitor { impl Visitor<'_> for Bytes32Visitor {
type Value = Bytes32; type Value = Bytes32;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -73,7 +73,7 @@ impl<'de> Deserialize<'de> for Hash28 {
struct Hash28Visitor; struct Hash28Visitor;
impl<'de> Visitor<'de> for Hash28Visitor { impl Visitor<'_> for Hash28Visitor {
type Value = Hash28; type Value = Hash28;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -113,7 +113,7 @@ impl<'de> Deserialize<'de> for Bytes {
struct BytesVisitor; struct BytesVisitor;
impl<'de> Visitor<'de> for BytesVisitor { impl Visitor<'_> for BytesVisitor {
type Value = Bytes; type Value = Bytes;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -265,7 +265,7 @@ impl<'de> Deserialize<'de> for RedeemerPurpose {
struct RedeemerPurposeVisitor; struct RedeemerPurposeVisitor;
impl<'de> Visitor<'de> for RedeemerPurposeVisitor { impl Visitor<'_> for RedeemerPurposeVisitor {
type Value = RedeemerPurpose; type Value = RedeemerPurpose;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -333,7 +333,7 @@ impl<'de> Deserialize<'de> for Address {
struct AddressVisitor; struct AddressVisitor;
impl<'de> Visitor<'de> for AddressVisitor { impl Visitor<'_> for AddressVisitor {
type Value = Address; type Value = Address;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
@ -370,7 +370,7 @@ impl<'de> Deserialize<'de> for Bytes64 {
struct Bytes64Visitor; struct Bytes64Visitor;
impl<'de> Visitor<'de> for Bytes64Visitor { impl Visitor<'_> for Bytes64Visitor {
type Value = Bytes64; type Value = Bytes64;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {

View file

@ -65,7 +65,7 @@ impl<C: LedgerContext> Mapper<C> {
u5c::Redeemer { u5c::Redeemer {
purpose: self.map_purpose(&x.tag()).into(), purpose: self.map_purpose(&x.tag()).into(),
payload: self.map_plutus_datum(x.data()).into(), payload: self.map_plutus_datum(x.data()).into(),
index: x.index().into(), index: x.index(),
ex_units: Some(u5c::ExUnits { ex_units: Some(u5c::ExUnits {
steps: x.ex_units().steps, steps: x.ex_units().steps,
memory: x.ex_units().mem, memory: x.ex_units().mem,
@ -613,7 +613,7 @@ mod tests {
// ) // )
// .unwrap(); // .unwrap();
let expected: serde_json::Value = serde_json::from_str(&json_str).unwrap(); let expected: serde_json::Value = serde_json::from_str(json_str).unwrap();
assert_eq!(expected, current) assert_eq!(expected, current)
} }