From fb6c00dc0a3dc448faa08dae626dec0124092ece Mon Sep 17 00:00:00 2001 From: LouiseMedova Date: Fri, 16 Aug 2024 13:45:02 +0300 Subject: [PATCH] fixed warnings --- gear-programs/bridging-payment/src/services/mod.rs | 7 ------- .../bridging-payment/src/services/msg_tracker.rs | 1 + .../bridging-payment/src/services/token_msg.rs | 2 +- gear-programs/bridging-payment/src/services/vft.rs | 7 ++++++- .../bridging-payment/src/services/vft_gateway.rs | 7 ++++++- .../bridging-payment/src/services/vft_gateway_msg.rs | 6 ++---- gear-programs/bridging-payment/src/wasm/Cargo.toml | 2 +- .../src/wasm/tests/bridging_payment.rs | 2 +- .../src/services/bridge_builtin_operations.rs | 4 ++-- gear-programs/vft-gateway/src/services/mod.rs | 11 ++--------- .../vft-gateway/src/services/token_operations.rs | 4 ++-- gear-programs/vft-gateway/src/services/utils.rs | 2 +- gear-programs/vft-gateway/src/services/vft.rs | 7 ++++++- gear-programs/vft-gateway/src/wasm/tests/utils.rs | 12 ------------ .../vft-gateway/src/wasm/tests/vft_gateway.rs | 6 +++--- 15 files changed, 34 insertions(+), 46 deletions(-) diff --git a/gear-programs/bridging-payment/src/services/mod.rs b/gear-programs/bridging-payment/src/services/mod.rs index c274115d..bfbb7612 100644 --- a/gear-programs/bridging-payment/src/services/mod.rs +++ b/gear-programs/bridging-payment/src/services/mod.rs @@ -110,13 +110,6 @@ where } } - fn data_mut(&mut self) -> &mut BridgingPaymentData { - unsafe { - DATA.as_mut() - .expect("BridgingPaymentData::seed() should be called") - } - } - fn config(&self) -> &Config { unsafe { CONFIG diff --git a/gear-programs/bridging-payment/src/services/msg_tracker.rs b/gear-programs/bridging-payment/src/services/msg_tracker.rs index c5448c66..e9bfe8e7 100644 --- a/gear-programs/bridging-payment/src/services/msg_tracker.rs +++ b/gear-programs/bridging-payment/src/services/msg_tracker.rs @@ -1,5 +1,6 @@ use super::{error::Error, MSG_TRACKER}; use gstd::prelude::collections::HashMap; +#[allow(unused_imports)] use sails_rs::{calls::ActionIo, prelude::*}; #[derive(Default)] pub struct MessageTracker { diff --git a/gear-programs/bridging-payment/src/services/token_msg.rs b/gear-programs/bridging-payment/src/services/token_msg.rs index a0f0ffc1..54a8b6cf 100644 --- a/gear-programs/bridging-payment/src/services/token_msg.rs +++ b/gear-programs/bridging-payment/src/services/token_msg.rs @@ -5,7 +5,7 @@ use super::{ vft::vft::io as vft_io, Config, }; - +#[allow(unused_imports)] use sails_rs::{calls::ActionIo, prelude::*}; pub async fn transfer_tokens( diff --git a/gear-programs/bridging-payment/src/services/vft.rs b/gear-programs/bridging-payment/src/services/vft.rs index 5a211678..f22fa37d 100644 --- a/gear-programs/bridging-payment/src/services/vft.rs +++ b/gear-programs/bridging-payment/src/services/vft.rs @@ -1 +1,6 @@ -include!(concat!(env!("OUT_DIR"), "/vft.rs")); +mod vft_module { + #![allow(dead_code)] + include!(concat!(env!("OUT_DIR"), "/vft.rs")); +} + +pub use vft_module::*; \ No newline at end of file diff --git a/gear-programs/bridging-payment/src/services/vft_gateway.rs b/gear-programs/bridging-payment/src/services/vft_gateway.rs index 910963ee..44073196 100644 --- a/gear-programs/bridging-payment/src/services/vft_gateway.rs +++ b/gear-programs/bridging-payment/src/services/vft_gateway.rs @@ -1 +1,6 @@ -include!(concat!(env!("OUT_DIR"), "/vft-gateway.rs")); +mod vft_gateway_module { + #![allow(dead_code)] + include!(concat!(env!("OUT_DIR"), "/vft-gateway.rs")); +} + +pub use vft_gateway_module::*; \ No newline at end of file diff --git a/gear-programs/bridging-payment/src/services/vft_gateway_msg.rs b/gear-programs/bridging-payment/src/services/vft_gateway_msg.rs index bc08e065..72864991 100644 --- a/gear-programs/bridging-payment/src/services/vft_gateway_msg.rs +++ b/gear-programs/bridging-payment/src/services/vft_gateway_msg.rs @@ -1,11 +1,9 @@ use super::{ error::Error, msg_tracker::{msg_tracker_mut, MessageStatus, TransactionDetails}, - utils, vft_gateway, - vft_gateway::vft_gateway::io as vft_gateway_io, - Config, + utils, vft_gateway, Config, }; -use gstd::{msg, prelude::collections::HashMap, MessageId}; +#[allow(unused_imports)] use sails_rs::calls::ActionIo; use sails_rs::prelude::*; diff --git a/gear-programs/bridging-payment/src/wasm/Cargo.toml b/gear-programs/bridging-payment/src/wasm/Cargo.toml index 17369036..5f6ca39e 100644 --- a/gear-programs/bridging-payment/src/wasm/Cargo.toml +++ b/gear-programs/bridging-payment/src/wasm/Cargo.toml @@ -21,4 +21,4 @@ scale-info.workspace = true sails-rs.workspace = true [lib] -crate-type = ["rlib"] \ No newline at end of file +crate-type = ["rlib"] diff --git a/gear-programs/bridging-payment/src/wasm/tests/bridging_payment.rs b/gear-programs/bridging-payment/src/wasm/tests/bridging_payment.rs index 030ba3f1..a984d934 100644 --- a/gear-programs/bridging-payment/src/wasm/tests/bridging_payment.rs +++ b/gear-programs/bridging-payment/src/wasm/tests/bridging_payment.rs @@ -1,5 +1,5 @@ use gtest::{Program, System}; -use sails_rs::{prelude::*}; +use sails_rs::prelude::*; mod utils; use utils::{ diff --git a/gear-programs/vft-gateway/src/services/bridge_builtin_operations.rs b/gear-programs/vft-gateway/src/services/bridge_builtin_operations.rs index 84c56486..ab7a27fc 100644 --- a/gear-programs/vft-gateway/src/services/bridge_builtin_operations.rs +++ b/gear-programs/vft-gateway/src/services/bridge_builtin_operations.rs @@ -1,5 +1,5 @@ -use super::{msg_tracker, msg_tracker_mut, utils, Config, Error, MessageStatus, MessageTracker}; -use gstd::{msg, MessageId}; +use super::{msg_tracker_mut, utils, Config, Error, MessageStatus}; +use gstd::{MessageId}; use sails_rs::prelude::*; pub async fn send_message_to_bridge_builtin( diff --git a/gear-programs/vft-gateway/src/services/mod.rs b/gear-programs/vft-gateway/src/services/mod.rs index b370628b..22402d83 100644 --- a/gear-programs/vft-gateway/src/services/mod.rs +++ b/gear-programs/vft-gateway/src/services/mod.rs @@ -1,6 +1,6 @@ use collections::HashMap; use sails_rs::{ - gstd::{msg, ExecContext}, + gstd::{ExecContext}, prelude::*, }; @@ -264,14 +264,7 @@ where .expect("VftGateway::seed() should be called") } } - - fn config_mut(&mut self) -> &mut Config { - unsafe { - CONFIG - .as_mut() - .expect("VftGatewayData::seed() should be called") - } - } + fn get_eth_token_id(&self, vara_token_id: &ActorId) -> Result { self.data() .vara_to_eth_token_id diff --git a/gear-programs/vft-gateway/src/services/token_operations.rs b/gear-programs/vft-gateway/src/services/token_operations.rs index 7be5b8ec..4749cb57 100644 --- a/gear-programs/vft-gateway/src/services/token_operations.rs +++ b/gear-programs/vft-gateway/src/services/token_operations.rs @@ -1,8 +1,8 @@ use super::msg_tracker::TransactionDetails; use super::{ - msg_tracker, msg_tracker_mut, utils, vft::vft::io as vft_io, Config, Error, MessageStatus, + msg_tracker_mut, utils, vft::vft::io as vft_io, Config, Error, MessageStatus, }; -use gstd::msg; +#[allow(unused_imports)] use sails_rs::calls::ActionIo; use sails_rs::prelude::*; pub async fn burn_tokens( diff --git a/gear-programs/vft-gateway/src/services/utils.rs b/gear-programs/vft-gateway/src/services/utils.rs index 79a40c2c..49aa8883 100644 --- a/gear-programs/vft-gateway/src/services/utils.rs +++ b/gear-programs/vft-gateway/src/services/utils.rs @@ -135,9 +135,9 @@ fn decode_bridge_reply(bytes: &[u8]) -> Result, Error> { let reply = gbuiltin_eth_bridge::Response::decode(&mut bytes.as_ref()) .map_err(|_| Error::BuiltinDecodeError)?; + match reply { gbuiltin_eth_bridge::Response::EthMessageQueued { nonce, .. } => Ok(Some(nonce)), - _ => Ok(None), } } diff --git a/gear-programs/vft-gateway/src/services/vft.rs b/gear-programs/vft-gateway/src/services/vft.rs index 5a211678..3887cc79 100644 --- a/gear-programs/vft-gateway/src/services/vft.rs +++ b/gear-programs/vft-gateway/src/services/vft.rs @@ -1 +1,6 @@ -include!(concat!(env!("OUT_DIR"), "/vft.rs")); +mod vft_module { + #![allow(dead_code)] + include!(concat!(env!("OUT_DIR"), "/vft.rs")); +} + +pub use vft_module::*; diff --git a/gear-programs/vft-gateway/src/wasm/tests/utils.rs b/gear-programs/vft-gateway/src/wasm/tests/utils.rs index 4eccd1f3..ee9cf17b 100644 --- a/gear-programs/vft-gateway/src/wasm/tests/utils.rs +++ b/gear-programs/vft-gateway/src/wasm/tests/utils.rs @@ -4,7 +4,6 @@ use vft_gateway_app::services::{error::Error, msg_tracker::MessageInfo, Config, use sails_rs::prelude::*; pub const ADMIN_ID: u64 = 1000; -pub const FEE: u128 = 10_000_000_000_000; pub const TOKEN_ID: u64 = 200; pub const BRIDGE_BUILTIN_ID: u64 = 300; @@ -71,7 +70,6 @@ create_mock!(GearBridgeBuiltinMockPanic, Err("Error")); pub trait Token { fn token(system: &System, id: u64) -> Program<'_>; fn mint(&self, from: u64, to: ActorId, value: U256); - fn approve(&self, from: u64, spender: ActorId, value: U256); fn grant_burner_role(&self, from: u64, to: ActorId); fn grant_minter_role(&self, from: u64, to: ActorId); fn balance_of(&self, account: ActorId) -> U256; @@ -91,16 +89,6 @@ impl Token for Program<'_> { assert!(!self.send_bytes(from, payload).main_failed()); } - fn approve(&self, from: u64, spender: ActorId, value: U256) { - let payload = [ - "Vft".encode(), - "Approve".encode(), - (spender, value).encode(), - ] - .concat(); - assert!(!self.send_bytes(from, payload).main_failed()); - } - fn grant_burner_role(&self, from: u64, to: ActorId) { let payload = ["Vft".encode(), "GrantBurnerRole".encode(), to.encode()].concat(); assert!(!self.send_bytes(from, payload).main_failed()); diff --git a/gear-programs/vft-gateway/src/wasm/tests/vft_gateway.rs b/gear-programs/vft-gateway/src/wasm/tests/vft_gateway.rs index 1fea1685..2e41b6d0 100644 --- a/gear-programs/vft-gateway/src/wasm/tests/vft_gateway.rs +++ b/gear-programs/vft-gateway/src/wasm/tests/vft_gateway.rs @@ -1,12 +1,12 @@ use gtest::{Program, System}; -use sails_rs::{collections::HashMap, prelude::*}; +use sails_rs::{prelude::*}; use vft_gateway_app::services::{error::Error, msg_tracker::MessageStatus}; mod utils; use utils::{ - FTMockError, FTMockReturnsFalse, FTMockReturnsTrue, FTMockWrongReply, GearBridgeBuiltinMock, - GearBridgeBuiltinMockPanic, Token, VftGateway, ADMIN_ID, BRIDGE_BUILTIN_ID, FEE, TOKEN_ID, + FTMockError, FTMockReturnsFalse, GearBridgeBuiltinMock, + GearBridgeBuiltinMockPanic, Token, VftGateway, ADMIN_ID, BRIDGE_BUILTIN_ID, TOKEN_ID, }; #[test]