diff --git a/src/amount.rs b/src/amount.rs index a020b21..cc03430 100644 --- a/src/amount.rs +++ b/src/amount.rs @@ -79,7 +79,7 @@ impl FromStr for Amount { type Err = Error; fn from_str(s: &str) -> Result { - let mut inner = Decimal::from_str(&s)?; + let mut inner = Decimal::from_str(s)?; // Check we don't lose precision let scale = inner.scale(); if scale > STELLAR_SCALE { @@ -266,15 +266,15 @@ impl TryFrom for Amount { } impl XDRSerialize for Price { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_price = self.to_xdr()?; - xdr_price.write_xdr(&mut out).map_err(Error::XdrError) + xdr_price.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for Price { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { - let (xdr_price, bytes_read) = xdr::Price::read_xdr(&buffer).map_err(Error::XdrError)?; + let (xdr_price, bytes_read) = xdr::Price::read_xdr(buffer).map_err(Error::XdrError)?; let res = Price::from_xdr(&xdr_price)?; Ok((res, bytes_read)) } diff --git a/src/asset.rs b/src/asset.rs index 1800749..8cf2ffd 100644 --- a/src/asset.rs +++ b/src/asset.rs @@ -58,10 +58,7 @@ impl Asset { /// Returns true if the asset is a Native. Returns false otherwise. pub fn is_native(&self) -> bool { - match *self { - Asset::Native => true, - _ => false, - } + matches!(*self, Asset::Native) } /// If the asset is a Credit, returns its value. Returns None otherwise @@ -136,9 +133,9 @@ impl CreditAsset { /// Code must be shorter than 12 characters. pub fn new(code: String, issuer: PublicKey) -> Result { let code_len = code.len(); - if code_len >= 1 && code_len <= 4 { + if (1..=4).contains(&code_len) { Ok(CreditAsset::AlphaNum4 { code, issuer }) - } else if code_len >= 5 && code_len <= 12 { + } else if (5..=12).contains(&code_len) { Ok(CreditAsset::AlphaNum12 { code, issuer }) } else { Err(Error::InvalidAssetCode) @@ -148,16 +145,16 @@ impl CreditAsset { /// Returns the asset code. pub fn code(&self) -> &str { match self { - CreditAsset::AlphaNum4 { code, issuer: _ } => &code, - CreditAsset::AlphaNum12 { code, issuer: _ } => &code, + CreditAsset::AlphaNum4 { code, issuer: _ } => code, + CreditAsset::AlphaNum12 { code, issuer: _ } => code, } } /// Returns the asset issuer. pub fn issuer(&self) -> &PublicKey { match self { - CreditAsset::AlphaNum4 { code: _, issuer } => &issuer, - CreditAsset::AlphaNum12 { code: _, issuer } => &issuer, + CreditAsset::AlphaNum4 { code: _, issuer } => issuer, + CreditAsset::AlphaNum12 { code: _, issuer } => issuer, } } @@ -197,10 +194,7 @@ impl TrustLineAsset { /// Returns true if the asset is a Native. Returns false otherwise. pub fn is_native(&self) -> bool { - match *self { - Self::Native => true, - _ => false, - } + matches!(*self, Self::Native) } /// Returns true if the asset is a Credit. Returns false otherwise. @@ -299,31 +293,31 @@ impl TrustLineAsset { } impl XDRSerialize for TrustLineAsset { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_asset = self.to_xdr()?; - xdr_asset.write_xdr(&mut out).map_err(Error::XdrError) + xdr_asset.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for TrustLineAsset { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_asset, bytes_read) = - xdr::TrustLineAsset::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::TrustLineAsset::read_xdr(buffer).map_err(Error::XdrError)?; let res = TrustLineAsset::from_xdr(&xdr_asset)?; Ok((res, bytes_read)) } } impl XDRSerialize for Asset { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_asset = self.to_xdr()?; - xdr_asset.write_xdr(&mut out).map_err(Error::XdrError) + xdr_asset.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for Asset { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { - let (xdr_asset, bytes_read) = xdr::Asset::read_xdr(&buffer).map_err(Error::XdrError)?; + let (xdr_asset, bytes_read) = xdr::Asset::read_xdr(buffer).map_err(Error::XdrError)?; let res = Asset::from_xdr(&xdr_asset)?; Ok((res, bytes_read)) } diff --git a/src/claim.rs b/src/claim.rs index 4e8b413..a21dddf 100644 --- a/src/claim.rs +++ b/src/claim.rs @@ -209,32 +209,32 @@ impl ClaimPredicate { } impl XDRSerialize for Claimant { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr = self.to_xdr()?; - xdr.write_xdr(&mut out).map_err(Error::XdrError) + xdr.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for Claimant { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_claimant, bytes_read) = - xdr::Claimant::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::Claimant::read_xdr(buffer).map_err(Error::XdrError)?; let res = Claimant::from_xdr(&xdr_claimant)?; Ok((res, bytes_read)) } } impl XDRSerialize for ClaimPredicate { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr = self.to_xdr()?; - xdr.write_xdr(&mut out).map_err(Error::XdrError) + xdr.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for ClaimPredicate { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_claim, bytes_read) = - xdr::ClaimPredicate::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::ClaimPredicate::read_xdr(buffer).map_err(Error::XdrError)?; let res = ClaimPredicate::from_xdr(&xdr_claim)?; Ok((res, bytes_read)) } diff --git a/src/crypto/mod.rs b/src/crypto/mod.rs index 3b74eb0..7650e65 100644 --- a/src/crypto/mod.rs +++ b/src/crypto/mod.rs @@ -20,7 +20,7 @@ pub use sodium_oxide::*; /// Compute sha256 hash of `m`. pub fn hash(m: &[u8]) -> Vec { - sha2::Sha256::digest(&m).to_vec() + sha2::Sha256::digest(m).to_vec() } #[derive(Debug, Clone, PartialEq)] @@ -92,6 +92,6 @@ where /// Return the signature hint, that is the last 4 bytes of the public key. pub fn signature_hint(&self) -> SignatureHint { - SignatureHint::from_public_key(&self.verifier.verify_key.as_ref()) + SignatureHint::from_public_key(self.verifier.verify_key.as_ref()) } } diff --git a/src/crypto/public_key.rs b/src/crypto/public_key.rs index 70c65d3..f932165 100644 --- a/src/crypto/public_key.rs +++ b/src/crypto/public_key.rs @@ -11,7 +11,7 @@ pub struct PublicKey(pub [u8; 32]); impl PublicKey { /// Create from `account_id`, e.g. `GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA`. pub fn from_account_id(account_id: &str) -> Result { - let bytes = strkey::decode_account_id(&account_id)?; + let bytes = strkey::decode_account_id(account_id)?; Self::from_slice(&bytes) } @@ -33,7 +33,7 @@ impl PublicKey { } pub fn to_muxed_account(&self, id: u64) -> MuxedAccount { - self.clone().into_muxed_account(id) + (*self).into_muxed_account(id) } pub fn to_xdr_uint256(&self) -> Result { @@ -90,13 +90,13 @@ impl MuxedEd25519PublicKey { } pub fn from_account_id(account_id: &str) -> Result { - let (bytes, id) = strkey::decode_muxed_account(&account_id)?; + let (bytes, id) = strkey::decode_muxed_account(account_id)?; Self::from_slice(&bytes, id) } /// Create from raw byte and id. pub fn from_slice(data: &[u8], id: u64) -> Result { - let key = PublicKey::from_slice(&data)?; + let key = PublicKey::from_slice(data)?; Ok(MuxedEd25519PublicKey { key, id }) } @@ -106,7 +106,7 @@ impl MuxedEd25519PublicKey { } pub fn account_id(&self) -> String { - strkey::encode_muxed_account(&self.key.as_bytes(), self.id) + strkey::encode_muxed_account(self.key.as_bytes(), self.id) } pub fn to_xdr(&self) -> Result { diff --git a/src/crypto/signature.rs b/src/crypto/signature.rs index 3c1478d..a9484a0 100644 --- a/src/crypto/signature.rs +++ b/src/crypto/signature.rs @@ -106,7 +106,7 @@ impl DecoratedSignature { /// Creates a new `DecoratedSignature` from the pre image. pub fn new_from_preimage(preimage: &[u8]) -> Result { let hint = SignatureHint::from_slice(&preimage[preimage.len() - 4..])?; - let signature = Signature::from_bytes(&preimage).map_err(|_| Error::InvalidSignature)?; + let signature = Signature::from_bytes(preimage).map_err(|_| Error::InvalidSignature)?; Ok(DecoratedSignature::new(hint, signature)) } @@ -172,7 +172,7 @@ impl SignerKey { tx: &TransactionEnvelope, network: &Network, ) -> Result { - let preauthtx = PreAuthTxHash::new_from_transaction_envelope(&tx, &network)?; + let preauthtx = PreAuthTxHash::new_from_transaction_envelope(tx, network)?; Ok(SignerKey::new_from_pre_authorized_transaction(preauthtx)) } @@ -334,7 +334,7 @@ impl PreAuthTxHash { tx: &TransactionEnvelope, network: &Network, ) -> Result { - let hash = tx.hash(&network)?; + let hash = tx.hash(network)?; PreAuthTxHash::new(hash) } @@ -369,31 +369,30 @@ impl HashX { } impl XDRSerialize for SignerKey { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_signer = self.to_xdr()?; - xdr_signer.write_xdr(&mut out).map_err(Error::XdrError) + xdr_signer.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for SignerKey { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { - let (xdr_signer, bytes_read) = - xdr::SignerKey::read_xdr(&buffer).map_err(Error::XdrError)?; + let (xdr_signer, bytes_read) = xdr::SignerKey::read_xdr(buffer).map_err(Error::XdrError)?; let res = SignerKey::from_xdr(&xdr_signer)?; Ok((res, bytes_read)) } } impl XDRSerialize for Signer { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_signer = self.to_xdr()?; - xdr_signer.write_xdr(&mut out).map_err(Error::XdrError) + xdr_signer.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for Signer { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { - let (xdr_signer, bytes_read) = xdr::Signer::read_xdr(&buffer).map_err(Error::XdrError)?; + let (xdr_signer, bytes_read) = xdr::Signer::read_xdr(buffer).map_err(Error::XdrError)?; let res = Signer::from_xdr(&xdr_signer)?; Ok((res, bytes_read)) } diff --git a/src/crypto/sodium_oxide/keypair.rs b/src/crypto/sodium_oxide/keypair.rs index f49a26b..d326ac9 100644 --- a/src/crypto/sodium_oxide/keypair.rs +++ b/src/crypto/sodium_oxide/keypair.rs @@ -45,7 +45,7 @@ impl AsRef> for SodiumKeyPair { impl SodiumKeyPair { /// Create the key pair from the secret seed, e.g. `SDAKFNYEIAORZKKCYRILFQKLLOCNPL5SWJ3YY5NM3ZH6GJSZGXHZEPQS`. pub fn from_secret_seed(data: &str) -> Result { - let bytes = strkey::decode_secret_seed(&data)?; + let bytes = strkey::decode_secret_seed(data)?; Self::from_seed_bytes(&bytes) } @@ -63,7 +63,7 @@ impl SodiumKeyPair { /// Crete a key pair from raw bytes. pub fn from_seed_bytes(data: &[u8]) -> Result { - let the_seed = sodium::Seed::from_slice(&data).ok_or(Error::InvalidSeed)?; + let the_seed = sodium::Seed::from_slice(data).ok_or(Error::InvalidSeed)?; let (public, sk) = sodium::keypair_from_seed(&the_seed); let secret = SecretKey { key: sk, @@ -94,7 +94,7 @@ impl SodiumKeyPair { } pub fn verify(&self, sig: &Signature, msg: &[u8]) -> bool { - self.0.verify(msg, &sig).map_or(false, |_| true) + self.0.verify(msg, sig).map_or(false, |_| true) } } @@ -102,7 +102,7 @@ impl std::str::FromStr for SodiumKeyPair { type Err = crate::error::Error; fn from_str(s: &str) -> std::result::Result { - let sk = SodiumKeyPair::from_secret_seed(&s)?; + let sk = SodiumKeyPair::from_secret_seed(s)?; Ok(sk) } } @@ -159,8 +159,8 @@ mod tests { ]; for &(secret, address) in keypairs.iter() { - let keypair = SodiumKeyPair::from_secret_seed(&secret).unwrap(); - let keypair2 = SodiumKeyPair::from_str(&secret).unwrap(); + let keypair = SodiumKeyPair::from_secret_seed(secret).unwrap(); + let keypair2 = SodiumKeyPair::from_str(secret).unwrap(); assert_eq!(&keypair2.secret_key().secret_seed(), secret); let account_id = keypair.public_key().account_id(); assert_eq!(&account_id, address); @@ -183,10 +183,10 @@ mod tests { #[test] fn test_sign_and_verify() { let the_secret = "SD7X7LEHBNMUIKQGKPARG5TDJNBHKC346OUARHGZL5ITC6IJPXHILY36"; - let kp = SodiumKeyPair::from_secret_seed(&the_secret).unwrap(); + let kp = SodiumKeyPair::from_secret_seed(the_secret).unwrap(); let message = "test post please ignore".as_bytes(); - let sign = kp.sign(&message); - let expected_sign = vec![ + let sign = kp.sign(message); + let expected_sign = [ 0x19, 0xDB, 0xFD, 0xAF, 0x0A, 0xA8, 0x4D, 0xF9, 0xA7, 0xFF, 0x6F, 0xE3, 0xC1, 0x0E, 0xBC, 0x1F, 0xE2, 0x14, 0xC5, 0x10, 0xB9, 0x5D, 0xB0, 0xD6, 0x33, 0xBE, 0xD9, 0x3D, 0xF9, 0x25, 0x6B, 0xA9, 0x92, 0xEF, 0x7D, 0x94, 0xB2, 0xA6, 0xE4, 0x54, 0xDE, 0x8F, @@ -194,15 +194,15 @@ mod tests { 0xE7, 0xA0, 0x72, 0x16, 0x02, 0x7A, 0xB4, 0xA, ]; assert_eq!(sign.to_bytes(), expected_sign[..]); - assert!(kp.verify(&sign, &message)); + assert!(kp.verify(&sign, message)); } #[test] fn test_sign_decorated() { let the_secret = "SD7X7LEHBNMUIKQGKPARG5TDJNBHKC346OUARHGZL5ITC6IJPXHILY36"; - let kp = SodiumKeyPair::from_secret_seed(&the_secret).unwrap(); + let kp = SodiumKeyPair::from_secret_seed(the_secret).unwrap(); let message = "test post please ignore".as_bytes(); - let sign = kp.as_ref().sign_decorated(&message); + let sign = kp.as_ref().sign_decorated(message); assert_eq!(sign.hint().to_vec(), vec![0x0B, 0xFA, 0xD1, 0x34]); } } diff --git a/src/crypto/strkey.rs b/src/crypto/strkey.rs index dd6ff6c..89f6e25 100644 --- a/src/crypto/strkey.rs +++ b/src/crypto/strkey.rs @@ -22,7 +22,7 @@ pub fn encode_muxed_account(data: &[u8], id: u64) -> String { let mut data_to_encode = Vec::new(); data_to_encode.resize(8 + data.len(), b'0'); BigEndian::write_u64(&mut data_to_encode[..8], id); - data_to_encode[8..].copy_from_slice(&data); + data_to_encode[8..].copy_from_slice(data); encode_check(MUXED_ACCOUNT_VERSION_BYTE, &data_to_encode) } @@ -59,7 +59,7 @@ pub fn decode_sha256_hash(data: &str) -> Result> { fn encode_check(version: u8, indata: &[u8]) -> String { let mut data = Vec::with_capacity(35); data.push(version); - data.extend_from_slice(&indata); + data.extend_from_slice(indata); let checksum = calculate_checksum(&data); let data_end = data.len(); data.resize(data_end + 2, 0); @@ -68,7 +68,7 @@ fn encode_check(version: u8, indata: &[u8]) -> String { } fn decode_unchecked(data: &str) -> Result<(u8, Vec)> { - let decoded = base32::decode(ALPHABET, &data).ok_or(Error::InvalidStrKey)?; + let decoded = base32::decode(ALPHABET, data).ok_or(Error::InvalidStrKey)?; let decoded_len = decoded.len(); if decoded_len == 0 { @@ -127,7 +127,7 @@ mod tests { #[test] fn test_encode_decode_secret_seed() { let seed = "SDJHRQF4GCMIIKAAAQ6IHY42X73FQFLHUULAPSKKD4DFDM7UXWWCRHBE"; - let secret = decode_secret_seed(&seed).unwrap(); + let secret = decode_secret_seed(seed).unwrap(); let encoded = encode_secret_seed(&secret); assert_eq!(seed, &encoded); } @@ -135,7 +135,7 @@ mod tests { #[test] fn test_encode_decode_account_id() { let addr = "GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D"; - let accountid = decode_account_id(&addr).unwrap(); + let accountid = decode_account_id(addr).unwrap(); let encoded = encode_account_id(&accountid); assert_eq!(addr, &encoded); } @@ -143,7 +143,7 @@ mod tests { #[test] fn test_invalid_version() { let addr = "GCZHXL5HXQX5ABDM26LHYRCQZ5OJFHLOPLZX47WEBP3V2PF5AVFK2A5D"; - let result = decode_secret_seed(&addr); + let result = decode_secret_seed(addr); assert!(result.is_err()); } @@ -186,7 +186,7 @@ mod tests { "", ]; for addr in addresses { - let result = decode_account_id(&addr); + let result = decode_account_id(addr); assert!(result.is_err()); } } @@ -203,7 +203,7 @@ mod tests { ]; for addr in addresses { - let result = decode_muxed_account(&addr); + let result = decode_muxed_account(addr); assert!(result.is_err()); } } @@ -222,7 +222,7 @@ mod tests { fn test_sha256_hash() { let keypair = SodiumKeyPair::from_network(&Network::new_test()).unwrap(); let pk = keypair.public_key(); - let encoded = encode_sha256_hash(&pk.as_bytes()); + let encoded = encode_sha256_hash(pk.as_bytes()); assert_eq!('X', encoded.chars().next().unwrap()); let decoded = decode_sha256_hash(&encoded).unwrap(); assert_eq!(pk.as_bytes(), &decoded[..]); diff --git a/src/lib.rs b/src/lib.rs index 2cc502c..649252a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -49,12 +49,12 @@ //! let payment_amount = Amount::from_str("13.12")?; //! //! let payment = Operation::new_payment() -//! .with_destination(destination.clone()) +//! .with_destination(destination) //! .with_amount(payment_amount)? //! .with_asset(Asset::new_native()) //! .build()?; //! -//! let mut tx = Transaction::builder(source_kp.public_key().clone(), 1234, MIN_BASE_FEE) +//! let mut tx = Transaction::builder(source_kp.public_key(), 1234, MIN_BASE_FEE) //! .with_memo(Memo::new_id(7483792)) //! .add_operation(payment) //! .into_transaction()?; diff --git a/src/memo.rs b/src/memo.rs index ddbab1b..55a512f 100644 --- a/src/memo.rs +++ b/src/memo.rs @@ -53,7 +53,7 @@ impl Memo { Err(Error::InvalidMemoHash) } else { let mut memo_hash: [u8; 32] = Default::default(); - memo_hash[..hash.len()].copy_from_slice(&hash); + memo_hash[..hash.len()].copy_from_slice(hash); Ok(Memo::Hash(memo_hash)) } } @@ -64,17 +64,14 @@ impl Memo { Err(Error::InvalidMemoReturn) } else { let mut memo_ret: [u8; 32] = Default::default(); - memo_ret[..ret.len()].copy_from_slice(&ret); + memo_ret[..ret.len()].copy_from_slice(ret); Ok(Memo::Return(memo_ret)) } } /// Returns true if memo is None. Returns false otherwise. pub fn is_none(&self) -> bool { - match self { - Memo::None => true, - _ => false, - } + matches!(self, Memo::None) } /// If the memo is an Id, returns its value. Returns None otherwise. @@ -197,15 +194,15 @@ impl Default for Memo { } impl XDRSerialize for Memo { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_memo = self.to_xdr()?; - xdr_memo.write_xdr(&mut out).map_err(Error::XdrError) + xdr_memo.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for Memo { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { - let (xdr_memo, bytes_read) = xdr::Memo::read_xdr(&buffer).map_err(Error::XdrError)?; + let (xdr_memo, bytes_read) = xdr::Memo::read_xdr(buffer).map_err(Error::XdrError)?; let res = Memo::from_xdr(&xdr_memo)?; Ok((res, bytes_read)) } @@ -272,7 +269,7 @@ mod tests { #[test] fn test_memo_hash() { - let mut memo = Memo::new_hash(&vec![1, 2, 3, 4, 5]).unwrap(); + let mut memo = Memo::new_hash(&[1, 2, 3, 4, 5]).unwrap(); assert!(!memo.is_none()); assert!(!memo.is_id()); assert!(!memo.is_text()); @@ -303,7 +300,7 @@ mod tests { #[test] fn test_memo_return() { - let mut memo = Memo::new_return(&vec![1, 2, 3, 4, 5]).unwrap(); + let mut memo = Memo::new_return(&[1, 2, 3, 4, 5]).unwrap(); assert!(!memo.is_none()); assert!(!memo.is_id()); assert!(!memo.is_text()); diff --git a/src/operation_result.rs b/src/operation_result.rs index 5bb29ba..83072f3 100644 --- a/src/operation_result.rs +++ b/src/operation_result.rs @@ -378,7 +378,7 @@ impl OperationResult { pub fn from_xdr(x: &xdr::OperationResult) -> Result { match *x { xdr::OperationResult::OpInner(ref xdr_inner) => { - let inner = InnerOperationResult::from_xdr(&xdr_inner)?; + let inner = InnerOperationResult::from_xdr(xdr_inner)?; Ok(OperationResult::Inner(inner)) } xdr::OperationResult::OpBadAuth(()) => Ok(OperationResult::BadAuth), @@ -395,99 +395,99 @@ impl InnerOperationResult { pub fn from_xdr(x: &xdr::OperationResultTr) -> Result { match *x { xdr::OperationResultTr::CreateAccount(ref xdr_inner) => { - let inner = CreateAccountResult::from_xdr(&xdr_inner)?; + let inner = CreateAccountResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::CreateAccount(inner)) } xdr::OperationResultTr::Payment(ref xdr_inner) => { - let inner = PaymentResult::from_xdr(&xdr_inner)?; + let inner = PaymentResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::Payment(inner)) } xdr::OperationResultTr::PathPaymentStrictReceive(ref xdr_inner) => { - let inner = PathPaymentStrictReceiveResult::from_xdr(&xdr_inner)?; + let inner = PathPaymentStrictReceiveResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::PathPaymentStrictReceive(inner)) } xdr::OperationResultTr::ManageSellOffer(ref xdr_inner) => { - let inner = ManageSellOfferResult::from_xdr(&xdr_inner)?; + let inner = ManageSellOfferResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::ManageSellOffer(inner)) } xdr::OperationResultTr::CreatePassiveSellOffer(ref xdr_inner) => { - let inner = ManageSellOfferResult::from_xdr(&xdr_inner)?; + let inner = ManageSellOfferResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::CreatePassiveSellOffer(inner)) } xdr::OperationResultTr::SetOptions(ref xdr_inner) => { - let inner = SetOptionsResult::from_xdr(&xdr_inner)?; + let inner = SetOptionsResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::SetOptions(inner)) } xdr::OperationResultTr::ChangeTrust(ref xdr_inner) => { - let inner = ChangeTrustResult::from_xdr(&xdr_inner)?; + let inner = ChangeTrustResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::ChangeTrust(inner)) } xdr::OperationResultTr::AllowTrust(ref xdr_inner) => { - let inner = AllowTrustResult::from_xdr(&xdr_inner)?; + let inner = AllowTrustResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::AllowTrust(inner)) } xdr::OperationResultTr::AccountMerge(ref xdr_inner) => { - let inner = AccountMergeResult::from_xdr(&xdr_inner)?; + let inner = AccountMergeResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::AccountMerge(inner)) } xdr::OperationResultTr::Inflation(ref xdr_inner) => { - let inner = InflationResult::from_xdr(&xdr_inner)?; + let inner = InflationResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::Inflation(inner)) } xdr::OperationResultTr::ManageData(ref xdr_inner) => { - let inner = ManageDataResult::from_xdr(&xdr_inner)?; + let inner = ManageDataResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::ManageData(inner)) } xdr::OperationResultTr::BumpSequence(ref xdr_inner) => { - let inner = BumpSequenceResult::from_xdr(&xdr_inner)?; + let inner = BumpSequenceResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::BumpSequence(inner)) } xdr::OperationResultTr::ManageBuyOffer(ref xdr_inner) => { - let inner = ManageBuyOfferResult::from_xdr(&xdr_inner)?; + let inner = ManageBuyOfferResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::ManageBuyOffer(inner)) } xdr::OperationResultTr::PathPaymentStrictSend(ref xdr_inner) => { - let inner = PathPaymentStrictSendResult::from_xdr(&xdr_inner)?; + let inner = PathPaymentStrictSendResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::PathPaymentStrictSend(inner)) } xdr::OperationResultTr::CreateClaimableBalance(ref xdr_inner) => { - let inner = CreateClaimableBalanceResult::from_xdr(&xdr_inner)?; + let inner = CreateClaimableBalanceResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::CreateClaimableBalance(inner)) } xdr::OperationResultTr::ClaimClaimableBalance(ref xdr_inner) => { - let inner = ClaimClaimableBalanceResult::from_xdr(&xdr_inner)?; + let inner = ClaimClaimableBalanceResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::ClaimClaimableBalance(inner)) } xdr::OperationResultTr::BeginSponsoringFutureReserves(ref xdr_inner) => { - let inner = BeginSponsoringFutureReservesResult::from_xdr(&xdr_inner)?; + let inner = BeginSponsoringFutureReservesResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::BeginSponsoringFutureReserves(inner)) } xdr::OperationResultTr::EndSponsoringFutureReserves(ref xdr_inner) => { - let inner = EndSponsoringFutureReservesResult::from_xdr(&xdr_inner)?; + let inner = EndSponsoringFutureReservesResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::EndSponsoringFutureReserves(inner)) } xdr::OperationResultTr::RevokeSponsorship(ref xdr_inner) => { - let inner = RevokeSponsorshipResult::from_xdr(&xdr_inner)?; + let inner = RevokeSponsorshipResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::RevokeSponsorship(inner)) } xdr::OperationResultTr::Clawback(ref xdr_inner) => { - let inner = ClawbackResult::from_xdr(&xdr_inner)?; + let inner = ClawbackResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::Clawback(inner)) } xdr::OperationResultTr::ClawbackClaimableBalance(ref xdr_inner) => { - let inner = ClawbackClaimableBalanceResult::from_xdr(&xdr_inner)?; + let inner = ClawbackClaimableBalanceResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::ClawbackClaimableBalance(inner)) } xdr::OperationResultTr::SetTrustLineFlags(ref xdr_inner) => { - let inner = SetTrustLineFlagsResult::from_xdr(&xdr_inner)?; + let inner = SetTrustLineFlagsResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::SetTrustLineFlags(inner)) } xdr::OperationResultTr::LiquidityPoolDeposit(ref xdr_inner) => { - let inner = LiquidityPoolDepositResult::from_xdr(&xdr_inner)?; + let inner = LiquidityPoolDepositResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::LiquidityPoolDeposit(inner)) } xdr::OperationResultTr::LiquidityPoolWithdraw(ref xdr_inner) => { - let inner = LiquidityPoolWithdrawResult::from_xdr(&xdr_inner)?; + let inner = LiquidityPoolWithdrawResult::from_xdr(xdr_inner)?; Ok(InnerOperationResult::LiquidityPoolWithdraw(inner)) } } @@ -539,7 +539,7 @@ impl PathPaymentStrictReceiveResult { ) -> Result { match *x { xdr::PathPaymentStrictReceiveResult::PathPaymentStrictReceiveSuccess(ref xdr_inner) => { - let inner = PathPaymentStrictReceiveResultSuccess::from_xdr(&xdr_inner)?; + let inner = PathPaymentStrictReceiveResultSuccess::from_xdr(xdr_inner)?; Ok(PathPaymentStrictReceiveResult::Success(inner)) } xdr::PathPaymentStrictReceiveResult::PathPaymentStrictReceiveMalformed(()) => { @@ -566,7 +566,7 @@ impl PathPaymentStrictReceiveResult { xdr::PathPaymentStrictReceiveResult::PathPaymentStrictReceiveNoIssuer( ref xdr_asset, ) => { - let asset = Asset::from_xdr(&xdr_asset)?; + let asset = Asset::from_xdr(xdr_asset)?; Ok(PathPaymentStrictReceiveResult::NoIssuer(asset)) } xdr::PathPaymentStrictReceiveResult::PathPaymentStrictReceiveLineFull(()) => { @@ -589,7 +589,7 @@ impl PathPaymentStrictSendResult { pub fn from_xdr(x: &xdr::PathPaymentStrictSendResult) -> Result { match *x { xdr::PathPaymentStrictSendResult::PathPaymentStrictSendSuccess(ref xdr_inner) => { - let inner = PathPaymentStrictSendResultSuccess::from_xdr(&xdr_inner)?; + let inner = PathPaymentStrictSendResultSuccess::from_xdr(xdr_inner)?; Ok(PathPaymentStrictSendResult::Success(inner)) } xdr::PathPaymentStrictSendResult::PathPaymentStrictSendMalformed(()) => { @@ -617,7 +617,7 @@ impl PathPaymentStrictSendResult { Ok(PathPaymentStrictSendResult::LineFull) } xdr::PathPaymentStrictSendResult::PathPaymentStrictSendNoIssuer(ref xdr_asset) => { - let asset = Asset::from_xdr(&xdr_asset)?; + let asset = Asset::from_xdr(xdr_asset)?; Ok(PathPaymentStrictSendResult::NoIssuer(asset)) } xdr::PathPaymentStrictSendResult::PathPaymentStrictSendTooFewOffers(()) => { @@ -637,7 +637,7 @@ impl ManageSellOfferResult { pub fn from_xdr(x: &xdr::ManageSellOfferResult) -> Result { match *x { xdr::ManageSellOfferResult::ManageSellOfferSuccess(ref xdr_inner) => { - let inner = ManageOfferResultSuccess::from_xdr(&xdr_inner)?; + let inner = ManageOfferResultSuccess::from_xdr(xdr_inner)?; Ok(ManageSellOfferResult::Success(inner)) } xdr::ManageSellOfferResult::ManageSellOfferMalformed(()) => { @@ -684,7 +684,7 @@ impl ManageBuyOfferResult { pub fn from_xdr(x: &xdr::ManageBuyOfferResult) -> Result { match *x { xdr::ManageBuyOfferResult::ManageBuyOfferSuccess(ref xdr_inner) => { - let inner = ManageOfferResultSuccess::from_xdr(&xdr_inner)?; + let inner = ManageOfferResultSuccess::from_xdr(xdr_inner)?; Ok(ManageBuyOfferResult::Success(inner)) } xdr::ManageBuyOfferResult::ManageBuyOfferMalformed(()) => { @@ -803,7 +803,7 @@ impl AccountMergeResult { pub fn from_xdr(x: &xdr::AccountMergeResult) -> Result { match *x { xdr::AccountMergeResult::AccountMergeSuccess(ref xdr_balance) => { - let balance = Stroops::from_xdr_int64(&xdr_balance)?; + let balance = Stroops::from_xdr_int64(xdr_balance)?; Ok(AccountMergeResult::Success(balance)) } xdr::AccountMergeResult::AccountMergeMalformed(()) => Ok(AccountMergeResult::Malformed), @@ -831,7 +831,7 @@ impl InflationResult { xdr::InflationResult::InflationSuccess(ref xdr_payouts) => { let mut payouts = Vec::new(); for xdr_payout in xdr_payouts { - let payout = InflationPayout::from_xdr(&xdr_payout)?; + let payout = InflationPayout::from_xdr(xdr_payout)?; payouts.push(payout); } Ok(InflationResult::Success(payouts)) @@ -868,7 +868,7 @@ impl CreateClaimableBalanceResult { pub fn from_xdr(x: &xdr::CreateClaimableBalanceResult) -> Result { match *x { xdr::CreateClaimableBalanceResult::CreateClaimableBalanceSuccess(ref xdr_id) => { - let id = ClaimableBalanceId::from_xdr(&xdr_id)?; + let id = ClaimableBalanceId::from_xdr(xdr_id)?; Ok(CreateClaimableBalanceResult::Success(id)) } xdr::CreateClaimableBalanceResult::CreateClaimableBalanceMalformed(()) => { @@ -1092,7 +1092,7 @@ impl ManageOfferResultSuccess { pub fn from_xdr(x: &xdr::ManageOfferSuccessResult) -> Result { let mut offers_claimed = Vec::new(); for xdr_offer in &x.offers_claimed { - let offer = ClaimAtom::from_xdr(&xdr_offer)?; + let offer = ClaimAtom::from_xdr(xdr_offer)?; offers_claimed.push(offer); } let offer = OfferResult::from_xdr(&x.offer)?; @@ -1192,11 +1192,11 @@ impl OfferResult { pub fn from_xdr(x: &xdr::ManageOfferSuccessResultOffer) -> Result { match *x { xdr::ManageOfferSuccessResultOffer::ManageOfferCreated(ref xdr_inner) => { - let inner = OfferEntry::from_xdr(&xdr_inner)?; + let inner = OfferEntry::from_xdr(xdr_inner)?; Ok(OfferResult::Created(inner)) } xdr::ManageOfferSuccessResultOffer::ManageOfferUpdated(ref xdr_inner) => { - let inner = OfferEntry::from_xdr(&xdr_inner)?; + let inner = OfferEntry::from_xdr(xdr_inner)?; Ok(OfferResult::Updated(inner)) } xdr::ManageOfferSuccessResultOffer::ManageOfferDeleted(()) => Ok(OfferResult::Deleted), @@ -1267,7 +1267,7 @@ mod tests { #[test] fn test_bad_auth() { let xdr = "AAAAAACYloD/////AAAAAf////8AAAAA"; - let result = TransactionResult::from_xdr_base64(&xdr) + let result = TransactionResult::from_xdr_base64(xdr) .unwrap() .as_failed() .unwrap() @@ -1282,7 +1282,7 @@ mod tests { #[test] fn test_no_account() { let xdr = "AAAAAACYloD/////AAAAAf////4AAAAA"; - let result = TransactionResult::from_xdr_base64(&xdr) + let result = TransactionResult::from_xdr_base64(xdr) .unwrap() .as_failed() .unwrap() @@ -1297,7 +1297,7 @@ mod tests { #[test] fn test_not_supported() { let xdr = "AAAAAACYloD/////AAAAAf////0AAAAA"; - let result = TransactionResult::from_xdr_base64(&xdr) + let result = TransactionResult::from_xdr_base64(xdr) .unwrap() .as_failed() .unwrap() @@ -1312,7 +1312,7 @@ mod tests { #[test] fn test_too_many_subentries() { let xdr = "AAAAAAAAA+j/////AAAAAf////wAAAAA"; - let result = TransactionResult::from_xdr_base64(&xdr) + let result = TransactionResult::from_xdr_base64(xdr) .unwrap() .as_failed() .unwrap() @@ -1327,7 +1327,7 @@ mod tests { #[test] fn test_exceeded_work_limit() { let xdr = "AAAAAAAAA+j/////AAAAAf////sAAAAA"; - let result = TransactionResult::from_xdr_base64(&xdr) + let result = TransactionResult::from_xdr_base64(xdr) .unwrap() .as_failed() .unwrap() @@ -1342,7 +1342,7 @@ mod tests { #[test] fn test_too_many_sponsoring() { let xdr = "AAAAAAAAA+j/////AAAAAf////oAAAAA"; - let result = TransactionResult::from_xdr_base64(&xdr) + let result = TransactionResult::from_xdr_base64(xdr) .unwrap() .as_failed() .unwrap() diff --git a/src/operations/account_merge.rs b/src/operations/account_merge.rs index 7814d40..7f5f0c2 100644 --- a/src/operations/account_merge.rs +++ b/src/operations/account_merge.rs @@ -104,11 +104,11 @@ mod tests { .with_destination(kp1.public_key().to_muxed_account(123).clone()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAIAAABAAAAAAAAAAB7Jcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAAAAAAAeoucsUAAABAsar7y6Xy4F1R8InkdOL21n646Z5Fe6dUUfhAkDf9GnIQKHcFzVoeo7z73S6V0zW1AxfR/wJDsFprWPhbllYhBw=="; @@ -125,14 +125,14 @@ mod tests { let op = Operation::new_account_merge() .with_destination(kp1.public_key().to_muxed_account(123).clone()) - .with_source_account(kp2.public_key().clone()) + .with_source_account(kp2.public_key()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAIAAABAAAAAAAAAAB7Jcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAAAAAAAeoucsUAAABAXZWyIftD9wZB7iI/CPWdye29ggvdwf20/WQr00IbTshuas0JDIbJhhfK8NUrEILhBspQjRx82XCrppZVrampAQ=="; diff --git a/src/operations/allow_trust.rs b/src/operations/allow_trust.rs index c23c125..1dcc967 100644 --- a/src/operations/allow_trust.rs +++ b/src/operations/allow_trust.rs @@ -186,17 +186,17 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_allow_trust() - .with_trustor(kp1.public_key().clone()) + .with_trustor(kp1.public_key()) .with_asset(CreditAssetType::CreditAlphaNum4("ABCD".to_string())) .with_authorize_flags(TrustLineFlags::AUTHORIZED) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAHAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAUFCQ0QAAAABAAAAAAAAAAHqLnLFAAAAQNhV5kJkZryrHEq8jgx9O76dchfHSkS99FTAcR6D2cjSoy6dbPuGsiPpTbwbMMV+lYTigEmv5vTVV+rWcLfr0Q0="; @@ -212,17 +212,17 @@ mod tests { let kp2 = keypair2(); let op = Operation::new_allow_trust() - .with_source_account(kp2.public_key().clone()) - .with_trustor(kp1.public_key().clone()) + .with_source_account(kp2.public_key()) + .with_trustor(kp1.public_key()) .with_asset(CreditAssetType::CreditAlphaNum4("ABCD".to_string())) .with_authorize_flags(TrustLineFlags::AUTHORIZED) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAHAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAUFCQ0QAAAABAAAAAAAAAAHqLnLFAAAAQOGeHFq7smaQekF9Cu+duxVIGbMiGvT5CccilyMmB7WELOn85XuYIY6qfDKCnjgH47ga1Yve8qnA5hdD2A+iAgA="; diff --git a/src/operations/begin_sponsoring_future_reserves.rs b/src/operations/begin_sponsoring_future_reserves.rs index f6e35fe..c53f348 100644 --- a/src/operations/begin_sponsoring_future_reserves.rs +++ b/src/operations/begin_sponsoring_future_reserves.rs @@ -110,15 +110,15 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_begin_sponsoring_future_reserves() - .with_sponsored_id(kp1.public_key().clone()) + .with_sponsored_id(kp1.public_key()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAQAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAAAAAAHqLnLFAAAAQIf45R2LIdRhc5dYfL6gFHyeBmxaIMfts2/+oOOhyVyKXYShySjM3xR9k1dCbg7cmgGJAmPo49RZczTXE1Ufjgs="; @@ -134,16 +134,16 @@ mod tests { let kp2 = keypair2(); let op = Operation::new_begin_sponsoring_future_reserves() - .with_source_account(kp2.public_key().clone()) - .with_sponsored_id(kp1.public_key().clone()) + .with_source_account(kp2.public_key()) + .with_sponsored_id(kp1.public_key()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAQAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAAAAAAHqLnLFAAAAQCxAVR1PtQyNc3Bin78gpQlhX+Gu6r9RWh7Rezak0wJwOebKRKsjdO0R3hvQN9ZwSAQDeF5Du4panJMptWkgLQo="; diff --git a/src/operations/bump_sequence.rs b/src/operations/bump_sequence.rs index e559f80..98f8b6f 100644 --- a/src/operations/bump_sequence.rs +++ b/src/operations/bump_sequence.rs @@ -109,11 +109,11 @@ mod tests { .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAALAAAAAAAAAHsAAAAAAAAAAeoucsUAAABAFjXV5orPOkYP+zKGyNKWNJPkZ1UG2n7zyj33W5LHlx1LkD+8vLtB8/GyamKUs7qThchbHdRS9lSBUnvqNkNeCg=="; @@ -127,16 +127,16 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); let op = Operation::new_bump_sequence() - .with_source_account(kp1.public_key().clone()) + .with_source_account(kp1.public_key()) .with_bump_to(i64::MAX) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAALf/////////8AAAAAAAAAAeoucsUAAABAvmRGh/Fe460s9zn2gNu6onhD76G7AL7M3KQ9Ps67y92kQUz0Aw8leVvjAkAvuapExekSc1iMRAkS0uszaQIRCA=="; diff --git a/src/operations/change_trust.rs b/src/operations/change_trust.rs index 34cceb6..03d9c88 100644 --- a/src/operations/change_trust.rs +++ b/src/operations/change_trust.rs @@ -229,17 +229,17 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); - let asset = ChangeTrustAsset::new_credit("FOOBAR", kp1.public_key().clone()).unwrap(); + let asset = ChangeTrustAsset::new_credit("FOOBAR", kp1.public_key()).unwrap(); let op = Operation::new_change_trust() .with_asset(asset) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAGAAAAAkZPT0JBUgAAAAAAAAAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAAAAAAAAAAAAAAAAHqLnLFAAAAQItMBQHM0xqmxrCWDEUHHLm8RZZAamXvBVCFovprlCnzAwGOCgo/HrZlKhZL5LMJtoUAgTtb9eQL+Ur7H8zKDAk="; @@ -253,7 +253,7 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); - let asset = ChangeTrustAsset::new_credit("FOOBAR", kp1.public_key().clone()).unwrap(); + let asset = ChangeTrustAsset::new_credit("FOOBAR", kp1.public_key()).unwrap(); let op = Operation::new_change_trust() .with_asset(asset) @@ -261,11 +261,11 @@ mod tests { .unwrap() .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAGAAAAAkZPT0JBUgAAAAAAAAAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfn//////////AAAAAAAAAAHqLnLFAAAAQBGXSIMx1RSjmS7XD9DluNCn6TolNnB9sdmvBSlWeaizwgfud6hD8BZSfqBHdTNm4DgmloojC9fIVRtVFEHhpAE="; @@ -280,20 +280,20 @@ mod tests { let kp1 = keypair1(); let kp2 = keypair2(); - let asset = ChangeTrustAsset::new_credit("FOOBAR", kp1.public_key().clone()).unwrap(); + let asset = ChangeTrustAsset::new_credit("FOOBAR", kp1.public_key()).unwrap(); let op = Operation::new_change_trust() - .with_source_account(kp2.public_key().clone()) + .with_source_account(kp2.public_key()) .with_asset(asset) .with_limit(Some(Stroops::max())) .unwrap() .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAGAAAAAkZPT0JBUgAAAAAAAAAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfn//////////AAAAAAAAAAHqLnLFAAAAQOLqKZ6HQ5VeJvRyWk9FBA5z6UVoxKPXAODzj7c0sOr6tGYzbAtHW1ahOPdIOI03J4lGjM21ROvgi3ClSfZVUAc="; diff --git a/src/operations/claim_claimable_balance.rs b/src/operations/claim_claimable_balance.rs index 6c8abe1..dc000cd 100644 --- a/src/operations/claim_claimable_balance.rs +++ b/src/operations/claim_claimable_balance.rs @@ -113,11 +113,11 @@ mod tests { .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAPAAAAAAcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHAAAAAAAAAAHqLnLFAAAAQH9SMMxYh28+t9WP0xrJWUZH/i7mk9jG1Qzjvnh2I2Hx/M8OTOqr0511hvBuHI+ETJiAEMUoFw8zb16fXHjQoQQ="; @@ -133,16 +133,16 @@ mod tests { let balance_id = ClaimableBalanceId::new(vec![7; 32]).unwrap(); let op = Operation::new_claim_claimable_balance() - .with_source_account(kp.public_key().clone()) + .with_source_account(kp.public_key()) .with_claimable_balance_id(balance_id) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAA4Nxt4XJcrGZRYrUvrOc1sooiQ+QdEk1suS1wo+oucsUAAAAPAAAAAAcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHAAAAAAAAAAHqLnLFAAAAQD80Q+16BK4ZzJzNGaesezr0cPxsyOvgVVlANU1g91tfM6/NkzLXkB1QI2F4xkXIbp5qbSJ/OfrGRxmsdwWo2g0="; diff --git a/src/operations/clawback.rs b/src/operations/clawback.rs index 7435840..280d68f 100644 --- a/src/operations/clawback.rs +++ b/src/operations/clawback.rs @@ -152,12 +152,12 @@ mod tests { #[test] fn test_clawback() { - let from = keypair1().public_key().clone(); + let from = keypair1().public_key(); let asset = asset0(); let amount = Amount::from_str("17.6301").unwrap(); let clawback_op = Operation::new_clawback() - .with_from(from.clone()) + .with_from(from) .with_asset(asset) .with_amount(amount) .unwrap() @@ -173,14 +173,14 @@ mod tests { #[test] fn test_clawback_with_source_account() { - let source_account = keypair0().public_key().clone(); - let from = keypair1().public_key().clone(); + let source_account = keypair0().public_key(); + let from = keypair1().public_key(); let asset = asset0(); let amount = Amount::from_str("17.6301").unwrap(); let clawback_op = Operation::new_clawback() - .with_source_account(source_account.clone()) - .with_from(from.clone()) + .with_source_account(source_account) + .with_from(from) .with_asset(asset) .with_amount(amount) .unwrap() diff --git a/src/operations/clawback_claimable_balance.rs b/src/operations/clawback_claimable_balance.rs index ef8be6c..37e1075 100644 --- a/src/operations/clawback_claimable_balance.rs +++ b/src/operations/clawback_claimable_balance.rs @@ -128,7 +128,7 @@ mod tests { .unwrap(); let op = Operation::new_clawback_claimable_balance() - .with_source_account(source_account.public_key().clone()) + .with_source_account(source_account.public_key()) .with_balance_id(balance_id) .build() .unwrap(); diff --git a/src/operations/create_account.rs b/src/operations/create_account.rs index ac11a89..69858d9 100644 --- a/src/operations/create_account.rs +++ b/src/operations/create_account.rs @@ -141,17 +141,17 @@ mod tests { let starting_balance = Amount::from_str("12.30").unwrap(); let op = Operation::new_create_account() - .with_destination(dest.clone()) + .with_destination(dest) .with_starting_balance(starting_balance) .unwrap() .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); @@ -170,17 +170,17 @@ mod tests { let starting_balance = "456.9878".parse::().unwrap(); let op = Operation::new_create_account() - .with_source_account(kp2.public_key().clone()) - .with_destination(dest.clone()) + .with_source_account(kp2.public_key()) + .with_destination(dest) .with_starting_balance(starting_balance) .unwrap() .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAARBizfAAAAAAAAAAAeoucsUAAABACIZzOxwBATuDx2738HBsh0VA0oYQT1mTfrlOROtQeBb8h4AkOJeQYn3VEkij0ZnDnrZAmRP/rR7WD714PQioCA=="; diff --git a/src/operations/create_claimable_balance.rs b/src/operations/create_claimable_balance.rs index fca58af..474012d 100644 --- a/src/operations/create_claimable_balance.rs +++ b/src/operations/create_claimable_balance.rs @@ -87,7 +87,7 @@ impl CreateClaimableBalanceOperation { let asset = Asset::from_xdr(&x.asset)?; let amount = Stroops::from_xdr_int64(&x.amount)?; let claimants_res: Result> = - x.claimants.iter().map(|c| Claimant::from_xdr(&c)).collect(); + x.claimants.iter().map(Claimant::from_xdr).collect(); let claimants = claimants_res?; Ok(CreateClaimableBalanceOperation { source_account, @@ -184,12 +184,12 @@ mod tests { let kp2 = keypair2(); let amount = Amount::from_str("12.0333").unwrap(); - let asset = Asset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); + let asset = Asset::new_credit("ABCD", kp2.public_key()).unwrap(); let predicate = ClaimPredicate::new_not(ClaimPredicate::new_before_relative_time(Duration::days(7))); - let claimant = Claimant::new(kp1.public_key().clone(), predicate); + let claimant = Claimant::new(kp1.public_key(), predicate); let op = Operation::new_create_claimable_balance() .with_asset(asset) @@ -199,11 +199,11 @@ mod tests { .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAOAAAAAUFCQ0QAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAABywiyAAAAAEAAAAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAwAAAAEAAAAFAAAAAAAJOoAAAAAAAAAAAeoucsUAAABAUA3iWSLubKZc6r4CL2s9WTr/xMS5zuWgzxvm2hBs9use/2ejCagSPlRBeRCe3Ky4R+tKMk8Qpa2LATvgUQS2BQ=="; @@ -219,15 +219,15 @@ mod tests { let kp2 = keypair2(); let amount = Amount::from_str("12.0333").unwrap(); - let asset = Asset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); + let asset = Asset::new_credit("ABCD", kp2.public_key()).unwrap(); let predicate = ClaimPredicate::new_not(ClaimPredicate::new_before_relative_time(Duration::days(7))); - let claimant = Claimant::new(kp1.public_key().clone(), predicate); + let claimant = Claimant::new(kp1.public_key(), predicate); let op = Operation::new_create_claimable_balance() - .with_source_account(kp.public_key().clone()) + .with_source_account(kp.public_key()) .with_asset(asset) .with_amount(amount) .unwrap() @@ -235,11 +235,11 @@ mod tests { .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAA4Nxt4XJcrGZRYrUvrOc1sooiQ+QdEk1suS1wo+oucsUAAAAOAAAAAUFCQ0QAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAABywiyAAAAAEAAAAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAwAAAAEAAAAFAAAAAAAJOoAAAAAAAAAAAeoucsUAAABAcaaQuqZMwpwVMS9814lZPhjt43B3xwlGNfeyx2wU2EJSDJ0h0d2a7dxngMzq4/abNVCjBKspCU7XroelAhSNCw=="; diff --git a/src/operations/create_passive_sell_offer.rs b/src/operations/create_passive_sell_offer.rs index 1b3d8c0..ebdb62d 100644 --- a/src/operations/create_passive_sell_offer.rs +++ b/src/operations/create_passive_sell_offer.rs @@ -192,7 +192,7 @@ mod tests { let kp1 = keypair1(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_create_passive_sell_offer() @@ -203,11 +203,11 @@ mod tests { .with_price(price) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAEAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAAB6i5yxQAAAECG2/IOsqY2pTugmUnhX9Iafmy5JuCQjPxlA0kxdYHe2EKIbZVClMbgckEwvjJq+B0G2SzRUqiK1sfAOIZpAB4D"; @@ -223,11 +223,11 @@ mod tests { let kp2 = keypair2(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_create_passive_sell_offer() - .with_source_account(kp2.public_key().clone()) + .with_source_account(kp2.public_key()) .with_selling_asset(Asset::new_native()) .with_buying_asset(buying) .with_amount(amount) @@ -235,11 +235,11 @@ mod tests { .with_price(price) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAEAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAAB6i5yxQAAAECffRDt4ilFKVEfldEY/Ys2VJm4g7iu6eiqJvPGqDGALTPnEMncqaMGoFbtNgMvZWv3rXi65351/VQv1o8MrtML"; diff --git a/src/operations/end_sponsoring_future_reserves.rs b/src/operations/end_sponsoring_future_reserves.rs index fdbc383..31322b4 100644 --- a/src/operations/end_sponsoring_future_reserves.rs +++ b/src/operations/end_sponsoring_future_reserves.rs @@ -72,11 +72,11 @@ mod tests { #[test] fn test_end_sponsoring_future_reserves() { let kp = keypair0(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(Operation::new_end_sponsoring_future_reserves().build()) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAARAAAAAAAAAAHqLnLFAAAAQOQlXWOVDQVXDDwpbjv6EpROZHQ77tzmTMCrczR20UFqzPBZHc6lKv9tTLzz/esVDbwYbaa+m/y8HqH7MqPjuQw="; @@ -90,15 +90,15 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation( Operation::new_end_sponsoring_future_reserves() - .with_source_account(kp1.public_key().clone()) + .with_source_account(kp1.public_key()) .build(), ) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAARAAAAAAAAAAHqLnLFAAAAQBjITBRZCRbpp2adVQSTC8l9NB/UoTFtHpHkZYEEWl0hSGD7U4N3m2WhFD+kmoBnyy1jWbtPMkyL3SriGvrSCwM="; diff --git a/src/operations/inflation.rs b/src/operations/inflation.rs index 8aa433a..3a35570 100644 --- a/src/operations/inflation.rs +++ b/src/operations/inflation.rs @@ -69,11 +69,11 @@ mod tests { #[test] fn test_inflation() { let kp = keypair0(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(Operation::new_inflation().build()) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAJAAAAAAAAAAHqLnLFAAAAQCvHHPKuTRaRXk9BH05oWii0PJRmVOoqMxxg+79MLO90n1ljVNoaQ1Fliy8Xe34yfUzjhMB/TCXH29T8dTYtBg4="; @@ -87,15 +87,15 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation( Operation::new_inflation() - .with_source_account(kp1.public_key().clone()) + .with_source_account(kp1.public_key()) .build(), ) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAJAAAAAAAAAAHqLnLFAAAAQEMnHq75AT55x0OCFN8mQGbwamRmSdlZsOw0U9z5SbhZqug7qlrW4R7U4era7DDGwOv1bdIMCcGZ4FxSDMH8hwg="; diff --git a/src/operations/liquidity_pool_deposit.rs b/src/operations/liquidity_pool_deposit.rs index ea8fcc7..2a156fa 100644 --- a/src/operations/liquidity_pool_deposit.rs +++ b/src/operations/liquidity_pool_deposit.rs @@ -237,7 +237,7 @@ mod tests { let max_price = Price::from_str("25.25").unwrap(); let op = Operation::new_liquidity_pool_deposit() - .with_source_account(source_account.public_key().clone()) + .with_source_account(source_account.public_key()) .with_liquidity_pool_id(liquidity_pool_id) .with_max_amount_a(max_amount_a) .unwrap() diff --git a/src/operations/liquidity_pool_withdraw.rs b/src/operations/liquidity_pool_withdraw.rs index 65b6b61..ecd6175 100644 --- a/src/operations/liquidity_pool_withdraw.rs +++ b/src/operations/liquidity_pool_withdraw.rs @@ -207,7 +207,7 @@ mod tests { #[test] fn test_liquidity_pool_withdraw_with_source_account() { - let source_account = keypair0().public_key().clone(); + let source_account = keypair0().public_key(); let liquidity_pool_id = LiquidityPoolId::new(vec![7; 32]).unwrap(); let amount = Amount::from_str("100.09").unwrap(); let min_amount_a = Amount::from_str("1700.69").unwrap(); diff --git a/src/operations/manage_buy_offer.rs b/src/operations/manage_buy_offer.rs index c550afb..a90bd56 100644 --- a/src/operations/manage_buy_offer.rs +++ b/src/operations/manage_buy_offer.rs @@ -228,7 +228,7 @@ mod tests { let kp1 = keypair1(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("ABCDEFGH", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("ABCDEFGH", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_manage_buy_offer() @@ -239,11 +239,11 @@ mod tests { .with_price(price) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAJBQkNERUZHSAAAAAAAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAAO5rKAAAAAPcAAAAUAAAAAAAAAAAAAAAAAAAAAeoucsUAAABAwJNdoP6KJlGw9S5BglgiBsWQPPKuPZQVqsFr0b9x3xSXUn+HOagzv210kzga37vSEFGIQ3GyoAgWLbxbYVcKDg=="; @@ -258,7 +258,7 @@ mod tests { let kp1 = keypair1(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_manage_buy_offer() @@ -270,11 +270,11 @@ mod tests { .with_offer_id(Some(888)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAN4AAAAAAAAAAHqLnLFAAAAQJiREkdqaD2QzbsQWcuaUdr5mhJmbatEzAEqChBjtlUQ44C7nFbashDHyTN/Q6YkYOGr2xwL7yWIK9SCJKfeSQU="; @@ -290,11 +290,11 @@ mod tests { let kp2 = keypair2(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_manage_buy_offer() - .with_source_account(kp2.public_key().clone()) + .with_source_account(kp2.public_key()) .with_selling_asset(Asset::new_native()) .with_buying_asset(buying) .with_buy_amount(amount) @@ -302,11 +302,11 @@ mod tests { .with_price(price) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAMAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAAAAAAAAAAAAAHqLnLFAAAAQLZdtLQcZZgoBIbkkHsnZ0Afhm5M+szpVmwulAYpde9aZx8FpN8ZRRHxW0qoLgr9Y1K7W/8jOyuEItqMd+PDewA="; diff --git a/src/operations/manage_data.rs b/src/operations/manage_data.rs index 8a13efa..75804f2 100644 --- a/src/operations/manage_data.rs +++ b/src/operations/manage_data.rs @@ -66,11 +66,7 @@ impl ManageDataOperation { x: &xdr::ManageDataOp, ) -> Result { let data_name = x.data_name.value.to_string(); - let data_value = x - .data_value - .as_ref() - .map(|d| DataValue::from_xdr(d)) - .transpose()?; + let data_value = x.data_value.as_ref().map(DataValue::from_xdr).transpose()?; Ok(ManageDataOperation { source_account, @@ -136,11 +132,11 @@ mod tests { .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAKAAAACVRFU1QgVEVTVAAAAAAAAAEAAAALdmFsdWUgdmFsdWUAAAAAAAAAAAHqLnLFAAAAQLxeb1DkXDTXi/rOffnHpyxuJhl8vN/GDMKLtxFFTGn5b99FNHmWUyUoxb4KTE9bBguIe33SEQ/npj32f2vt/gY="; @@ -155,17 +151,17 @@ mod tests { let kp1 = keypair1(); let value = DataValue::from_slice("value value".as_bytes()).unwrap(); let op = Operation::new_manage_data() - .with_source_account(kp1.public_key().clone()) + .with_source_account(kp1.public_key()) .with_data_name("TEST TEST".to_string()) .with_data_value(Some(value)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAKAAAACVRFU1QgVEVTVAAAAAAAAAEAAAALdmFsdWUgdmFsdWUAAAAAAAAAAAHqLnLFAAAAQBQKnwjKQ1RbYg0rk7G9VV1jHwM29YEp1EoOug960nTVWga6aFmPlQ0mDDudEsbSMq+9G8eYX5mcu9EHTjZUBQI="; diff --git a/src/operations/manage_sell_offer.rs b/src/operations/manage_sell_offer.rs index 843d50e..c543321 100644 --- a/src/operations/manage_sell_offer.rs +++ b/src/operations/manage_sell_offer.rs @@ -228,7 +228,7 @@ mod tests { let kp1 = keypair1(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_manage_sell_offer() @@ -239,11 +239,11 @@ mod tests { .with_price(price) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAAAAAAAAAAAAAHqLnLFAAAAQPhJ8gbyJpZmlbKl5ItaNi7KAGF0BH3Dfe3ZT/f9liF1JtsEFKeoNq8ea0me2y59AH78iahdkLLxVc4oq1ROcw4="; @@ -258,7 +258,7 @@ mod tests { let kp1 = keypair1(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_manage_sell_offer() @@ -270,11 +270,11 @@ mod tests { .with_offer_id(Some(888)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAN4AAAAAAAAAAHqLnLFAAAAQI9ZDQtGLZFCFgqd/6dLqznGWwAI4/LOwrNS7JkO5Rbx8j1cG60rWFylW9v0i40yk7Z5HleAncBJzrvcDeHhDAA="; @@ -290,11 +290,11 @@ mod tests { let kp2 = keypair2(); let amount = Amount::from_str("100.0").unwrap(); - let buying = Asset::new_credit("AB", kp1.public_key().clone()).unwrap(); + let buying = Asset::new_credit("AB", kp1.public_key()).unwrap(); let price = Price::from_str("12.35").unwrap(); let op = Operation::new_manage_sell_offer() - .with_source_account(kp2.public_key().clone()) + .with_source_account(kp2.public_key()) .with_selling_asset(Asset::new_native()) .with_buying_asset(buying) .with_amount(amount) @@ -303,11 +303,11 @@ mod tests { .with_offer_id(Some(888)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAADAAAAAAAAAAFBQgAAAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAADuaygAAAAD3AAAAFAAAAAAAAAN4AAAAAAAAAAHqLnLFAAAAQBJhFxneImX3Z8FW+UO5xM1kAQhkwVVxSbpVqsafWaeFzcY8KWTlopVYqgoJrXnHRQq3KAstTiRktSg5zZbppgQ="; diff --git a/src/operations/mod.rs b/src/operations/mod.rs index 03f88a7..a422dbe 100644 --- a/src/operations/mod.rs +++ b/src/operations/mod.rs @@ -859,7 +859,7 @@ impl Operation { pub fn from_xdr(x: &xdr::Operation) -> Result { let source_account = match &x.source_account { None => None, - Some(sa) => Some(MuxedAccount::from_xdr(&sa)?), + Some(sa) => Some(MuxedAccount::from_xdr(sa)?), }; match &x.body { xdr::OperationBody::CreateAccount(op) => { @@ -977,16 +977,16 @@ impl Operation { } impl XDRSerialize for Operation { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_operation = self.to_xdr()?; - xdr_operation.write_xdr(&mut out).map_err(Error::XdrError) + xdr_operation.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for Operation { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_operation, bytes_read) = - xdr::Operation::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::Operation::read_xdr(buffer).map_err(Error::XdrError)?; let res = Operation::from_xdr(&xdr_operation)?; Ok((res, bytes_read)) } diff --git a/src/operations/path_payment_strict_receive.rs b/src/operations/path_payment_strict_receive.rs index 4c93570..923b528 100644 --- a/src/operations/path_payment_strict_receive.rs +++ b/src/operations/path_payment_strict_receive.rs @@ -129,7 +129,7 @@ impl PathPaymentStrictReceiveOperation { let send_max = Stroops::from_xdr_int64(&x.send_max)?; let destination_asset = Asset::from_xdr(&x.dest_asset)?; let destination_amount = Stroops::from_xdr_int64(&x.dest_amount)?; - let path_res: Result> = x.path.iter().map(|a| Asset::from_xdr(&a)).collect(); + let path_res: Result> = x.path.iter().map(Asset::from_xdr).collect(); let path = path_res?; Ok(PathPaymentStrictReceiveOperation { source_account, @@ -282,11 +282,11 @@ mod tests { let dest_amount = Amount::from_str("12.301").unwrap(); let send_max = Amount::from_str("0.333").unwrap(); - let abcd = Asset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); - let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key().clone()).unwrap(); + let abcd = Asset::new_credit("ABCD", kp2.public_key()).unwrap(); + let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key()).unwrap(); let op = Operation::new_path_payment_strict_receive() - .with_destination(dest.clone()) + .with_destination(dest) .with_send_asset(Asset::new_native()) .with_send_max(send_max) .unwrap() @@ -296,11 +296,11 @@ mod tests { .add_asset(abcd) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAACAAAAAAAAAAAAMs/QAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAkRFU1RBU1NFVAAAAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAHVPvQAAAAAQAAAAFBQkNEAAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAAAAAAAHqLnLFAAAAQLZISKYSR3RXr9Hvxw1tr9P1B4fst/sDuQMGapBvSpLYU6DpDSOFM/vVEuB94HXWI79fSJmfyEl+gR6Zh+o0Yw4="; @@ -319,12 +319,12 @@ mod tests { let dest_amount = Amount::from_str("12.301").unwrap(); let send_max = Amount::from_str("0.333").unwrap(); - let abcd = Asset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); - let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key().clone()).unwrap(); + let abcd = Asset::new_credit("ABCD", kp2.public_key()).unwrap(); + let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key()).unwrap(); let op = Operation::new_path_payment_strict_receive() - .with_source_account(kp1.public_key().clone()) - .with_destination(dest.clone()) + .with_source_account(kp1.public_key()) + .with_destination(dest) .with_send_asset(Asset::new_native()) .with_send_max(send_max) .unwrap() @@ -334,11 +334,11 @@ mod tests { .add_asset(abcd) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAACAAAAAAAAAAAAMs/QAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAkRFU1RBU1NFVAAAAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAHVPvQAAAAAQAAAAFBQkNEAAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAAAAAAAHqLnLFAAAAQJgKu/fRcqT/SwSy1ejitxV6hGH/CZZtv+Qoe1usuSK2kN0UYz6YQOy0aqMwP1iJrIV5DbiDRymKEdEZAo9a5Q4="; diff --git a/src/operations/path_payment_strict_send.rs b/src/operations/path_payment_strict_send.rs index 6e42e03..8fcb485 100644 --- a/src/operations/path_payment_strict_send.rs +++ b/src/operations/path_payment_strict_send.rs @@ -129,7 +129,7 @@ impl PathPaymentStrictSendOperation { let send_amount = Stroops::from_xdr_int64(&x.send_amount)?; let destination_asset = Asset::from_xdr(&x.dest_asset)?; let destination_min = Stroops::from_xdr_int64(&x.dest_min)?; - let path_res: Result> = x.path.iter().map(|a| Asset::from_xdr(&a)).collect(); + let path_res: Result> = x.path.iter().map(Asset::from_xdr).collect(); let path = path_res?; Ok(PathPaymentStrictSendOperation { source_account, @@ -277,11 +277,11 @@ mod tests { let dest_amount = Amount::from_str("12.301").unwrap(); let send_amount = Amount::from_str("0.333").unwrap(); - let abcd = Asset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); - let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key().clone()).unwrap(); + let abcd = Asset::new_credit("ABCD", kp2.public_key()).unwrap(); + let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key()).unwrap(); let op = Operation::new_path_payment_strict_send() - .with_destination(dest.clone()) + .with_destination(dest) .with_send_asset(Asset::new_native()) .with_send_amount(send_amount) .unwrap() @@ -291,11 +291,11 @@ mod tests { .add_asset(abcd) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAANAAAAAAAAAAAAMs/QAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAkRFU1RBU1NFVAAAAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAHVPvQAAAAAQAAAAFBQkNEAAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAAAAAAAHqLnLFAAAAQKDDuyBJaD3+y98EloB5VJi1wYamH+poOoaOhxGGFcH4ZhFI04TRAY3Ahggs3bMV7pcOmw120oZ4P4vA0aFjWgk="; @@ -314,12 +314,12 @@ mod tests { let dest_amount = Amount::from_str("12.301").unwrap(); let send_amount = Amount::from_str("0.333").unwrap(); - let abcd = Asset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); - let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key().clone()).unwrap(); + let abcd = Asset::new_credit("ABCD", kp2.public_key()).unwrap(); + let dest_asset = Asset::new_credit("DESTASSET", kp2.public_key()).unwrap(); let op = Operation::new_path_payment_strict_send() - .with_source_account(kp1.public_key().clone()) - .with_destination(dest.clone()) + .with_source_account(kp1.public_key()) + .with_destination(dest) .with_send_asset(Asset::new_native()) .with_send_amount(send_amount) .unwrap() @@ -329,11 +329,11 @@ mod tests { .add_asset(abcd) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAANAAAAAAAAAAAAMs/QAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAkRFU1RBU1NFVAAAAAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAHVPvQAAAAAQAAAAFBQkNEAAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAAAAAAAAHqLnLFAAAAQI4En43OnB/OEQ9ZAjymT8dGwnHVah2gqkq1AQuwJ89e7kVvwWPl/axspv25B0x9NnEdNZd+KKhoZfmA4B5EWwg="; diff --git a/src/operations/payment.rs b/src/operations/payment.rs index a75f175..f6d8265 100644 --- a/src/operations/payment.rs +++ b/src/operations/payment.rs @@ -169,17 +169,17 @@ mod tests { let amount = Amount::from_str("12.301").unwrap(); let op = Operation::new_payment() - .with_destination(dest.clone()) + .with_destination(dest) .with_amount(amount) .unwrap() .with_asset(Asset::new_native()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAABAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAAAAAAAHVPvQAAAAAAAAAAHqLnLFAAAAQFOPIvnhDoRtPKJl7mJGPD69z2riRwZCJJcLRD+QaJ1Wg+yMiDHLiheBZv/BodiTqEvFHFxcmSxo7pjyzoc7mQ8="; @@ -197,18 +197,18 @@ mod tests { let amount = Amount::from_str("12.301").unwrap(); let op = Operation::new_payment() - .with_source_account(kp2.public_key().clone()) - .with_destination(dest.clone()) + .with_source_account(kp2.public_key()) + .with_destination(dest) .with_amount(amount) .unwrap() .with_asset(Asset::new_native()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAABAAAAACXK8doPx27P6IReQlRRuweSSUiUfjqgyswxiu3Sh2R+AAAAAAAAAAAHVPvQAAAAAAAAAAHqLnLFAAAAQE6H/Nqe7xqcdepF+y5PxXJaGn6aG1xzKXDqWQajo3lsPec0puxpaFvOKs2shgjKap4BgzREPyIs9st4IKq9kAo="; diff --git a/src/operations/revoke_sponsorship.rs b/src/operations/revoke_sponsorship.rs index 6e78630..33c59a6 100644 --- a/src/operations/revoke_sponsorship.rs +++ b/src/operations/revoke_sponsorship.rs @@ -124,7 +124,7 @@ impl RevokeSponsorshipOperation { ) -> Result { match x { xdr::RevokeSponsorshipOp::RevokeSponsorshipLedgerEntry(ref le) => { - let ledger_key = LedgerKey::from_xdr(&le)?; + let ledger_key = LedgerKey::from_xdr(le)?; let inner = RevokeSponsorshipLedgerEntry { source_account, ledger_key, @@ -321,14 +321,14 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_revoke_sponsorship() - .with_ledger_key(LedgerKey::Account(kp1.public_key().clone())) + .with_ledger_key(LedgerKey::Account(kp1.public_key())) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAASAAAAAAAAAAAAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAAAAAAAeoucsUAAABAlhwbGG2OC+ym0bD7G0GsGnbLInIVKzfLdhCl6AsyioseAydDXCVOB2A8Ywv4XfT0nC4BY26UdPBuLWG3cALmAg=="; @@ -343,17 +343,17 @@ mod tests { let kp1 = keypair1(); let kp2 = keypair2(); - let abcd = TrustLineAsset::new_credit("ABCD", kp2.public_key().clone()).unwrap(); + let abcd = TrustLineAsset::new_credit("ABCD", kp2.public_key()).unwrap(); let op = Operation::new_revoke_sponsorship() - .with_ledger_key(LedgerKey::Trustline(kp1.public_key().clone(), abcd)) + .with_ledger_key(LedgerKey::Trustline(kp1.public_key(), abcd)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAASAAAAAAAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAABQUJDRAAAAAB+Ecs01jX14asC1KAsPdWlpGbYCM2PEgFZCD3NLhVZmAAAAAAAAAAB6i5yxQAAAEA+1KnFKV7vhXjLxRJ+/aWfusVTrV3Az+Iscd13uKG0g6Pi41uTC5nsU07GeC2Os2bwz7r8XlNtxlkwHF89DCcG"; @@ -368,14 +368,14 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_revoke_sponsorship() - .with_ledger_key(LedgerKey::Offer(kp1.public_key().clone(), 123)) + .with_ledger_key(LedgerKey::Offer(kp1.public_key(), 123)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAASAAAAAAAAAAIAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAAAAAAewAAAAAAAAAB6i5yxQAAAECBX+hYvz4LN3DoBmTTabB7aZGCjUqps1DZaMm9jLBsHgIUrfmoVNx2e0a6t1o0nvAKpatd3SCZFWIY0W6TnAYJ"; @@ -390,17 +390,14 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_revoke_sponsorship() - .with_ledger_key(LedgerKey::Data( - kp1.public_key().clone(), - "Test_Data".to_string(), - )) + .with_ledger_key(LedgerKey::Data(kp1.public_key(), "Test_Data".to_string())) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAASAAAAAAAAAAMAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAJVGVzdF9EYXRhAAAAAAAAAAAAAAHqLnLFAAAAQIEt621z4bNoQ9RXuT+bUktPySCRYocLfde5SKO2/94r4K8GBZhVzKBez80hNxfljncOuG4ZkzQ+mWaCGBjnpgE="; @@ -419,11 +416,11 @@ mod tests { .with_ledger_key(LedgerKey::ClaimableBalance(balance_id)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAASAAAAAAAAAAQAAAAABwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcAAAAAAAAAAeoucsUAAABAAofz60qpHGLrsNmcT9fgAnUOywCE5xDW8OMYpusgis1zODTg3fmsbFmUGB32DrGn+aeVtrLkVVjIY8vey3cVDQ=="; @@ -438,15 +435,15 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_revoke_sponsorship() - .with_ledger_key(LedgerKey::Account(kp1.public_key().clone())) - .with_source_account(kp1.public_key().clone()) + .with_ledger_key(LedgerKey::Account(kp1.public_key())) + .with_source_account(kp1.public_key()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAASAAAAAAAAAAAAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAAAAAAAAeoucsUAAABA0Fd2Pp3NfMLTFGXbb6oks4IiwWQLqzQ71DFgVjv98Cle113hcH2toNlNEF7iT1D+262C4ajIhdAReZBubwTHCg=="; @@ -460,17 +457,17 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); - let signer_key = SignerKey::new_from_public_key(kp1.public_key().clone()); + let signer_key = SignerKey::new_from_public_key(kp1.public_key()); let op = Operation::new_revoke_sponsorship() - .with_signer(kp1.public_key().clone(), signer_key) + .with_signer(kp1.public_key(), signer_key) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAASAAAAAQAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAAAAAB6i5yxQAAAECkJuiFk6qWll/g4XtiknA2GktvVLIsQuxSs2SC2NvzrzxF0WSxZjOaKdDqeZ/AfkzgajS6mCo7s9e7sg9DcF8P"; @@ -484,18 +481,18 @@ mod tests { let kp = keypair0(); let kp1 = keypair1(); - let signer_key = SignerKey::new_from_public_key(kp1.public_key().clone()); + let signer_key = SignerKey::new_from_public_key(kp1.public_key()); let op = Operation::new_revoke_sponsorship() - .with_signer(kp1.public_key().clone(), signer_key) - .with_source_account(kp1.public_key().clone()) + .with_signer(kp1.public_key(), signer_key) + .with_source_account(kp1.public_key()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAJcrx2g/Hbs/ohF5CVFG7B5JJSJR+OqDKzDGK7dKHZH4AAAASAAAAAQAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAAAAAB6i5yxQAAAECe7rfndyOX8KE0jYOH5hH8oTYFF06UOEeQWvtLdxP9s0a/V8kTDclsyPpfCiC4dcNV5CPVifcolty05Qap2TUN"; diff --git a/src/operations/set_options.rs b/src/operations/set_options.rs index d19104f..2c3e630 100644 --- a/src/operations/set_options.rs +++ b/src/operations/set_options.rs @@ -182,7 +182,7 @@ impl SetOptionsOperation { let inflation_destination = x .inflation_dest .as_ref() - .map(|d| PublicKey::from_xdr_account_id(d)) + .map(PublicKey::from_xdr_account_id) .transpose()?; let clear_flags = x .clear_flags @@ -199,11 +199,7 @@ impl SetOptionsOperation { let medium_threshold = x.med_threshold.as_ref().map(|w| w.value); let high_threshold = x.high_threshold.as_ref().map(|w| w.value); let home_domain = x.home_domain.as_ref().map(|h| h.value.clone()); - let signer = x - .signer - .as_ref() - .map(|s| Signer::from_xdr(&s)) - .transpose()?; + let signer = x.signer.as_ref().map(Signer::from_xdr).transpose()?; Ok(SetOptionsOperation { source_account, inflation_destination, @@ -306,17 +302,17 @@ mod tests { let kp1 = keypair1(); let op = Operation::new_set_options() - .with_inflation_destination(Some(kp1.public_key().clone())) + .with_inflation_destination(Some(kp1.public_key())) .with_set_flags(Some( AccountFlags::AUTH_REQUIRED | AccountFlags::AUTH_IMMUTABLE, )) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAAlyvHaD8duz+iEXkJUUbsHkklIlH46oMrMMYrt0odkfgAAAAAAAAABAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB6i5yxQAAAEBtYhsjGguNMF06uqEn/cUIdy9eAp/X2jlhTRiVcIGUQJ2U/45eFGXZ8AjgE5P/fWoQYlsUihurccOMwu891EAD"; @@ -331,14 +327,14 @@ mod tests { let kp2 = keypair2(); let op = Operation::new_set_options() - .with_source_account(kp2.public_key().clone()) + .with_source_account(kp2.public_key()) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAEAAAAAfhHLNNY19eGrAtSgLD3VpaRm2AjNjxIBWQg9zS4VWZgAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHqLnLFAAAAQBf+wJNmYicge0JOI5iRVzprRG7AXpfQWCHRCIjqiXvJ0MRv71eSyPdJgUVlcStKM8prTF2TPuO8uWPk2kIRKAo="; @@ -357,11 +353,11 @@ mod tests { )) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAABAAAABQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB6i5yxQAAAECKOes75G40HX5JiVxydn+pu/DTZSGRf0A9eKdDXdS3Znog4kDjnw0vgZ7efMGl8NYW165N13sBub8Dnrc1E+MA"; @@ -380,11 +376,11 @@ mod tests { )) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB6i5yxQAAAEAXg+D6BNKJyRzCHu2np0PSWoAcFanuZa2gfS8a1iAB62buUwxezc/RULixb5W2rQwBxbSyaIrFA/3QJBf480UA"; @@ -404,11 +400,11 @@ mod tests { .with_high_threshold(Some(4)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAEAAAABAAAAAgAAAAEAAAADAAAAAQAAAAQAAAAAAAAAAAAAAAAAAAAB6i5yxQAAAECfQ+WZfpgizILpZL84nvzoDM5+JMQOlA0+9FQZjj6Xr+njvLP/84HFz+lgK3/orX/1MdoBQb61sybrfC1kjdcA"; @@ -422,18 +418,18 @@ mod tests { let kp = keypair0(); let kp2 = keypair2(); - let signer_key = SignerKey::Ed25519(kp2.public_key().clone()); + let signer_key = SignerKey::Ed25519(kp2.public_key()); let signer = Signer::new(signer_key, 8); let op = Operation::new_set_options() .with_signer(Some(signer)) .build() .unwrap(); - let mut tx = Transaction::builder(kp.public_key().clone(), 3556091187167235, MIN_BASE_FEE) + let mut tx = Transaction::builder(kp.public_key(), 3556091187167235, MIN_BASE_FEE) .add_operation(op) .into_transaction() .unwrap(); - tx.sign(&kp.as_ref(), &Network::new_test()).unwrap(); + tx.sign(kp.as_ref(), &Network::new_test()).unwrap(); let envelope = tx.to_envelope(); let xdr = envelope.xdr_base64().unwrap(); let expected = "AAAAAgAAAADg3G3hclysZlFitS+s5zWyiiJD5B0STWy5LXCj6i5yxQAAAGQADKI/AAAAAwAAAAAAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAH4RyzTWNfXhqwLUoCw91aWkZtgIzY8SAVkIPc0uFVmYAAAACAAAAAAAAAAB6i5yxQAAAEDlGdxaTcfjFp4ukgepGrUe2ALXJZvDRBIGWw3ROBsQlxFV9kgx2YvszPy4DWtXQNvc3i0KxrUrR+r2liPGr/QJ"; diff --git a/src/operations/set_trustline_flags.rs b/src/operations/set_trustline_flags.rs index b14b59e..812f034 100644 --- a/src/operations/set_trustline_flags.rs +++ b/src/operations/set_trustline_flags.rs @@ -141,8 +141,8 @@ impl SetTrustLineFlagsOperationBuilder { Error::InvalidOperation("missing asset for set trustline flags operation".to_string()) })?; - let clear_flags = self.clear_flags.or(Some(TrustLineFlags::empty())).unwrap(); - let set_flags = self.set_flags.or(Some(TrustLineFlags::empty())).unwrap(); + let clear_flags = self.clear_flags.unwrap_or_else(TrustLineFlags::empty); + let set_flags = self.set_flags.unwrap_or_else(TrustLineFlags::empty); Ok(Operation::SetTrustLineFlags(SetTrustLineFlagsOperation { source_account: self.source_account, @@ -170,7 +170,7 @@ mod tests { #[test] fn test_set_trustline_flags() { - let trustor = keypair1().public_key().clone(); + let trustor = keypair1().public_key(); let asset = asset0(); let clear_flags = TrustLineFlags::AUTHORIZED_TO_MAINTAIN_LIABILITIES; let set_flags = TrustLineFlags::TRUSTLINE_CLAWBACK_ENABLED; @@ -192,8 +192,8 @@ mod tests { #[test] fn test_set_trustline_flags_with_source_account() { - let source_account = keypair0().public_key().clone(); - let trustor = keypair1().public_key().clone(); + let source_account = keypair0().public_key(); + let trustor = keypair1().public_key(); let asset = asset0(); let clear_flags = TrustLineFlags::AUTHORIZED_TO_MAINTAIN_LIABILITIES; let set_flags = TrustLineFlags::TRUSTLINE_CLAWBACK_ENABLED; diff --git a/src/time_bounds.rs b/src/time_bounds.rs index 1e06665..1f15c51 100644 --- a/src/time_bounds.rs +++ b/src/time_bounds.rs @@ -118,16 +118,16 @@ impl TimeBounds { } impl XDRSerialize for TimeBounds { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr = self.to_xdr()?; - xdr.write_xdr(&mut out).map_err(Error::XdrError) + xdr.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for TimeBounds { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_timebounds, bytes_read) = - xdr::TimeBounds::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::TimeBounds::read_xdr(buffer).map_err(Error::XdrError)?; let res = TimeBounds::from_xdr(&xdr_timebounds)?; Ok((res, bytes_read)) } diff --git a/src/transaction.rs b/src/transaction.rs index 4be4038..156eef0 100644 --- a/src/transaction.rs +++ b/src/transaction.rs @@ -151,7 +151,7 @@ impl Transaction { /// /// This signs the transaction with the preimage `x` of `hash(x)`. pub fn sign_hashx(&mut self, preimage: &[u8]) -> Result<()> { - let signature = self.decorated_signature_from_preimage(&preimage)?; + let signature = self.decorated_signature_from_preimage(preimage)?; self.signatures.push(signature); Ok(()) } @@ -162,14 +162,14 @@ impl Transaction { S: Ed25519Signer, V: Ed25519Verifier + AsRef<[u8]>, { - let signature = self.decorated_signature(key, &network)?; + let signature = self.decorated_signature(key, network)?; self.signatures.push(signature); Ok(()) } /// Returns the decorated signature of the transaction create with `image`. pub fn decorated_signature_from_preimage(&self, preimage: &[u8]) -> Result { - DecoratedSignature::new_from_preimage(&preimage) + DecoratedSignature::new_from_preimage(preimage) } /// Returns the decorated signature of the transaction create with `key` for `network`. @@ -182,7 +182,7 @@ impl Transaction { S: Ed25519Signer, V: Ed25519Verifier + AsRef<[u8]>, { - let tx_hash = self.hash(&network)?; + let tx_hash = self.hash(network)?; Ok(key.sign_decorated(&tx_hash)) } @@ -195,7 +195,7 @@ impl Transaction { /// Returns the transaction signature data as bytes. pub fn signature_data(&self, network: &Network) -> Result> { let mut base = Vec::new(); - let tx_signature_payload = self.to_xdr_transaction_signature_payload(&network)?; + let tx_signature_payload = self.to_xdr_transaction_signature_payload(network)?; tx_signature_payload .write_xdr(&mut base) .map_err(Error::XdrError)?; @@ -263,7 +263,7 @@ impl Transaction { let memo = Memo::from_xdr(&x.memo)?; let mut operations = Vec::new(); for operation in &x.operations { - let xdr_operation = Operation::from_xdr(&operation)?; + let xdr_operation = Operation::from_xdr(operation)?; operations.push(xdr_operation); } Ok(Transaction { @@ -357,7 +357,7 @@ impl FeeBumpTransaction { /// /// This signs the transaction with the preimage `x` of `hash(x)`. pub fn sign_hashx(&mut self, preimage: &[u8]) -> Result<()> { - let signature = self.decorated_signature_from_preimage(&preimage)?; + let signature = self.decorated_signature_from_preimage(preimage)?; self.signatures.push(signature); Ok(()) } @@ -368,14 +368,14 @@ impl FeeBumpTransaction { S: Ed25519Signer, V: Ed25519Verifier + AsRef<[u8]>, { - let signature = self.decorated_signature(key, &network)?; + let signature = self.decorated_signature(key, network)?; self.signatures.push(signature); Ok(()) } /// Returns the decorated signature of the transaction create with `image`. pub fn decorated_signature_from_preimage(&self, preimage: &[u8]) -> Result { - DecoratedSignature::new_from_preimage(&preimage) + DecoratedSignature::new_from_preimage(preimage) } /// Returns the decorated signature of the transaction create with `key` for `network`. @@ -388,7 +388,7 @@ impl FeeBumpTransaction { S: Ed25519Signer, V: Ed25519Verifier + AsRef<[u8]>, { - let tx_hash = self.hash(&network)?; + let tx_hash = self.hash(network)?; Ok(key.sign_decorated(&tx_hash)) } @@ -401,7 +401,7 @@ impl FeeBumpTransaction { /// Returns the transaction signature data as bytes. pub fn signature_data(&self, network: &Network) -> Result> { let mut base = Vec::new(); - let tx_signature_payload = self.to_xdr_transaction_signature_payload(&network)?; + let tx_signature_payload = self.to_xdr_transaction_signature_payload(network)?; tx_signature_payload .write_xdr(&mut base) .map_err(Error::XdrError)?; @@ -436,7 +436,7 @@ impl FeeBumpTransaction { let fee = Stroops::new(x.fee.value); let inner_tx = match &x.inner_tx { xdr::FeeBumpTransactionInnerTx::EnvelopeTypeTx(inner_tx) => { - Transaction::from_xdr_envelope(&inner_tx)? + Transaction::from_xdr_envelope(inner_tx)? } }; Ok(FeeBumpTransaction { @@ -519,8 +519,8 @@ impl TransactionEnvelope { /// This signs the transaction with the preimage `x` of `hash(x)`. pub fn sign_hashx(&mut self, preimage: &[u8]) -> Result<()> { match self { - TransactionEnvelope::Transaction(tx) => tx.sign_hashx(&preimage), - TransactionEnvelope::FeeBumpTransaction(tx) => tx.sign_hashx(&preimage), + TransactionEnvelope::Transaction(tx) => tx.sign_hashx(preimage), + TransactionEnvelope::FeeBumpTransaction(tx) => tx.sign_hashx(preimage), } } @@ -531,17 +531,17 @@ impl TransactionEnvelope { V: Ed25519Verifier + AsRef<[u8]>, { match self { - TransactionEnvelope::Transaction(tx) => tx.sign(key, &network), - TransactionEnvelope::FeeBumpTransaction(tx) => tx.sign(key, &network), + TransactionEnvelope::Transaction(tx) => tx.sign(key, network), + TransactionEnvelope::FeeBumpTransaction(tx) => tx.sign(key, network), } } /// Returns the decorated signature of the transaction create with `image`. pub fn decorated_signature_from_preimage(&self, preimage: &[u8]) -> Result { match self { - TransactionEnvelope::Transaction(tx) => tx.decorated_signature_from_preimage(&preimage), + TransactionEnvelope::Transaction(tx) => tx.decorated_signature_from_preimage(preimage), TransactionEnvelope::FeeBumpTransaction(tx) => { - tx.decorated_signature_from_preimage(&preimage) + tx.decorated_signature_from_preimage(preimage) } } } @@ -557,24 +557,24 @@ impl TransactionEnvelope { V: Ed25519Verifier + AsRef<[u8]>, { match self { - TransactionEnvelope::Transaction(tx) => tx.decorated_signature(key, &network), - TransactionEnvelope::FeeBumpTransaction(tx) => tx.decorated_signature(key, &network), + TransactionEnvelope::Transaction(tx) => tx.decorated_signature(key, network), + TransactionEnvelope::FeeBumpTransaction(tx) => tx.decorated_signature(key, network), } } /// Returns the transaction hash for the transaction on `network`. pub fn hash(&self, network: &Network) -> Result> { match self { - TransactionEnvelope::Transaction(tx) => tx.hash(&network), - TransactionEnvelope::FeeBumpTransaction(tx) => tx.hash(&network), + TransactionEnvelope::Transaction(tx) => tx.hash(network), + TransactionEnvelope::FeeBumpTransaction(tx) => tx.hash(network), } } /// Returns the transaction signature data as bytes. pub fn signature_data(&self, network: &Network) -> Result> { match self { - TransactionEnvelope::Transaction(tx) => tx.signature_data(&network), - TransactionEnvelope::FeeBumpTransaction(tx) => tx.signature_data(&network), + TransactionEnvelope::Transaction(tx) => tx.signature_data(network), + TransactionEnvelope::FeeBumpTransaction(tx) => tx.signature_data(network), } } @@ -614,10 +614,10 @@ impl TransactionEnvelope { ) -> Result { match self { TransactionEnvelope::Transaction(tx) => { - tx.to_xdr_transaction_signature_payload(&network) + tx.to_xdr_transaction_signature_payload(network) } TransactionEnvelope::FeeBumpTransaction(tx) => { - tx.to_xdr_transaction_signature_payload(&network) + tx.to_xdr_transaction_signature_payload(network) } } } @@ -685,7 +685,7 @@ impl TransactionBuilder { let fee = self .base_fee .checked_mul(&Stroops::new(tx.operations.len() as i64)) - .ok_or_else(|| Error::TransactionFeeOverflow)?; + .ok_or(Error::TransactionFeeOverflow)?; *tx.fee_mut() = fee; } @@ -697,16 +697,16 @@ impl TransactionBuilder { } impl XDRSerialize for TransactionEnvelope { - fn write_xdr(&self, mut out: &mut Vec) -> Result { + fn write_xdr(&self, out: &mut Vec) -> Result { let xdr_tx = self.to_xdr()?; - xdr_tx.write_xdr(&mut out).map_err(Error::XdrError) + xdr_tx.write_xdr(out).map_err(Error::XdrError) } } impl XDRDeserialize for TransactionEnvelope { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_tx, bytes_read) = - xdr::TransactionEnvelope::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::TransactionEnvelope::read_xdr(buffer).map_err(Error::XdrError)?; let res = TransactionEnvelope::from_xdr(&xdr_tx)?; Ok((res, bytes_read)) } @@ -726,7 +726,7 @@ fn signatures_from_xdr( ) -> Result> { let mut signatures = Vec::new(); for xdr_signature in xdr_signatures { - let signature = DecoratedSignature::from_xdr(&xdr_signature)?; + let signature = DecoratedSignature::from_xdr(xdr_signature)?; signatures.push(signature); } Ok(signatures) @@ -744,7 +744,7 @@ mod tests { #[test] fn test_transaction_builder() { let kp = SodiumKeyPair::random().unwrap(); - let tx = Transaction::builder(kp.public_key().clone(), 123, Stroops::new(100)) + let tx = Transaction::builder(kp.public_key(), 123, Stroops::new(100)) .with_memo(Memo::new_id(987)) .with_time_bounds(TimeBounds::always_valid()) .add_operation(Operation::new_inflation().build()) diff --git a/src/transaction_result.rs b/src/transaction_result.rs index ce48a0e..f288897 100644 --- a/src/transaction_result.rs +++ b/src/transaction_result.rs @@ -455,7 +455,7 @@ impl TransactionResult { impl XDRDeserialize for TransactionResult { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_result, bytes_read) = - xdr::TransactionResult::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::TransactionResult::read_xdr(buffer).map_err(Error::XdrError)?; let res = TransactionResult::from_xdr(&xdr_result)?; Ok((res, bytes_read)) } @@ -735,7 +735,7 @@ impl InnerTransactionResult { impl XDRDeserialize for InnerTransactionResult { fn from_xdr_bytes(buffer: &[u8]) -> Result<(Self, u64)> { let (xdr_result, bytes_read) = - xdr::InnerTransactionResult::read_xdr(&buffer).map_err(Error::XdrError)?; + xdr::InnerTransactionResult::read_xdr(buffer).map_err(Error::XdrError)?; let res = InnerTransactionResult::from_xdr(&xdr_result)?; Ok((res, bytes_read)) } @@ -749,119 +749,119 @@ mod tests { #[test] fn test_fee_bump_success() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAA="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_fee_bump_success()); } #[test] fn test_fee_bump_failed() { let xdr = "AAAAAAAAA+j////zAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAA="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_fee_bump_failed()); } #[test] fn test_success() { let xdr = "AAAAAAAAA+gAAAAAAAAAAAAAAAA="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_success()); } #[test] fn test_failed() { let xdr = "AAAAAAAAA+j/////AAAAAAAAAAA="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_failed()); } #[test] fn test_too_early() { let xdr = "AAAAAAAPQkD////+AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_too_early()); } #[test] fn test_too_late() { let xdr = "AAAAAAAPQkD////9AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_too_late()); } #[test] fn test_missing_operation() { let xdr = "AAAAAAAPQkD////8AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_missing_operation()); } #[test] fn test_bad_sequence() { let xdr = "AAAAAAAPQkD////7AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_bad_sequence()); } #[test] fn test_bad_auth() { let xdr = "AAAAAAAPQkD////6AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_bad_auth()); } #[test] fn test_insufficient_balance() { let xdr = "AAAAAAAPQkD////5AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_insufficient_balance()); } #[test] fn test_no_account() { let xdr = "AAAAAAAPQkD////4AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_no_account()); } #[test] fn test_insufficient_fee() { let xdr = "AAAAAAAPQkD////3AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_insufficient_fee()); } #[test] fn test_bad_auth_extra() { let xdr = "AAAAAAAPQkD////2AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_bad_auth_extra()); } #[test] fn test_internal_error() { let xdr = "AAAAAAAPQkD////1AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_internal_error()); } #[test] fn test_not_supported() { let xdr = "AAAAAAAPQkD////0AAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_not_supported()); } #[test] fn test_bad_sponsorship() { let xdr = "AAAAAAAPQkD////yAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); assert!(result.is_bad_sponsorship()); } #[test] fn test_inner_success() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0AAAAAAAAAAAAAAAAAAAAAA="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_success()); } @@ -869,7 +869,7 @@ mod tests { #[test] fn test_inner_failed() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////8AAAAAAAAAAAAAAAA="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_failed()); } @@ -877,7 +877,7 @@ mod tests { #[test] fn test_inner_too_early() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////4AAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_too_early()); } @@ -885,7 +885,7 @@ mod tests { #[test] fn test_inner_too_late() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////0AAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_too_late()); } @@ -893,7 +893,7 @@ mod tests { #[test] fn test_inner_missing_operation() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////wAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_missing_operation()); } @@ -901,7 +901,7 @@ mod tests { #[test] fn test_inner_bad_sequence() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////sAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_bad_sequence()); } @@ -909,7 +909,7 @@ mod tests { #[test] fn test_inner_bad_auth() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////oAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_bad_auth()); } @@ -917,7 +917,7 @@ mod tests { #[test] fn test_inner_insufficient_balance() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////kAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_insufficient_balance()); } @@ -925,7 +925,7 @@ mod tests { #[test] fn test_inner_no_account() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////gAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_no_account()); } @@ -933,7 +933,7 @@ mod tests { #[test] fn test_inner_insufficient_fee() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////cAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_insufficient_fee()); } @@ -941,7 +941,7 @@ mod tests { #[test] fn test_inner_bad_auth_extra() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////YAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_bad_auth_extra()); } @@ -949,7 +949,7 @@ mod tests { #[test] fn test_inner_internal_error() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////UAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_internal_error()); } @@ -957,7 +957,7 @@ mod tests { #[test] fn test_inner_not_supported() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////QAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_not_supported()); } @@ -965,7 +965,7 @@ mod tests { #[test] fn test_inner_bad_sponsorship() { let xdr = "AAAAAAAAA+gAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH0P////IAAAAAAAAAAA=="; - let result = TransactionResult::from_xdr_base64(&xdr).unwrap(); + let result = TransactionResult::from_xdr_base64(xdr).unwrap(); let inner_result = result.as_fee_bump_success().unwrap().result.clone(); assert!(inner_result.is_bad_sponsorship()); }