Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix lint warnings #582

Merged
merged 2 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions examples/crawler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use pallas::{

// An arbitrary predicate to decide whether to save the block or not;
// fill in with your own purpose built logic
async fn block_matches<'a>(block: &MultiEraBlock<'a>) -> bool {
async fn block_matches(block: &MultiEraBlock<'_>) -> bool {
// As an example, we save any blocks that have an "Update proposal" in any era
block.update().is_some() || block.txs().iter().any(|tx| tx.update().is_some())
}

// An arbitrary predicate to decide whether to save the transaction or not;
// fill in with your own purpose built logic
async fn tx_matches<'a>(_tx: &MultiEraTx<'a>) -> bool {
async fn tx_matches(_tx: &MultiEraTx<'_>) -> bool {
false
}

Expand All @@ -41,7 +41,8 @@ async fn main() -> Result<()> {
.await?;

loop {
// We either request the next block, or wait until we're told that the block is ready
// We either request the next block, or wait until we're told that the block is
// ready
let next = client.chainsync().request_or_await_next().await?;
// And depending on the message we receive...
match next {
Expand Down Expand Up @@ -101,7 +102,8 @@ struct Args {
/// The network magic used to handshake with that node; defaults to mainnet
#[arg(short, long, env("CARDANO_NETWORK_MAGIC"), default_value_t = 764824073)]
pub network_magic: u64,
/// A list of points to use when trying to decide a startpoint; defaults to origin
/// A list of points to use when trying to decide a startpoint; defaults to
/// origin
#[arg(short, long, value_parser = parse_point)]
pub point: Vec<Point>,
/// Download only the first block found that matches this criteria
Expand Down
11 changes: 7 additions & 4 deletions pallas-applying/src/babbage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::utils::{
compute_plutus_v1_script_hash, compute_plutus_v2_script_hash, empty_value, get_babbage_tx_size,
get_lovelace_from_alonzo_val, get_payment_part, get_shelley_address, get_val_size_in_words,
is_byron_address, lovelace_diff_or_fail, mk_alonzo_vk_wits_check_list, values_are_equal,
verify_signature,
verify_signature, BabbageProtParams,
PostAlonzoError::*,
BabbageProtParams, UTxOs,
UTxOs,
ValidationError::{self, *},
ValidationResult,
};
Expand Down Expand Up @@ -261,8 +261,11 @@ fn check_collaterals_assets(
None => Value::Coin(0),
};
// The balance between collateral inputs and output contains only lovelace.
let paid_collateral: u64 =
lovelace_diff_or_fail(&coll_input, &coll_return, &PostAlonzo(NonLovelaceCollateral))?;
let paid_collateral: u64 = lovelace_diff_or_fail(
&coll_input,
&coll_return,
&PostAlonzo(NonLovelaceCollateral),
)?;
let fee_percentage: u64 = tx_body.fee * prot_pps.collateral_percentage as u64;
// The balance is not lower than the minimum allowed.
if paid_collateral * 100 < fee_percentage {
Expand Down
54 changes: 25 additions & 29 deletions pallas-applying/src/conway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use crate::utils::{
conway_add_values, conway_get_val_size_in_words, conway_lovelace_diff_or_fail,
conway_values_are_equal, get_conway_tx_size, get_lovelace_from_conway_val, get_payment_part,
get_shelley_address, is_byron_address, mk_alonzo_vk_wits_check_list, verify_signature,
ConwayProtParams,
PostAlonzoError::*,
ConwayProtParams, UTxOs,
UTxOs,
ValidationError::{self, *},
ValidationResult,
};
Expand All @@ -19,12 +20,12 @@ use pallas_codec::{
use pallas_primitives::{
babbage,
conway::{
Language, Mint, MintedTransactionBody, MintedTransactionOutput, MintedTx,
MintedWitnessSet, NativeScript, PseudoDatumOption, PseudoScript, PseudoTransactionOutput,
Redeemer, Redeemers, RedeemersKey, RequiredSigners, VKeyWitness, Value,
Language, Mint, MintedTransactionBody, MintedTransactionOutput, MintedTx, MintedWitnessSet,
NativeScript, PseudoDatumOption, PseudoScript, PseudoTransactionOutput, Redeemer,
Redeemers, RedeemersKey, RequiredSigners, VKeyWitness, Value,
},
AddrKeyhash, Hash, NonEmptyKeyValuePairs, PlutusData, PlutusScript, PolicyId,
PositiveCoin, TransactionInput,
AddrKeyhash, Hash, NonEmptyKeyValuePairs, PlutusData, PlutusScript, PolicyId, PositiveCoin,
TransactionInput,
};
use pallas_traverse::{MultiEraInput, MultiEraOutput, OriginalHash};
use std::ops::Deref;
Expand Down Expand Up @@ -166,17 +167,17 @@ fn check_min_fee(

fn presence_of_plutus_scripts(mtx: &MintedTx) -> bool {
let minted_witness_set: &MintedWitnessSet = &mtx.transaction_witness_set;
let plutus_v1_scripts: &[PlutusScript<1>] = &minted_witness_set
let plutus_v1_scripts: &[PlutusScript<1>] = minted_witness_set
.plutus_v1_script
.as_ref()
.map(|x| x.as_slice())
.unwrap_or(&[]);
let plutus_v2_scripts: &[PlutusScript<2>] = &minted_witness_set
let plutus_v2_scripts: &[PlutusScript<2>] = minted_witness_set
.plutus_v2_script
.as_ref()
.map(|x| x.as_slice())
.unwrap_or(&[]);
let plutus_v3_scripts: &[PlutusScript<3>] = &minted_witness_set
let plutus_v3_scripts: &[PlutusScript<3>] = minted_witness_set
.plutus_v3_script
.as_ref()
.map(|x| x.as_slice())
Expand Down Expand Up @@ -395,7 +396,8 @@ fn get_produced(tx_body: &MintedTransactionBody) -> Result<Value, ValidationErro
let amount = output.amount.clone();
match amount {
babbage::Value::Coin(coin) => {
res = conway_add_values(&res, &Value::Coin(coin), &PostAlonzo(NegativeValue))?
res =
conway_add_values(&res, &Value::Coin(coin), &PostAlonzo(NegativeValue))?
}
babbage::Value::Multiasset(coin, assets) => {
let mut conway_assets = Vec::new();
Expand Down Expand Up @@ -1699,11 +1701,9 @@ fn check_script_data_hash(
}
}
}
},
(None, None) => {
Err(PostAlonzo(ScriptIntegrityHash))
}
(Some(_), None) => Err(PostAlonzo(ScriptIntegrityHash)),
(None, None) => Err(PostAlonzo(ScriptIntegrityHash)),
(Some(_), None) => Err(PostAlonzo(ScriptIntegrityHash)),
},
None => {
let plutus_data = mtx
Expand All @@ -1713,14 +1713,14 @@ fn check_script_data_hash(
.map(|x| x.to_vec());
let redeemer_is_empty = mtx.transaction_witness_set.redeemer.is_none();

if !redeemer_is_empty{
if !redeemer_is_empty {
if option_vec_is_empty(&plutus_data) {
match &mtx
.transaction_witness_set
.redeemer
.clone()
.unwrap()
.unwrap()
.transaction_witness_set
.redeemer
.clone()
.unwrap()
.unwrap()
{
Redeemers::List(redeemers) => {
if !option_vec_is_empty(&Some(redeemers.clone().to_vec())) {
Expand All @@ -1737,7 +1737,7 @@ fn check_script_data_hash(
} else {
Err(PostAlonzo(ScriptIntegrityHash))
}
}else {
} else {
Ok(())
}
}
Expand Down Expand Up @@ -1837,16 +1837,14 @@ fn cost_model_cbor(
hex::decode(
"a10198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0223accc0a1a0374f693194a1f0a1a02515e841980b30a"
).unwrap()
}
else if !tx_languages.contains(&Language::PlutusV1)
} else if !tx_languages.contains(&Language::PlutusV1)
&& !tx_languages.contains(&Language::PlutusV2)
&& tx_languages.contains(&Language::PlutusV3)
{
hex::decode(
"a1029901291a000189b41901a401011903e818ad00011903e819ea350401192baf18201a000312591920a404193e801864193e801864193e801864193e801864193e801864193e80186418641864193e8018641a000170a718201a00020782182019f016041a0001194a18b2000119568718201a0001643519030104021a00014f581a0001e143191c893903831906b419022518391a00014f580001011903e819a7a90402195fe419733a1826011a000db464196a8f0119ca3f19022e011999101903e819ecb2011a00022a4718201a000144ce1820193bc318201a0001291101193371041956540a197147184a01197147184a0119a9151902280119aecd19021d0119843c18201a00010a9618201a00011aaa1820191c4b1820191cdf1820192d1a18201a00014f581a0001e143191c893903831906b419022518391a00014f5800011a0001614219020700011a000122c118201a00014f581a0001e143191c893903831906b419022518391a00014f580001011a00014f581a0001e143191c893903831906b419022518391a00014f5800011a000e94721a0003414000021a0004213c19583c041a00163cad19fc3604194ff30104001a00022aa818201a000189b41901a401011a00013eff182019e86a1820194eae182019600c1820195108182019654d182019602f18201a0290f1e70a1a032e93af1937fd0a1a0298e40b1966c40a193e801864193e8018641a000eaf1f121a002a6e06061a0006be98011a0321aac7190eac121a00041699121a048e466e1922a4121a0327ec9a121a001e743c18241a0031410f0c1a000dbf9e011a09f2f6d31910d318241a0004578218241a096e44021967b518241a0473cee818241a13e62472011a0f23d40118481a00212c5618481a0022814619fc3b041a00032b00192076041a0013be0419702c183f00011a000f59d919aa6718fb00011a000187551902d61902cf00011a000187551902d61902cf00011a000187551902d61902cf00011a0001a5661902a800011a00017468011a00044a391949a000011a0002bfe2189f01011a00026b371922ee00011a00026e9219226d00011a0001a3e2190ce2011a00019e4919028f011a001df8bb195fc803"
).unwrap()
}
else {
} else {
hex::decode(
"a241005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0374f693194a1f0aff0198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0223accc0a1a0374f693194a1f0a1a02515e841980b30a"
).unwrap()
Expand Down Expand Up @@ -1913,16 +1911,14 @@ fn cost_model_cbor(
hex::decode(
"a10198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0223accc0a1a0374f693194a1f0a1a02515e841980b30a"
).unwrap()
}
else if !tx_languages.contains(&Language::PlutusV1)
} else if !tx_languages.contains(&Language::PlutusV1)
&& !tx_languages.contains(&Language::PlutusV2)
&& tx_languages.contains(&Language::PlutusV3)
{
hex::decode(
"a1029901291a000189b41901a401011903e818ad00011903e819ea350401192baf18201a000312591920a404193e801864193e801864193e801864193e801864193e801864193e80186418641864193e8018641a000170a718201a00020782182019f016041a0001194a18b2000119568718201a0001643519030104021a00014f581a0001e143191c893903831906b419022518391a00014f580001011903e819a7a90402195fe419733a1826011a000db464196a8f0119ca3f19022e011999101903e819ecb2011a00022a4718201a000144ce1820193bc318201a0001291101193371041956540a197147184a01197147184a0119a9151902280119aecd19021d0119843c18201a00010a9618201a00011aaa1820191c4b1820191cdf1820192d1a18201a00014f581a0001e143191c893903831906b419022518391a00014f5800011a0001614219020700011a000122c118201a00014f581a0001e143191c893903831906b419022518391a00014f580001011a00014f581a0001e143191c893903831906b419022518391a00014f5800011a000e94721a0003414000021a0004213c19583c041a00163cad19fc3604194ff30104001a00022aa818201a000189b41901a401011a00013eff182019e86a1820194eae182019600c1820195108182019654d182019602f18201a0290f1e70a1a032e93af1937fd0a1a0298e40b1966c40a193e801864193e8018641a000eaf1f121a002a6e06061a0006be98011a0321aac7190eac121a00041699121a048e466e1922a4121a0327ec9a121a001e743c18241a0031410f0c1a000dbf9e011a09f2f6d31910d318241a0004578218241a096e44021967b518241a0473cee818241a13e62472011a0f23d40118481a00212c5618481a0022814619fc3b041a00032b00192076041a0013be0419702c183f00011a000f59d919aa6718fb00011a000187551902d61902cf00011a000187551902d61902cf00011a000187551902d61902cf00011a0001a5661902a800011a00017468011a00044a391949a000011a0002bfe2189f01011a00026b371922ee00011a00026e9219226d00011a0001a3e2190ce2011a00019e4919028f011a001df8bb195fc803"
).unwrap()
}
else {
} else {
hex::decode(
"a241005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0374f693194a1f0aff0198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a0223accc0a1a0374f693194a1f0a1a02515e841980b30a"
).unwrap()
Expand Down
4 changes: 2 additions & 2 deletions pallas-applying/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pub mod alonzo;
pub mod babbage;
pub mod byron;
pub mod conway;
pub mod shelley_ma;
pub mod utils;
pub mod conway;

use alonzo::validate_alonzo_tx;
use babbage::validate_babbage_tx;
Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn validate_tx(
env.network_id(),
),
_ => Err(TxAndProtParamsDiffer),
}
},
(_, None) => Err(EnvMissingAccountState),
}
}
Loading
Loading