diff --git a/chain/rust/src/address.rs b/chain/rust/src/address.rs index 28e8eea6..53767438 100644 --- a/chain/rust/src/address.rs +++ b/chain/rust/src/address.rs @@ -1363,7 +1363,7 @@ mod tests { let script_hash = ScriptHash::from_raw_bytes(oneof_native_script.hash().to_raw_bytes()).unwrap(); - let spend_cred = StakeCredential::new_script(script_hash.clone()); + let spend_cred = StakeCredential::new_script(script_hash); let stake_cred = StakeCredential::new_script(script_hash); let addr_net_0 = BaseAddress::new( NetworkInfo::testnet().network_id(), diff --git a/chain/rust/src/assets/utils.rs b/chain/rust/src/assets/utils.rs index 370e1339..76075377 100644 --- a/chain/rust/src/assets/utils.rs +++ b/chain/rust/src/assets/utils.rs @@ -158,7 +158,7 @@ where // asset name is missing from left hand side if !T::min_value().is_zero() { bundle.set( - policy.clone(), + *policy, asset_name.clone(), T::zero().clamped_sub(rhs_amount), ); @@ -169,7 +169,7 @@ where // policy id missing from left hand side if !T::min_value().is_zero() { bundle.set( - policy.clone(), + *policy, asset_name.clone(), T::zero().clamped_sub(rhs_amount), ); @@ -210,7 +210,7 @@ where let mut bundle = self.0.clone(); for (policy, assets) in rhs.0.iter() { for (asset_name, amount) in assets.iter() { - match bundle.entry(policy.clone()) { + match bundle.entry(*policy) { Entry::Occupied(mut assets) => { match assets.get_mut().entry(asset_name.clone()) { Entry::Occupied(mut assets2) => { @@ -268,7 +268,7 @@ where }, None => { // policy id missing from left hand side - return Err(AssetArithmeticError::PolicyIdDoesntExist(policy.clone())); + return Err(AssetArithmeticError::PolicyIdDoesntExist(*policy)); } } } @@ -296,7 +296,7 @@ impl Mint { acc }); if !assets.is_empty() { - acc.insert(policy.clone(), new_assets); + acc.insert(*policy, new_assets); } acc }) @@ -693,7 +693,7 @@ impl Deserialize for Value { multiasset_value_value_encodings, ); if multiasset_table - .insert(multiasset_key.clone(), multiasset_value) + .insert(multiasset_key, multiasset_value) .is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str( @@ -702,9 +702,9 @@ impl Deserialize for Value { .into()); } multiasset_key_encodings - .insert(multiasset_key.clone(), multiasset_key_encoding); + .insert(multiasset_key, multiasset_key_encoding); multiasset_value_encodings.insert( - multiasset_key.clone(), + multiasset_key, (multiasset_value_encoding, multiasset_value_value_encodings), ); } diff --git a/chain/rust/src/builders/certificate_builder.rs b/chain/rust/src/builders/certificate_builder.rs index c6d1f52d..ebe41fcf 100644 --- a/chain/rust/src/builders/certificate_builder.rs +++ b/chain/rust/src/builders/certificate_builder.rs @@ -29,28 +29,28 @@ pub fn cert_required_wits(cert: &Certificate, required_witnesses: &mut RequiredW Certificate::StakeRegistration(_cert) => (), Certificate::StakeDeregistration(cert) => match &cert.stake_credential { StakeCredential::Script { hash, .. } => { - required_witnesses.add_script_hash(hash.clone()); + required_witnesses.add_script_hash(*hash); } StakeCredential::PubKey { hash, .. } => { - required_witnesses.add_vkey_key_hash(hash.clone()); + required_witnesses.add_vkey_key_hash(*hash); } }, Certificate::StakeDelegation(cert) => match &cert.stake_credential { StakeCredential::Script { hash, .. } => { - required_witnesses.add_script_hash(hash.clone()); + required_witnesses.add_script_hash(*hash); } StakeCredential::PubKey { hash, .. } => { - required_witnesses.add_vkey_key_hash(hash.clone()); + required_witnesses.add_vkey_key_hash(*hash); } }, Certificate::PoolRegistration(cert) => { for owner in &cert.pool_params.pool_owners { - required_witnesses.add_vkey_key_hash(owner.clone()); + required_witnesses.add_vkey_key_hash(*owner); } - required_witnesses.add_vkey_key_hash(cert.pool_params.operator.clone()); + required_witnesses.add_vkey_key_hash(cert.pool_params.operator); } Certificate::PoolRetirement(cert) => { - required_witnesses.add_vkey_key_hash(cert.ed25519_key_hash.clone()); + required_witnesses.add_vkey_key_hash(cert.ed25519_key_hash); } Certificate::RegCert(_cert) => todo!(), Certificate::UnregCert(_cert) => todo!(), @@ -78,28 +78,28 @@ pub fn add_cert_vkeys( Certificate::StakeRegistration(_cert) => {} Certificate::StakeDeregistration(cert) => match &cert.stake_credential { StakeCredential::Script { hash, .. } => { - return Err(CertBuilderError::ExpectedKeyHash(hash.clone())) + return Err(CertBuilderError::ExpectedKeyHash(*hash)) } StakeCredential::PubKey { hash, .. } => { - vkeys.insert(hash.clone()); + vkeys.insert(*hash); } }, Certificate::StakeDelegation(cert) => match &cert.stake_credential { StakeCredential::Script { hash, .. } => { - return Err(CertBuilderError::ExpectedKeyHash(hash.clone())) + return Err(CertBuilderError::ExpectedKeyHash(*hash)) } StakeCredential::PubKey { hash, .. } => { - vkeys.insert(hash.clone()); + vkeys.insert(*hash); } }, Certificate::PoolRegistration(cert) => { for owner in &cert.pool_params.pool_owners { - vkeys.insert(owner.clone()); + vkeys.insert(*owner); } - vkeys.insert(cert.pool_params.operator.clone()); + vkeys.insert(cert.pool_params.operator); } Certificate::PoolRetirement(cert) => { - vkeys.insert(cert.ed25519_key_hash.clone()); + vkeys.insert(cert.ed25519_key_hash); } Certificate::RegCert(_cert) => todo!(), Certificate::UnregCert(_cert) => todo!(), @@ -209,7 +209,7 @@ impl SingleCertificateBuilder { let mut required_wits = RequiredWitnessSet::default(); required_signers .iter() - .for_each(|required_signer| required_wits.add_vkey_key_hash(required_signer.clone())); + .for_each(|required_signer| required_wits.add_vkey_key_hash(*required_signer)); cert_required_wits(&self.cert, &mut required_wits); let mut required_wits_left = required_wits.clone(); diff --git a/chain/rust/src/builders/input_builder.rs b/chain/rust/src/builders/input_builder.rs index e85ed960..d7905d6f 100644 --- a/chain/rust/src/builders/input_builder.rs +++ b/chain/rust/src/builders/input_builder.rs @@ -26,12 +26,12 @@ pub fn input_required_wits( if let Some(cred) = utxo_info.address().payment_cred() { match cred { StakeCredential::PubKey { hash, .. } => { - required_witnesses.add_vkey_key_hash(hash.clone()); + required_witnesses.add_vkey_key_hash(*hash); } StakeCredential::Script { hash, .. } => { - required_witnesses.add_script_hash(hash.clone()); + required_witnesses.add_script_hash(*hash); if let Some(data_hash) = utxo_info.datum_hash() { - required_witnesses.add_plutus_datum_hash(data_hash.clone()); + required_witnesses.add_plutus_datum_hash(*data_hash); // note: redeemer is required as well // but we can't know the index, so we rely on the tx builder to satisfy this requirement } @@ -138,7 +138,7 @@ impl SingleInputBuilder { let mut required_wits = RequiredWitnessSet::default(); required_signers .iter() - .for_each(|required_signer| required_wits.add_vkey_key_hash(required_signer.clone())); + .for_each(|required_signer| required_wits.add_vkey_key_hash(*required_signer)); input_required_wits(&self.utxo_info, &mut required_wits); let mut required_wits_left = required_wits.clone(); diff --git a/chain/rust/src/builders/mint_builder.rs b/chain/rust/src/builders/mint_builder.rs index 90d8243f..2c934c3e 100644 --- a/chain/rust/src/builders/mint_builder.rs +++ b/chain/rust/src/builders/mint_builder.rs @@ -37,7 +37,7 @@ impl SingleMintBuilder { ) -> MintBuilderResult { let mut required_wits = RequiredWitnessSet::default(); let script_hash = native_script.hash(); - required_wits.add_script_hash(script_hash.clone()); + required_wits.add_script_hash(script_hash); MintBuilderResult { assets: self.assets, @@ -60,8 +60,8 @@ impl SingleMintBuilder { let script_hash = partial_witness.script.hash(); required_signers .iter() - .for_each(|required_signer| required_wits.add_vkey_key_hash(required_signer.clone())); - required_wits.add_script_hash(script_hash.clone()); + .for_each(|required_signer| required_wits.add_vkey_key_hash(*required_signer)); + required_wits.add_script_hash(script_hash); MintBuilderResult { assets: self.assets, diff --git a/chain/rust/src/builders/redeemer_builder.rs b/chain/rust/src/builders/redeemer_builder.rs index 354f0a7d..284c142d 100644 --- a/chain/rust/src/builders/redeemer_builder.rs +++ b/chain/rust/src/builders/redeemer_builder.rs @@ -171,11 +171,11 @@ impl RedeemerSetBuilder { }; if let Some(data) = plutus_data { self.mint.insert( - result.policy_id.clone(), + result.policy_id, Some(UntaggedRedeemerPlaceholder::JustData(data.clone())), ); } else { - self.mint.insert(result.policy_id.clone(), None); + self.mint.insert(result.policy_id, None); } } diff --git a/chain/rust/src/builders/tx_builder.rs b/chain/rust/src/builders/tx_builder.rs index 19aa7fa7..628785b3 100644 --- a/chain/rust/src/builders/tx_builder.rs +++ b/chain/rust/src/builders/tx_builder.rs @@ -683,7 +683,7 @@ impl TransactionBuilder { .is_none() { Err(TxBuilderError::RefScriptNotFound( - ref_script.clone(), + *ref_script, self.witness_builders .witness_set_builder .required_wits @@ -889,17 +889,14 @@ impl TransactionBuilder { .witness_set_builder .add_required_wits(result.required_wits.clone()); let mut mint = self.mint.take().unwrap_or_default(); - let combined_assets = mint - .deref_mut() - .entry(result.policy_id.clone()) - .or_default(); + let combined_assets = mint.deref_mut().entry(result.policy_id).or_default(); for (asset_name, asset_value) in result.assets.iter() { if combined_assets .insert(asset_name.clone(), *asset_value) .is_some() { return Err(TxBuilderError::DuplicateMint( - result.policy_id.clone(), + result.policy_id, asset_name.clone(), )); } @@ -980,7 +977,7 @@ impl TransactionBuilder { if let InputAggregateWitnessData::PlutusScript(_, required_signers, _) = data { required_signers .iter() - .for_each(|signer| self.add_required_signer(signer.clone())); + .for_each(|signer| self.add_required_signer(*signer)); } } self.witness_builders @@ -992,7 +989,7 @@ impl TransactionBuilder { pub fn add_required_signer(&mut self, hash: Ed25519KeyHash) { let mut set = RequiredWitnessSet::new(); - set.add_vkey_key_hash(hash.clone()); + set.add_vkey_key_hash(hash); self.witness_builders .witness_set_builder .add_required_wits(set); @@ -1593,7 +1590,7 @@ pub fn add_change_if_needed( if will_adding_asset_make_output_overflow( &output, &rebuilt_assets, - (policy.clone(), asset_name.clone(), *value), + (*policy, asset_name.clone(), *value), max_value_size, coins_per_utxo_byte, ) { @@ -1601,7 +1598,7 @@ pub fn add_change_if_needed( // so we want to split into multiple outputs, for that we... // 1. insert the current assets as they are, as this won't overflow - next_nft.insert(policy.clone(), rebuilt_assets); + next_nft.insert(*policy, rebuilt_assets); val.multiasset = next_nft; output.set_amount(output.amount().checked_add(&val)?); change_assets.push(output.amount().multiasset.clone()); @@ -1626,7 +1623,7 @@ pub fn add_change_if_needed( rebuilt_assets.insert(asset_name.clone(), *value); } - next_nft.insert(policy.clone(), rebuilt_assets); + next_nft.insert(*policy, rebuilt_assets); val.multiasset = next_nft; output.set_amount(output.amount().checked_add(&val)?); @@ -2550,7 +2547,7 @@ mod tests { tx_builder.add_mint(result).unwrap(); let mut mass = MultiAsset::new(); - mass.set(policy_id.clone(), name.clone(), amount_sent); + mass.set(policy_id, name.clone(), amount_sent); // One coin and the minted asset goes into the output let mut output_amount = Value::from(264); @@ -2613,7 +2610,7 @@ mod tests { .iter() .map(|input| { let mut multiasset = MultiAsset::new(); - multiasset.set(policy_id.clone(), name.clone(), *input); + multiasset.set(policy_id, name.clone(), *input); multiasset }) .collect::>(); @@ -2695,7 +2692,7 @@ mod tests { .iter() .map(|input| { let mut multiasset = MultiAsset::new(); - multiasset.set(policy_id.clone(), name.clone(), *input); + multiasset.set(*policy_id, name.clone(), *input); multiasset }) .collect::>(); @@ -2782,7 +2779,7 @@ mod tests { .iter() .map(|input| { let mut multiasset = MultiAsset::new(); - multiasset.set(policy_id.clone(), name.clone(), *input); + multiasset.set(*policy_id, name.clone(), *input); multiasset }) .collect::>(); @@ -3037,7 +3034,7 @@ mod tests { // add an output that uses up all the token but leaves ADA let input_amount = { let mut input_multiasset = MultiAsset::new(); - input_multiasset.set(policy_id.clone(), name.clone(), 100); + input_multiasset.set(policy_id, name.clone(), 100); Value::new(5_000_000, input_multiasset) }; @@ -3109,7 +3106,7 @@ mod tests { let multiasset = policy_ids.iter().zip(names.iter()).fold( MultiAsset::new(), |mut acc, (policy_id, name)| { - acc.set(policy_id.clone(), name.clone(), 500); + acc.set(*policy_id, name.clone(), 500); acc }, ); @@ -3244,7 +3241,7 @@ mod tests { let multiasset = policy_ids.iter().zip(names.iter()).fold( MultiAsset::new(), |mut acc, (policy_id, name)| { - acc.set(policy_id.clone(), name.clone(), 500); + acc.set(*policy_id, name.clone(), 500); acc }, ); @@ -3417,10 +3414,10 @@ mod tests { let mut output_value = Value::from(415); let mut output_ma = MultiAsset::new(); - output_ma.set(pid1.clone(), asset_name1.clone(), 5); - output_ma.set(pid1.clone(), asset_name2.clone(), 1); - output_ma.set(pid2.clone(), asset_name2.clone(), 2); - output_ma.set(pid2.clone(), asset_name3.clone(), 4); + output_ma.set(pid1, asset_name1.clone(), 5); + output_ma.set(pid1, asset_name2.clone(), 1); + output_ma.set(pid2, asset_name2.clone(), 2); + output_ma.set(pid2, asset_name3.clone(), 4); output_value.multiasset = output_ma; tx_builder .add_output(SingleOutputBuilderResult::new(TransactionOutput::new( @@ -3437,39 +3434,39 @@ mod tests { // should not be taken let mut ma1 = MultiAsset::new(); - ma1.set(pid1.clone(), asset_name1.clone(), 10); - ma1.set(pid1.clone(), asset_name2.clone(), 1); - ma1.set(pid2.clone(), asset_name2.clone(), 2); + ma1.set(pid1, asset_name1.clone(), 10); + ma1.set(pid1, asset_name2.clone(), 1); + ma1.set(pid2, asset_name2.clone(), 2); let input1 = make_input(1u8, Value::new(200, ma1)); tx_builder.add_utxo(input1); // taken first to satisfy pid1:asset_name1 (but also satisfies pid2:asset_name3) let mut ma2 = MultiAsset::new(); - ma2.set(pid1.clone(), asset_name1.clone(), 20); - ma2.set(pid2.clone(), asset_name3.clone(), 4); + ma2.set(pid1, asset_name1.clone(), 20); + ma2.set(pid2, asset_name3.clone(), 4); let input2 = make_input(2u8, Value::new(10, ma2)); tx_builder.add_utxo(input2.clone()); // taken second to satisfy pid1:asset_name2 (but also satisfies pid2:asset_name1) let mut ma3 = MultiAsset::new(); - ma3.set(pid2.clone(), asset_name1.clone(), 5); - ma3.set(pid1.clone(), asset_name2.clone(), 15); + ma3.set(pid2, asset_name1.clone(), 5); + ma3.set(pid1, asset_name2.clone(), 15); let input3 = make_input(3u8, Value::new(50, ma3)); tx_builder.add_utxo(input3.clone()); // should not be taken either let mut ma4 = MultiAsset::new(); - ma4.set(pid1.clone(), asset_name1.clone(), 10); - ma4.set(pid1.clone(), asset_name2.clone(), 10); + ma4.set(pid1, asset_name1.clone(), 10); + ma4.set(pid1, asset_name2.clone(), 10); let input4 = make_input(4u8, Value::new(10, ma4)); tx_builder.add_utxo(input4); // taken third to satisfy pid2:asset_name_2 let mut ma5 = MultiAsset::new(); - ma5.set(pid1.clone(), asset_name2.clone(), 10); - ma5.set(pid2.clone(), asset_name2.clone(), 3); + ma5.set(pid1, asset_name2.clone(), 10); + ma5.set(pid2, asset_name2.clone(), 3); let input5 = make_input(5u8, Value::new(10, ma5)); tx_builder.add_utxo(input5.clone()); @@ -3532,10 +3529,10 @@ mod tests { let asset_name3 = AssetName::new(vec![3u8; 9]).unwrap(); let mut output_ma = MultiAsset::new(); - output_ma.set(pid1.clone(), asset_name1.clone(), 5); - output_ma.set(pid1.clone(), asset_name2.clone(), 1); - output_ma.set(pid2.clone(), asset_name2.clone(), 2); - output_ma.set(pid2.clone(), asset_name3.clone(), 4); + output_ma.set(pid1, asset_name1.clone(), 5); + output_ma.set(pid1, asset_name2.clone(), 1); + output_ma.set(pid2, asset_name2.clone(), 2); + output_ma.set(pid2, asset_name3.clone(), 4); let output_value = Value::new(415, output_ma); tx_builder .add_output(SingleOutputBuilderResult::new(TransactionOutput::new( @@ -3550,33 +3547,33 @@ mod tests { tx_builder.add_utxo(make_input(0u8, Value::from(150))); let mut ma1 = MultiAsset::new(); - ma1.set(pid1.clone(), asset_name1.clone(), 10); - ma1.set(pid1.clone(), asset_name2.clone(), 1); - ma1.set(pid2.clone(), asset_name2.clone(), 2); + ma1.set(pid1, asset_name1.clone(), 10); + ma1.set(pid1, asset_name2.clone(), 1); + ma1.set(pid2, asset_name2.clone(), 2); let input1 = make_input(1u8, Value::new(200, ma1)); tx_builder.add_utxo(input1); let mut ma2 = MultiAsset::new(); - ma2.set(pid1.clone(), asset_name1.clone(), 20); - ma2.set(pid2.clone(), asset_name3.clone(), 4); + ma2.set(pid1, asset_name1.clone(), 20); + ma2.set(pid2, asset_name3.clone(), 4); let input2 = make_input(2u8, Value::new(10, ma2)); tx_builder.add_utxo(input2); let mut ma3 = MultiAsset::new(); - ma3.set(pid2.clone(), asset_name1.clone(), 5); - ma3.set(pid1.clone(), asset_name2.clone(), 15); + ma3.set(pid2, asset_name1.clone(), 5); + ma3.set(pid1, asset_name2.clone(), 15); let input3 = make_input(3u8, Value::new(50, ma3)); tx_builder.add_utxo(input3); let mut ma4 = MultiAsset::new(); - ma4.set(pid1.clone(), asset_name1, 10); - ma4.set(pid1.clone(), asset_name2.clone(), 10); + ma4.set(pid1, asset_name1, 10); + ma4.set(pid1, asset_name2.clone(), 10); let input4 = make_input(4u8, Value::new(10, ma4)); tx_builder.add_utxo(input4); let mut ma5 = MultiAsset::new(); ma5.set(pid1, asset_name2.clone(), 10); - ma5.set(pid2.clone(), asset_name2.clone(), 3); + ma5.set(pid2, asset_name2.clone(), 3); let input5 = make_input(5u8, Value::new(10, ma5)); tx_builder.add_utxo(input5); @@ -3585,7 +3582,7 @@ mod tests { tx_builder.add_utxo(make_input(7u8, Value::from(100))); let mut ma8 = MultiAsset::new(); - ma8.set(pid2.clone(), asset_name2, 10); + ma8.set(pid2, asset_name2, 10); let input8 = make_input(8u8, Value::new(10, ma8)); tx_builder.add_utxo(input8); @@ -3658,16 +3655,13 @@ mod tests { // we need to look up the values to ensure there's enough let mut input_values = BTreeMap::new(); for utxo in tx_builder.utxos.iter() { - input_values.insert( - utxo.input.transaction_id.clone(), - utxo.utxo_info.amount().clone(), - ); + input_values.insert(utxo.input.transaction_id, utxo.utxo_info.amount().clone()); } let mut encountered = std::collections::HashSet::new(); let mut input_total = Value::from(Coin::zero()); for input in tx.inputs.iter() { let txid = &input.transaction_id; - if !encountered.insert(txid.clone()) { + if !encountered.insert(*txid) { panic!("Input {:?} duplicated", txid); } let value = input_values.get(txid).unwrap(); @@ -4076,7 +4070,7 @@ mod tests { ]; let mut multiasset = MultiAsset::new(); for name in names.iter() { - multiasset.set(policy_id.clone(), name.clone(), 500); + multiasset.set(policy_id, name.clone(), 500); } let input_value = Value::new(1300, multiasset); @@ -4447,7 +4441,7 @@ mod tests { fn create_multiasset_one_asset(policy_id: &PolicyId) -> MultiAsset { let mut mint = MultiAsset::default(); - mint.set(policy_id.clone(), create_asset_name(), 1234); + mint.set(*policy_id, create_asset_name(), 1234); mint } @@ -4462,7 +4456,7 @@ mod tests { fn mint_script_and_policy_and_hash(x: u8) -> (NativeScript, PolicyId, Ed25519KeyHash) { let hash = fake_key_hash(x); - let mint_script = NativeScript::new_script_pubkey(hash.clone()); + let mint_script = NativeScript::new_script_pubkey(hash); let policy_id = mint_script.hash(); (mint_script, policy_id, hash) } @@ -4602,7 +4596,7 @@ mod tests { // One input from a related address let input = { - let cred = StakeCredential::new_script(policy_id1.clone()); + let cred = StakeCredential::new_script(policy_id1); let address = BaseAddress::new(NetworkInfo::testnet().network_id(), cred.clone(), cred) .to_address(); let builder = SingleInputBuilder::new( @@ -4804,7 +4798,7 @@ mod tests { let multiasset = { let mut multiasset = MultiAsset::new(); - multiasset.set(policy_id1.clone(), name.clone(), 1234); + multiasset.set(policy_id1, name.clone(), 1234); multiasset }; @@ -4874,7 +4868,7 @@ mod tests { let multiasset = { let mut multiasset = MultiAsset::new(); - multiasset.set(policy_id1.clone(), name.clone(), 1234); + multiasset.set(policy_id1, name.clone(), 1234); multiasset }; @@ -4942,8 +4936,8 @@ mod tests { .iter() .map(|input| { let mut multiasset = MultiAsset::new(); - multiasset.set(policy_id1.clone(), name.clone(), *input); - multiasset.set(policy_id2.clone(), name.clone(), *input); + multiasset.set(policy_id1, name.clone(), *input); + multiasset.set(policy_id2, name.clone(), *input); multiasset }) .collect::>(); @@ -5628,7 +5622,7 @@ mod tests { let script_base_address = BaseAddress::new( NetworkInfo::testnet().network_id(), - StakeCredential::new_script(script_hash.clone()), + StakeCredential::new_script(script_hash), stake_cred.clone(), ); diff --git a/chain/rust/src/builders/withdrawal_builder.rs b/chain/rust/src/builders/withdrawal_builder.rs index e48f5e4b..a626a8a8 100644 --- a/chain/rust/src/builders/withdrawal_builder.rs +++ b/chain/rust/src/builders/withdrawal_builder.rs @@ -21,10 +21,10 @@ pub fn withdrawal_required_wits( ) { match &address.payment { StakeCredential::PubKey { hash, .. } => { - required_witnesses.add_vkey_key_hash(hash.clone()); + required_witnesses.add_vkey_key_hash(*hash); } StakeCredential::Script { hash, .. } => { - required_witnesses.add_script_hash(hash.clone()); + required_witnesses.add_script_hash(*hash); // recall: no datum hash for reward withdrawals } } @@ -104,7 +104,7 @@ impl SingleWithdrawalBuilder { let mut required_wits = RequiredWitnessSet::default(); required_signers .iter() - .for_each(|required_signer| required_wits.add_vkey_key_hash(required_signer.clone())); + .for_each(|required_signer| required_wits.add_vkey_key_hash(*required_signer)); withdrawal_required_wits(&self.address, &mut required_wits); let mut required_wits_left = required_wits.clone(); diff --git a/chain/rust/src/builders/witness_builder.rs b/chain/rust/src/builders/witness_builder.rs index 3d5de0bb..fdff14ad 100644 --- a/chain/rust/src/builders/witness_builder.rs +++ b/chain/rust/src/builders/witness_builder.rs @@ -43,7 +43,7 @@ impl PlutusScriptWitness { pub fn hash(&self) -> ScriptHash { match self { - Self::Ref(hash) => hash.clone(), + Self::Ref(hash) => *hash, Self::Script(script) => script.hash(), } } @@ -633,7 +633,7 @@ mod tests { let mut required_wits = RequiredWitnessSet::new(); let key = fake_raw_key_public(0); let hash = key.hash(); - required_wits.add_vkey_key_hash(hash.clone()); + required_wits.add_vkey_key_hash(hash); let data = { let witness = { diff --git a/chain/rust/src/transaction/serialization.rs b/chain/rust/src/transaction/serialization.rs index 04610992..f37e7e20 100644 --- a/chain/rust/src/transaction/serialization.rs +++ b/chain/rust/src/transaction/serialization.rs @@ -2607,11 +2607,11 @@ impl Deserialize for TransactionBody { mint_value_value_encodings.insert(mint_value_key, mint_value_value_encoding); } let (mint_value, mint_value_encoding, mint_value_value_encodings) = (mint_value_table, mint_value_encoding, mint_value_value_encodings); - if mint_table.insert(mint_key.clone(), mint_value).is_some() { + if mint_table.insert(mint_key, mint_value).is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from("some complicated/unsupported type"))).into()); } - mint_key_encodings.insert(mint_key.clone(), mint_key_encoding); - mint_value_encodings.insert(mint_key.clone(), (mint_value_encoding, mint_value_value_encodings)); + mint_key_encodings.insert(mint_key, mint_key_encoding); + mint_value_encodings.insert(mint_key, (mint_value_encoding, mint_value_value_encodings)); } Ok((mint_table, mint_encoding, mint_key_encodings, mint_value_encodings)) })().map_err(|e| e.annotate("mint"))?; diff --git a/chain/rust/src/transaction/utils.rs b/chain/rust/src/transaction/utils.rs index d6e3b048..a6812a3d 100644 --- a/chain/rust/src/transaction/utils.rs +++ b/chain/rust/src/transaction/utils.rs @@ -58,7 +58,7 @@ impl TransactionOutput { Self::AlonzoFormatTxOut(tx_out) => tx_out .datum_hash .as_ref() - .map(|hash| DatumOption::new_hash(hash.clone())), + .map(|hash| DatumOption::new_hash(*hash)), Self::ConwayFormatTxOut(tx_out) => tx_out.datum_option.clone(), } } @@ -103,7 +103,7 @@ impl From<&NativeScript> for RequiredSignersSet { fn from_scripts(scripts: &[NativeScript]) -> RequiredSignersSet { scripts.iter().fold(BTreeSet::new(), |mut set, s| { RequiredSignersSet::from(s).iter().for_each(|pk| { - set.insert(pk.clone()); + set.insert(*pk); }); set }) @@ -111,7 +111,7 @@ impl From<&NativeScript> for RequiredSignersSet { match script { NativeScript::ScriptPubkey(spk) => { let mut set = BTreeSet::new(); - set.insert(spk.ed25519_key_hash.clone()); + set.insert(spk.ed25519_key_hash); set } NativeScript::ScriptAll(all) => from_scripts(&all.native_scripts), diff --git a/chain/wasm/src/assets/utils.rs b/chain/wasm/src/assets/utils.rs index 8d749df9..0daadf8a 100644 --- a/chain/wasm/src/assets/utils.rs +++ b/chain/wasm/src/assets/utils.rs @@ -61,7 +61,7 @@ impl MultiAsset { } pub fn keys(&self) -> PolicyIdList { - PolicyIdList(self.0.iter().map(|(k, _v)| k.clone()).collect::>()) + PolicyIdList(self.0.iter().map(|(k, _v)| *k).collect::>()) } /// Adds to multiassets together, checking value bounds. @@ -138,7 +138,7 @@ impl Mint { } pub fn keys(&self) -> PolicyIdList { - PolicyIdList(self.0.iter().map(|(k, _v)| k.clone()).collect::>()) + PolicyIdList(self.0.iter().map(|(k, _v)| *k).collect::>()) } /// Adds two mints together, checking value bounds. diff --git a/chain/wasm/src/block/mod.rs b/chain/wasm/src/block/mod.rs index c9bc255d..284f4f1a 100644 --- a/chain/wasm/src/block/mod.rs +++ b/chain/wasm/src/block/mod.rs @@ -102,7 +102,7 @@ impl HeaderBody { } pub fn prev_hash(&self) -> Option { - self.0.prev_hash.clone().map(std::convert::Into::into) + self.0.prev_hash.map(std::convert::Into::into) } pub fn issuer_vkey(&self) -> Vkey { @@ -110,7 +110,7 @@ impl HeaderBody { } pub fn vrf_vkey(&self) -> VRFVkey { - self.0.vrf_vkey.clone().into() + self.0.vrf_vkey.into() } pub fn vrf_result(&self) -> VRFCert { @@ -122,7 +122,7 @@ impl HeaderBody { } pub fn block_body_hash(&self) -> BlockBodyHash { - self.0.block_body_hash.clone().into() + self.0.block_body_hash.into() } pub fn operational_cert(&self) -> OperationalCert { @@ -171,7 +171,7 @@ impl_wasm_conversions!(cml_chain::block::OperationalCert, OperationalCert); #[wasm_bindgen] impl OperationalCert { pub fn hot_vkey(&self) -> KESVkey { - self.0.hot_vkey.clone().into() + self.0.hot_vkey.into() } pub fn sequence_number(&self) -> u64 { diff --git a/chain/wasm/src/byron/mod.rs b/chain/wasm/src/byron/mod.rs index 5a5bfcd4..db2fd94b 100644 --- a/chain/wasm/src/byron/mod.rs +++ b/chain/wasm/src/byron/mod.rs @@ -69,7 +69,7 @@ impl_wasm_cbor_event_serialize_api!(AddressContent); #[wasm_bindgen] impl AddressContent { pub fn address_id(&self) -> AddressId { - self.0.address_id.clone().into() + self.0.address_id.into() } pub fn addr_attributes(&self) -> AddrAttributes { @@ -187,9 +187,7 @@ impl SpendingData { pub fn as_spending_data_script(&self) -> Option { match &self.0 { - cml_chain::byron::SpendingData::SpendingDataScript(script) => { - Some(script.clone().into()) - } + cml_chain::byron::SpendingData::SpendingDataScript(script) => Some((*script).into()), _ => None, } } @@ -243,7 +241,7 @@ impl StakeDistribution { pub fn as_single_key(&self) -> Option { match &self.0 { cml_chain::byron::StakeDistribution::SingleKey(stakeholder_id) => { - Some(stakeholder_id.clone().into()) + Some((*stakeholder_id).into()) } _ => None, } diff --git a/chain/wasm/src/certs/mod.rs b/chain/wasm/src/certs/mod.rs index 519ead60..e2011851 100644 --- a/chain/wasm/src/certs/mod.rs +++ b/chain/wasm/src/certs/mod.rs @@ -444,14 +444,14 @@ impl Credential { pub fn as_pub_key(&self) -> Option { match &self.0 { - cml_chain::certs::Credential::PubKey { hash, .. } => Some(hash.clone().into()), + cml_chain::certs::Credential::PubKey { hash, .. } => Some((*hash).into()), _ => None, } } pub fn as_script(&self) -> Option { match &self.0 { - cml_chain::certs::Credential::Script { hash, .. } => Some(hash.clone().into()), + cml_chain::certs::Credential::Script { hash, .. } => Some((*hash).into()), _ => None, } } @@ -506,14 +506,14 @@ impl DRep { match &self.0 { cml_chain::certs::DRep::Key { ed25519_key_hash, .. - } => Some(ed25519_key_hash.clone().into()), + } => Some((*ed25519_key_hash).into()), _ => None, } } pub fn as_script(&self) -> Option { match &self.0 { - cml_chain::certs::DRep::Script { script_hash, .. } => Some(script_hash.clone().into()), + cml_chain::certs::DRep::Script { script_hash, .. } => Some((*script_hash).into()), _ => None, } } @@ -610,7 +610,7 @@ impl PoolMetadata { } pub fn pool_metadata_hash(&self) -> PoolMetadataHash { - self.0.pool_metadata_hash.clone().into() + self.0.pool_metadata_hash.into() } pub fn new(url: &Url, pool_metadata_hash: &PoolMetadataHash) -> Self { @@ -632,11 +632,11 @@ impl_wasm_conversions!(cml_chain::certs::PoolParams, PoolParams); #[wasm_bindgen] impl PoolParams { pub fn operator(&self) -> Ed25519KeyHash { - self.0.operator.clone().into() + self.0.operator.into() } pub fn vrf_keyhash(&self) -> VRFKeyHash { - self.0.vrf_keyhash.clone().into() + self.0.vrf_keyhash.into() } pub fn pledge(&self) -> Coin { @@ -724,7 +724,7 @@ impl_wasm_conversions!(cml_chain::certs::PoolRetirement, PoolRetirement); #[wasm_bindgen] impl PoolRetirement { pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn epoch(&self) -> Epoch { @@ -972,7 +972,7 @@ impl StakeDelegation { } pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn new(stake_credential: &StakeCredential, ed25519_key_hash: &Ed25519KeyHash) -> Self { @@ -1019,7 +1019,7 @@ impl StakeRegDelegCert { } pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn coin(&self) -> Coin { @@ -1075,7 +1075,7 @@ impl StakeVoteDelegCert { } pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn d_rep(&self) -> DRep { @@ -1113,7 +1113,7 @@ impl StakeVoteRegDelegCert { } pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn d_rep(&self) -> DRep { diff --git a/chain/wasm/src/crypto/mod.rs b/chain/wasm/src/crypto/mod.rs index a50d227f..f92b23d7 100644 --- a/chain/wasm/src/crypto/mod.rs +++ b/chain/wasm/src/crypto/mod.rs @@ -98,7 +98,7 @@ impl Nonce { pub fn as_hash(&self) -> Option { match &self.0 { - cml_chain::crypto::Nonce::Hash { hash, .. } => Some(hash.clone().into()), + cml_chain::crypto::Nonce::Hash { hash, .. } => Some((*hash).into()), _ => None, } } diff --git a/chain/wasm/src/governance/mod.rs b/chain/wasm/src/governance/mod.rs index bbd05be0..a8dfaca7 100644 --- a/chain/wasm/src/governance/mod.rs +++ b/chain/wasm/src/governance/mod.rs @@ -31,7 +31,7 @@ impl Anchor { } pub fn anchor_doc_hash(&self) -> AnchorDocHash { - self.0.anchor_doc_hash.clone().into() + self.0.anchor_doc_hash.into() } pub fn new(anchor_url: &Url, anchor_doc_hash: &AnchorDocHash) -> Self { @@ -86,7 +86,7 @@ impl Constitution { } pub fn script_hash(&self) -> Option { - self.0.script_hash.clone().map(std::convert::Into::into) + self.0.script_hash.map(std::convert::Into::into) } pub fn new(anchor: &Anchor, script_hash: Option) -> Self { @@ -255,7 +255,7 @@ impl_wasm_conversions!(cml_chain::governance::GovActionId, GovActionId); #[wasm_bindgen] impl GovActionId { pub fn transaction_id(&self) -> TransactionHash { - self.0.transaction_id.clone().into() + self.0.transaction_id.into() } pub fn gov_action_index(&self) -> u64 { @@ -554,7 +554,7 @@ impl Voter { cml_chain::governance::Voter::ConstitutionalCommitteeHotKeyHash { ed25519_key_hash, .. - } => Some(ed25519_key_hash.clone().into()), + } => Some((*ed25519_key_hash).into()), _ => None, } } @@ -564,7 +564,7 @@ impl Voter { cml_chain::governance::Voter::ConstitutionalCommitteeHotScriptHash { script_hash, .. - } => Some(script_hash.clone().into()), + } => Some((*script_hash).into()), _ => None, } } @@ -573,7 +573,7 @@ impl Voter { match &self.0 { cml_chain::governance::Voter::DRepKeyHash { ed25519_key_hash, .. - } => Some(ed25519_key_hash.clone().into()), + } => Some((*ed25519_key_hash).into()), _ => None, } } @@ -581,7 +581,7 @@ impl Voter { pub fn as_d_rep_script_hash(&self) -> Option { match &self.0 { cml_chain::governance::Voter::DRepScriptHash { script_hash, .. } => { - Some(script_hash.clone().into()) + Some((*script_hash).into()) } _ => None, } @@ -591,7 +591,7 @@ impl Voter { match &self.0 { cml_chain::governance::Voter::StakingPoolKeyHash { ed25519_key_hash, .. - } => Some(ed25519_key_hash.clone().into()), + } => Some((*ed25519_key_hash).into()), _ => None, } } diff --git a/chain/wasm/src/lib.rs b/chain/wasm/src/lib.rs index 28c15d0f..0e4034b5 100644 --- a/chain/wasm/src/lib.rs +++ b/chain/wasm/src/lib.rs @@ -254,7 +254,7 @@ impl Ed25519KeyHashList { } pub fn get(&self, index: usize) -> Ed25519KeyHash { - self.0[index].clone().into() + self.0[index].into() } pub fn add(&mut self, elem: &Ed25519KeyHash) { @@ -760,7 +760,7 @@ impl PolicyIdList { } pub fn get(&self, index: usize) -> PolicyId { - self.0[index].clone().into() + self.0[index].into() } pub fn add(&mut self, elem: &PolicyId) { diff --git a/chain/wasm/src/transaction/mod.rs b/chain/wasm/src/transaction/mod.rs index 88fcd25d..151ed10b 100644 --- a/chain/wasm/src/transaction/mod.rs +++ b/chain/wasm/src/transaction/mod.rs @@ -43,7 +43,7 @@ impl AlonzoFormatTxOut { } pub fn datum_hash(&self) -> Option { - self.0.datum_hash.clone().map(std::convert::Into::into) + self.0.datum_hash.map(std::convert::Into::into) } pub fn new(address: &Address, amount: &Value) -> Self { @@ -131,7 +131,7 @@ impl DatumOption { pub fn as_hash(&self) -> Option { match &self.0 { cml_chain::transaction::DatumOption::Hash { datum_hash, .. } => { - Some(datum_hash.clone().into()) + Some((*datum_hash).into()) } _ => None, } @@ -291,7 +291,7 @@ impl RequiredSigners { } pub fn get(&self, index: usize) -> Ed25519KeyHash { - self.0[index].clone().into() + self.0[index].into() } pub fn add(&mut self, elem: &Ed25519KeyHash) { @@ -422,7 +422,7 @@ impl_wasm_conversions!(cml_chain::transaction::ScriptPubkey, ScriptPubkey); #[wasm_bindgen] impl ScriptPubkey { pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn new(ed25519_key_hash: &Ed25519KeyHash) -> Self { @@ -526,10 +526,7 @@ impl TransactionBody { } pub fn auxiliary_data_hash(&self) -> Option { - self.0 - .auxiliary_data_hash - .clone() - .map(std::convert::Into::into) + self.0.auxiliary_data_hash.map(std::convert::Into::into) } pub fn set_validity_interval_start(&mut self, validity_interval_start: u64) { @@ -553,10 +550,7 @@ impl TransactionBody { } pub fn script_data_hash(&self) -> Option { - self.0 - .script_data_hash - .clone() - .map(std::convert::Into::into) + self.0.script_data_hash.map(std::convert::Into::into) } pub fn set_collateral_inputs(&mut self, collateral_inputs: &TransactionInputList) { @@ -677,7 +671,7 @@ impl_wasm_conversions!(cml_chain::transaction::TransactionInput, TransactionInpu #[wasm_bindgen] impl TransactionInput { pub fn transaction_id(&self) -> TransactionHash { - self.0.transaction_id.clone().into() + self.0.transaction_id.into() } pub fn index(&self) -> u64 { diff --git a/cip25/rust/src/utils.rs b/cip25/rust/src/utils.rs index c70318e8..f9235a8b 100644 --- a/cip25/rust/src/utils.rs +++ b/cip25/rust/src/utils.rs @@ -388,7 +388,7 @@ impl Deserialize for LabelMetadata { } let label_metadata_v1_value = label_metadata_v1_value_table; if label_metadata_v1_table - .insert(label_metadata_v1_key.clone(), label_metadata_v1_value) + .insert(label_metadata_v1_key, label_metadata_v1_value) .is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str( @@ -507,7 +507,7 @@ impl Deserialize for LabelMetadata { } } let data_value = data_value_table; - if data_table.insert(data_key.clone(), data_value).is_some() + if data_table.insert(data_key, data_value).is_some() { return Err(DeserializeFailure::DuplicateKey( Key::Str(String::from( diff --git a/crypto/rust/src/lib.rs b/crypto/rust/src/lib.rs index ca296f0d..5c1863d3 100644 --- a/crypto/rust/src/lib.rs +++ b/crypto/rust/src/lib.rs @@ -503,7 +503,7 @@ impl_signature!(Ed25519Signature, Vec, chain_crypto::Ed25519); #[macro_export] macro_rules! impl_hash_type { ($name:ident, $byte_count:expr) => { - #[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] + #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct $name([u8; $byte_count]); impl $name { diff --git a/multi-era/rust/src/alonzo/serialization.rs b/multi-era/rust/src/alonzo/serialization.rs index 4238d079..6a1ee7eb 100644 --- a/multi-era/rust/src/alonzo/serialization.rs +++ b/multi-era/rust/src/alonzo/serialization.rs @@ -2918,11 +2918,11 @@ impl Deserialize for AlonzoTransactionBody { mint_value_value_encodings.insert(mint_value_key, mint_value_value_encoding); } let (mint_value, mint_value_encoding, mint_value_value_encodings) = (mint_value_table, mint_value_encoding, mint_value_value_encodings); - if mint_table.insert(mint_key.clone(), mint_value).is_some() { + if mint_table.insert(mint_key, mint_value).is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from("some complicated/unsupported type"))).into()); } - mint_key_encodings.insert(mint_key.clone(), mint_key_encoding); - mint_value_encodings.insert(mint_key.clone(), (mint_value_encoding, mint_value_value_encodings)); + mint_key_encodings.insert(mint_key, mint_key_encoding); + mint_value_encodings.insert(mint_key, (mint_value_encoding, mint_value_value_encodings)); } Ok((mint_table, mint_encoding, mint_key_encodings, mint_value_encodings)) })().map_err(|e| e.annotate("mint"))?; @@ -3738,7 +3738,7 @@ impl Deserialize for AlonzoUpdate { AlonzoProtocolParamUpdate::deserialize(raw)?; if proposed_protocol_parameter_updates_table .insert( - proposed_protocol_parameter_updates_key.clone(), + proposed_protocol_parameter_updates_key, proposed_protocol_parameter_updates_value, ) .is_some() @@ -3749,7 +3749,7 @@ impl Deserialize for AlonzoUpdate { .into()); } proposed_protocol_parameter_updates_key_encodings.insert( - proposed_protocol_parameter_updates_key.clone(), + proposed_protocol_parameter_updates_key, proposed_protocol_parameter_updates_key_encoding, ); } diff --git a/multi-era/rust/src/babbage/serialization.rs b/multi-era/rust/src/babbage/serialization.rs index dfbcba8a..89c17e72 100644 --- a/multi-era/rust/src/babbage/serialization.rs +++ b/multi-era/rust/src/babbage/serialization.rs @@ -3569,11 +3569,11 @@ impl Deserialize for BabbageTransactionBody { mint_value_value_encodings.insert(mint_value_key, mint_value_value_encoding); } let (mint_value, mint_value_encoding, mint_value_value_encodings) = (mint_value_table, mint_value_encoding, mint_value_value_encodings); - if mint_table.insert(mint_key.clone(), mint_value).is_some() { + if mint_table.insert(mint_key, mint_value).is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from("some complicated/unsupported type"))).into()); } - mint_key_encodings.insert(mint_key.clone(), mint_key_encoding); - mint_value_encodings.insert(mint_key.clone(), (mint_value_encoding, mint_value_value_encodings)); + mint_key_encodings.insert(mint_key, mint_key_encoding); + mint_value_encodings.insert(mint_key, (mint_value_encoding, mint_value_value_encodings)); } Ok((mint_table, mint_encoding, mint_key_encodings, mint_value_encodings)) })().map_err(|e| e.annotate("mint"))?; @@ -4555,16 +4555,13 @@ impl Deserialize for BabbageUpdate { }) })?; let updates_value = BabbageProtocolParamUpdate::deserialize(raw)?; - if updates_table - .insert(updates_key.clone(), updates_value) - .is_some() - { + if updates_table.insert(updates_key, updates_value).is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from( "some complicated/unsupported type", ))) .into()); } - updates_key_encodings.insert(updates_key.clone(), updates_key_encoding); + updates_key_encodings.insert(updates_key, updates_key_encoding); } Ok((updates_table, updates_encoding, updates_key_encodings)) })() diff --git a/multi-era/rust/src/byron/mpc/serialization.rs b/multi-era/rust/src/byron/mpc/serialization.rs index 88bd4556..f9c71836 100644 --- a/multi-era/rust/src/byron/mpc/serialization.rs +++ b/multi-era/rust/src/byron/mpc/serialization.rs @@ -566,7 +566,7 @@ impl Deserialize for SscOpeningsPayload { })?; let ssc_opens_value = raw.bytes()? as Vec; if ssc_opens_table - .insert(ssc_opens_key.clone(), ssc_opens_value) + .insert(ssc_opens_key, ssc_opens_value) .is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from( @@ -862,7 +862,7 @@ impl Deserialize for SscSharesPayload { } let ssc_shares_value_value = ssc_shares_value_value_arr; if ssc_shares_value_table - .insert(ssc_shares_value_key.clone(), ssc_shares_value_value) + .insert(ssc_shares_value_key, ssc_shares_value_value) .is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from( @@ -873,7 +873,7 @@ impl Deserialize for SscSharesPayload { } let ssc_shares_value = ssc_shares_value_table; if ssc_shares_table - .insert(ssc_shares_key.clone(), ssc_shares_value) + .insert(ssc_shares_key, ssc_shares_value) .is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from( diff --git a/multi-era/rust/src/mary/serialization.rs b/multi-era/rust/src/mary/serialization.rs index e1671388..50b43cea 100644 --- a/multi-era/rust/src/mary/serialization.rs +++ b/multi-era/rust/src/mary/serialization.rs @@ -954,11 +954,11 @@ impl Deserialize for MaryTransactionBody { mint_value_value_encodings.insert(mint_value_key, mint_value_value_encoding); } let (mint_value, mint_value_encoding, mint_value_value_encodings) = (mint_value_table, mint_value_encoding, mint_value_value_encodings); - if mint_table.insert(mint_key.clone(), mint_value).is_some() { + if mint_table.insert(mint_key, mint_value).is_some() { return Err(DeserializeFailure::DuplicateKey(Key::Str(String::from("some complicated/unsupported type"))).into()); } - mint_key_encodings.insert(mint_key.clone(), mint_key_encoding); - mint_value_encodings.insert(mint_key.clone(), (mint_value_encoding, mint_value_value_encodings)); + mint_key_encodings.insert(mint_key, mint_key_encoding); + mint_value_encodings.insert(mint_key, (mint_value_encoding, mint_value_value_encodings)); } Ok((mint_table, mint_encoding, mint_key_encodings, mint_value_encodings)) })().map_err(|e| e.annotate("mint"))?; diff --git a/multi-era/rust/src/shelley/serialization.rs b/multi-era/rust/src/shelley/serialization.rs index 94ec0e70..00bbf491 100644 --- a/multi-era/rust/src/shelley/serialization.rs +++ b/multi-era/rust/src/shelley/serialization.rs @@ -3710,7 +3710,7 @@ impl Deserialize for ShelleyUpdate { ShelleyProtocolParamUpdate::deserialize(raw)?; if shelley_proposed_protocol_parameter_updates_table .insert( - shelley_proposed_protocol_parameter_updates_key.clone(), + shelley_proposed_protocol_parameter_updates_key, shelley_proposed_protocol_parameter_updates_value, ) .is_some() @@ -3721,7 +3721,7 @@ impl Deserialize for ShelleyUpdate { .into()); } shelley_proposed_protocol_parameter_updates_key_encodings.insert( - shelley_proposed_protocol_parameter_updates_key.clone(), + shelley_proposed_protocol_parameter_updates_key, shelley_proposed_protocol_parameter_updates_key_encoding, ); } diff --git a/multi-era/wasm/src/allegra/mod.rs b/multi-era/wasm/src/allegra/mod.rs index 737c93eb..e0a17330 100644 --- a/multi-era/wasm/src/allegra/mod.rs +++ b/multi-era/wasm/src/allegra/mod.rs @@ -410,10 +410,7 @@ impl AllegraTransactionBody { } pub fn auxiliary_data_hash(&self) -> Option { - self.0 - .auxiliary_data_hash - .clone() - .map(std::convert::Into::into) + self.0.auxiliary_data_hash.map(std::convert::Into::into) } pub fn set_validity_interval_start(&mut self, validity_interval_start: u64) { diff --git a/multi-era/wasm/src/alonzo/mod.rs b/multi-era/wasm/src/alonzo/mod.rs index 50174be0..d854654d 100644 --- a/multi-era/wasm/src/alonzo/mod.rs +++ b/multi-era/wasm/src/alonzo/mod.rs @@ -251,11 +251,7 @@ impl AlonzoProposedProtocolParameterUpdates { } pub fn keys(&self) -> GenesisHashList { - self.0 - .iter() - .map(|(k, _v)| k.clone()) - .collect::>() - .into() + self.0.iter().map(|(k, _v)| *k).collect::>().into() } } @@ -594,10 +590,7 @@ impl AlonzoTransactionBody { } pub fn auxiliary_data_hash(&self) -> Option { - self.0 - .auxiliary_data_hash - .clone() - .map(std::convert::Into::into) + self.0.auxiliary_data_hash.map(std::convert::Into::into) } pub fn set_validity_interval_start(&mut self, validity_interval_start: u64) { @@ -621,10 +614,7 @@ impl AlonzoTransactionBody { } pub fn script_data_hash(&self) -> Option { - self.0 - .script_data_hash - .clone() - .map(std::convert::Into::into) + self.0.script_data_hash.map(std::convert::Into::into) } pub fn set_collateral_inputs(&mut self, collateral_inputs: &TransactionInputList) { diff --git a/multi-era/wasm/src/babbage/mod.rs b/multi-era/wasm/src/babbage/mod.rs index ded0c78d..903ac2d8 100644 --- a/multi-era/wasm/src/babbage/mod.rs +++ b/multi-era/wasm/src/babbage/mod.rs @@ -323,11 +323,7 @@ impl BabbageProposedProtocolParameterUpdates { } pub fn keys(&self) -> GenesisHashList { - self.0 - .iter() - .map(|(k, _v)| k.clone()) - .collect::>() - .into() + self.0.iter().map(|(k, _v)| *k).collect::>().into() } } @@ -723,10 +719,7 @@ impl BabbageTransactionBody { } pub fn auxiliary_data_hash(&self) -> Option { - self.0 - .auxiliary_data_hash - .clone() - .map(std::convert::Into::into) + self.0.auxiliary_data_hash.map(std::convert::Into::into) } pub fn set_validity_interval_start(&mut self, validity_interval_start: u64) { @@ -750,10 +743,7 @@ impl BabbageTransactionBody { } pub fn script_data_hash(&self) -> Option { - self.0 - .script_data_hash - .clone() - .map(std::convert::Into::into) + self.0.script_data_hash.map(std::convert::Into::into) } pub fn set_collateral_inputs(&mut self, collateral_inputs: &TransactionInputList) { diff --git a/multi-era/wasm/src/byron/block/mod.rs b/multi-era/wasm/src/byron/block/mod.rs index 1410e5b5..042565a6 100644 --- a/multi-era/wasm/src/byron/block/mod.rs +++ b/multi-era/wasm/src/byron/block/mod.rs @@ -40,7 +40,7 @@ impl BlockHeaderExtraData { } pub fn extra_proof(&self) -> Blake2b256 { - self.0.extra_proof.clone().into() + self.0.extra_proof.into() } pub fn new( @@ -209,7 +209,7 @@ impl ByronBlockHeader { } pub fn prev_block(&self) -> ByronBlockId { - self.0.prev_block.clone().into() + self.0.prev_block.into() } pub fn body_proof(&self) -> ByronBodyProof { @@ -432,11 +432,11 @@ impl ByronBodyProof { } pub fn dlg_proof(&self) -> Blake2b256 { - self.0.dlg_proof.clone().into() + self.0.dlg_proof.into() } pub fn upd_proof(&self) -> Blake2b256 { - self.0.upd_proof.clone().into() + self.0.upd_proof.into() } pub fn new( @@ -586,11 +586,11 @@ impl EbbHead { } pub fn prev_block(&self) -> ByronBlockId { - self.0.prev_block.clone().into() + self.0.prev_block.into() } pub fn body_proof(&self) -> Blake2b256 { - self.0.body_proof.clone().into() + self.0.body_proof.into() } pub fn consensus_data(&self) -> EbbConsensusData { diff --git a/multi-era/wasm/src/byron/mpc/mod.rs b/multi-era/wasm/src/byron/mpc/mod.rs index d351cf6b..6f7bec07 100644 --- a/multi-era/wasm/src/byron/mpc/mod.rs +++ b/multi-era/wasm/src/byron/mpc/mod.rs @@ -177,7 +177,7 @@ impl_wasm_conversions!( #[wasm_bindgen] impl SscCertificatesProof { pub fn blake2b256(&self) -> Blake2b256 { - self.0.blake2b256.clone().into() + self.0.blake2b256.into() } pub fn new(blake2b256: &Blake2b256) -> Self { @@ -258,11 +258,11 @@ impl_wasm_conversions!( #[wasm_bindgen] impl SscCommitmentsProof { pub fn blake2b256(&self) -> Blake2b256 { - self.0.blake2b256.clone().into() + self.0.blake2b256.into() } pub fn blake2b2562(&self) -> Blake2b256 { - self.0.blake2b2562.clone().into() + self.0.blake2b2562.into() } pub fn new(blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self { @@ -324,11 +324,11 @@ impl_wasm_conversions!( #[wasm_bindgen] impl SscOpeningsProof { pub fn blake2b256(&self) -> Blake2b256 { - self.0.blake2b256.clone().into() + self.0.blake2b256.into() } pub fn blake2b2562(&self) -> Blake2b256 { - self.0.blake2b2562.clone().into() + self.0.blake2b2562.into() } pub fn new(blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self { @@ -499,11 +499,11 @@ impl_wasm_conversions!(cml_multi_era::byron::mpc::SscSharesProof, SscSharesProof #[wasm_bindgen] impl SscSharesProof { pub fn blake2b256(&self) -> Blake2b256 { - self.0.blake2b256.clone().into() + self.0.blake2b256.into() } pub fn blake2b2562(&self) -> Blake2b256 { - self.0.blake2b2562.clone().into() + self.0.blake2b2562.into() } pub fn new(blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self { diff --git a/multi-era/wasm/src/byron/transaction/mod.rs b/multi-era/wasm/src/byron/transaction/mod.rs index df46517a..959423be 100644 --- a/multi-era/wasm/src/byron/transaction/mod.rs +++ b/multi-era/wasm/src/byron/transaction/mod.rs @@ -372,7 +372,7 @@ impl_wasm_conversions!( #[wasm_bindgen] impl ByronTxOutPtr { pub fn byron_tx_id(&self) -> ByronTxId { - self.0.byron_tx_id.clone().into() + self.0.byron_tx_id.into() } pub fn u32(&self) -> u32 { @@ -405,11 +405,11 @@ impl ByronTxProof { } pub fn blake2b256(&self) -> Blake2b256 { - self.0.blake2b256.clone().into() + self.0.blake2b256.into() } pub fn blake2b2562(&self) -> Blake2b256 { - self.0.blake2b2562.clone().into() + self.0.blake2b2562.into() } pub fn new(u32: u32, blake2b256: &Blake2b256, blake2b2562: &Blake2b256) -> Self { diff --git a/multi-era/wasm/src/byron/update/mod.rs b/multi-era/wasm/src/byron/update/mod.rs index d95e0aa5..08427257 100644 --- a/multi-era/wasm/src/byron/update/mod.rs +++ b/multi-era/wasm/src/byron/update/mod.rs @@ -237,19 +237,19 @@ impl_wasm_conversions!( #[wasm_bindgen] impl ByronUpdateData { pub fn blake2b256(&self) -> Blake2b256 { - self.0.blake2b256.clone().into() + self.0.blake2b256.into() } pub fn blake2b2562(&self) -> Blake2b256 { - self.0.blake2b2562.clone().into() + self.0.blake2b2562.into() } pub fn blake2b2563(&self) -> Blake2b256 { - self.0.blake2b2563.clone().into() + self.0.blake2b2563.into() } pub fn blake2b2564(&self) -> Blake2b256 { - self.0.blake2b2564.clone().into() + self.0.blake2b2564.into() } pub fn new( @@ -347,7 +347,7 @@ impl ByronUpdateVote { } pub fn proposal_id(&self) -> ByronUpdateId { - self.0.proposal_id.clone().into() + self.0.proposal_id.into() } pub fn vote(&self) -> bool { diff --git a/multi-era/wasm/src/mary/mod.rs b/multi-era/wasm/src/mary/mod.rs index 0655520f..1ab949c2 100644 --- a/multi-era/wasm/src/mary/mod.rs +++ b/multi-era/wasm/src/mary/mod.rs @@ -152,10 +152,7 @@ impl MaryTransactionBody { } pub fn auxiliary_data_hash(&self) -> Option { - self.0 - .auxiliary_data_hash - .clone() - .map(std::convert::Into::into) + self.0.auxiliary_data_hash.map(std::convert::Into::into) } pub fn set_validity_interval_start(&mut self, validity_interval_start: u64) { diff --git a/multi-era/wasm/src/shelley/mod.rs b/multi-era/wasm/src/shelley/mod.rs index 4a28a3a7..8bf30e6a 100644 --- a/multi-era/wasm/src/shelley/mod.rs +++ b/multi-era/wasm/src/shelley/mod.rs @@ -39,15 +39,15 @@ impl_wasm_conversions!( #[wasm_bindgen] impl GenesisKeyDelegation { pub fn genesis_hash(&self) -> GenesisHash { - self.0.genesis_hash.clone().into() + self.0.genesis_hash.into() } pub fn genesis_delegate_hash(&self) -> GenesisDelegateHash { - self.0.genesis_delegate_hash.clone().into() + self.0.genesis_delegate_hash.into() } pub fn v_r_f_key_hash(&self) -> VRFKeyHash { - self.0.v_r_f_key_hash.clone().into() + self.0.v_r_f_key_hash.into() } pub fn new( @@ -142,7 +142,7 @@ impl_wasm_conversions!(cml_multi_era::shelley::MultisigPubkey, MultisigPubkey); #[wasm_bindgen] impl MultisigPubkey { pub fn ed25519_key_hash(&self) -> Ed25519KeyHash { - self.0.ed25519_key_hash.clone().into() + self.0.ed25519_key_hash.into() } pub fn new(ed25519_key_hash: &Ed25519KeyHash) -> Self { @@ -545,7 +545,7 @@ impl ShelleyHeaderBody { } pub fn prev_hash(&self) -> Option { - self.0.prev_hash.clone().map(std::convert::Into::into) + self.0.prev_hash.map(std::convert::Into::into) } pub fn issuer_vkey(&self) -> Vkey { @@ -553,7 +553,7 @@ impl ShelleyHeaderBody { } pub fn v_r_f_vkey(&self) -> VRFVkey { - self.0.v_r_f_vkey.clone().into() + self.0.v_r_f_vkey.into() } pub fn nonce_vrf(&self) -> VRFCert { @@ -569,7 +569,7 @@ impl ShelleyHeaderBody { } pub fn block_body_hash(&self) -> BlockBodyHash { - self.0.block_body_hash.clone().into() + self.0.block_body_hash.into() } pub fn operational_cert(&self) -> OperationalCert { @@ -702,11 +702,7 @@ impl ShelleyProposedProtocolParameterUpdates { } pub fn keys(&self) -> GenesisHashList { - self.0 - .iter() - .map(|(k, _v)| k.clone()) - .collect::>() - .into() + self.0.iter().map(|(k, _v)| *k).collect::>().into() } } @@ -964,10 +960,7 @@ impl ShelleyTransactionBody { } pub fn auxiliary_data_hash(&self) -> Option { - self.0 - .auxiliary_data_hash - .clone() - .map(std::convert::Into::into) + self.0.auxiliary_data_hash.map(std::convert::Into::into) } pub fn new( diff --git a/rust/src/crypto.rs b/rust/src/crypto.rs index 959d1223..6e6973af 100644 --- a/rust/src/crypto.rs +++ b/rust/src/crypto.rs @@ -804,7 +804,7 @@ impl_signature!(Ed25519Signature, Vec, crypto::Ed25519); macro_rules! impl_hash_type { ($name:ident, $byte_count:expr) => { #[wasm_bindgen] - #[derive(Debug, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] + #[derive(Debug, Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct $name(pub (crate) [u8; $byte_count]); // hash types are the only types in this library to not expect the entire CBOR structure.