From f42453be4538153cee4eb6c150798590e8d1c55a Mon Sep 17 00:00:00 2001 From: Hendrik Hofstadt Date: Mon, 23 Aug 2021 09:51:31 +0200 Subject: [PATCH] Resolve rust compiler warnings Change-Id: Iaac63d0fb44ecb7e03d68a10df7bddbb521c73a0 --- solana/bridge/program/src/api/post_message.rs | 3 +- solana/bridge/program/src/api/post_vaa.rs | 1 - solana/bridge/program/src/instructions.rs | 2 +- solana/bridge/program/src/types.rs | 39 ++++++++++--------- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/solana/bridge/program/src/api/post_message.rs b/solana/bridge/program/src/api/post_message.rs index 18a6e34e..f66ab830 100644 --- a/solana/bridge/program/src/api/post_message.rs +++ b/solana/bridge/program/src/api/post_message.rs @@ -57,7 +57,8 @@ pub struct PostMessage<'b> { pub clock: Sysvar<'b, Clock>, } -impl<'b> InstructionContext<'b> for PostMessage<'b> {} +impl<'b> InstructionContext<'b> for PostMessage<'b> { +} #[derive(BorshDeserialize, BorshSerialize)] pub struct PostMessageData { diff --git a/solana/bridge/program/src/api/post_vaa.rs b/solana/bridge/program/src/api/post_vaa.rs index e42e0ed4..4bcc8b14 100644 --- a/solana/bridge/program/src/api/post_vaa.rs +++ b/solana/bridge/program/src/api/post_vaa.rs @@ -23,7 +23,6 @@ use crate::{ PostVAAConsensusFailed, PostVAAGuardianSetExpired, }, - CHAIN_ID_SOLANA, }; use byteorder::{ BigEndian, diff --git a/solana/bridge/program/src/instructions.rs b/solana/bridge/program/src/instructions.rs index 611fcfbb..be4817d6 100644 --- a/solana/bridge/program/src/instructions.rs +++ b/solana/bridge/program/src/instructions.rs @@ -173,7 +173,7 @@ pub fn post_vaa( &program_id, ); - let mut msg_derivation_data = &PostedVAADerivationData { + let msg_derivation_data = &PostedVAADerivationData { payload_hash: hash_vaa(&vaa).to_vec(), }; diff --git a/solana/bridge/program/src/types.rs b/solana/bridge/program/src/types.rs index 9e8c71c8..2a26f5c0 100644 --- a/solana/bridge/program/src/types.rs +++ b/solana/bridge/program/src/types.rs @@ -41,7 +41,6 @@ use std::{ Deref, DerefMut, }, - str::FromStr, }; #[derive(Default, BorshSerialize, BorshDeserialize, Serialize, Deserialize)] @@ -176,9 +175,8 @@ impl Owned for PostedMessageData { #[cfg(feature = "cpi")] impl Owned for PostedMessageData { fn owner(&self) -> AccountOwner { - AccountOwner::Other( - Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap(), - ) + use std::str::FromStr; + AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap()) } } @@ -270,9 +268,8 @@ impl Owned for PostedVAAData { #[cfg(feature = "cpi")] impl Owned for PostedVAAData { fn owner(&self) -> AccountOwner { - AccountOwner::Other( - Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap(), - ) + use std::str::FromStr; + AccountOwner::Other(Pubkey::from_str(env!("BRIDGE_ADDRESS")).unwrap()) } } @@ -311,8 +308,8 @@ impl SerializePayload for GovernancePayloadUpgrade { } impl DeserializePayload for GovernancePayloadUpgrade - where - Self: DeserializeGovernancePayload, +where + Self: DeserializeGovernancePayload, { fn deserialize(buf: &mut &[u8]) -> Result { let mut c = Cursor::new(buf); @@ -336,7 +333,8 @@ impl SerializeGovernancePayload for GovernancePayloadUpgrade { const ACTION: u8 = 1; } -impl DeserializeGovernancePayload for GovernancePayloadUpgrade {} +impl DeserializeGovernancePayload for GovernancePayloadUpgrade { +} pub struct GovernancePayloadGuardianSetChange { // New GuardianSetIndex @@ -359,8 +357,8 @@ impl SerializePayload for GovernancePayloadGuardianSetChange { } impl DeserializePayload for GovernancePayloadGuardianSetChange - where - Self: DeserializeGovernancePayload, +where + Self: DeserializeGovernancePayload, { fn deserialize(buf: &mut &[u8]) -> Result { let mut c = Cursor::new(buf); @@ -392,7 +390,8 @@ impl SerializeGovernancePayload for GovernancePayloadGuardianSetChange { const ACTION: u8 = 2; } -impl DeserializeGovernancePayload for GovernancePayloadGuardianSetChange {} +impl DeserializeGovernancePayload for GovernancePayloadGuardianSetChange { +} pub struct GovernancePayloadSetMessageFee { // New fee in lamports @@ -410,8 +409,8 @@ impl SerializePayload for GovernancePayloadSetMessageFee { } impl DeserializePayload for GovernancePayloadSetMessageFee - where - Self: DeserializeGovernancePayload, +where + Self: DeserializeGovernancePayload, { fn deserialize(buf: &mut &[u8]) -> Result { let mut c = Cursor::new(buf); @@ -434,7 +433,8 @@ impl SerializeGovernancePayload for GovernancePayloadSetMessageFee { const ACTION: u8 = 3; } -impl DeserializeGovernancePayload for GovernancePayloadSetMessageFee {} +impl DeserializeGovernancePayload for GovernancePayloadSetMessageFee { +} pub struct GovernancePayloadTransferFees { // Amount to be transferred @@ -455,8 +455,8 @@ impl SerializePayload for GovernancePayloadTransferFees { } impl DeserializePayload for GovernancePayloadTransferFees - where - Self: DeserializeGovernancePayload, +where + Self: DeserializeGovernancePayload, { fn deserialize(buf: &mut &[u8]) -> Result { let mut c = Cursor::new(buf); @@ -482,7 +482,8 @@ impl SerializeGovernancePayload for GovernancePayloadTransferFees { const ACTION: u8 = 4; } -impl DeserializeGovernancePayload for GovernancePayloadTransferFees {} +impl DeserializeGovernancePayload for GovernancePayloadTransferFees { +} #[repr(u8)] #[derive(BorshSerialize, BorshDeserialize, Clone, Serialize, Deserialize)]