Skip to content

Commit

Permalink
fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
LouiseMedova committed Aug 16, 2024
1 parent 5e6ba15 commit fb6c00d
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 46 deletions.
7 changes: 0 additions & 7 deletions gear-programs/bridging-payment/src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions gear-programs/bridging-payment/src/services/msg_tracker.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion gear-programs/bridging-payment/src/services/token_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 6 additions & 1 deletion gear-programs/bridging-payment/src/services/vft.rs
Original file line number Diff line number Diff line change
@@ -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::*;
7 changes: 6 additions & 1 deletion gear-programs/bridging-payment/src/services/vft_gateway.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Original file line number Diff line number Diff line change
@@ -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::*;

Expand Down
2 changes: 1 addition & 1 deletion gear-programs/bridging-payment/src/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ scale-info.workspace = true
sails-rs.workspace = true

[lib]
crate-type = ["rlib"]
crate-type = ["rlib"]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use gtest::{Program, System};
use sails_rs::{prelude::*};
use sails_rs::prelude::*;

mod utils;
use utils::{
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
11 changes: 2 additions & 9 deletions gear-programs/vft-gateway/src/services/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use collections::HashMap;
use sails_rs::{
gstd::{msg, ExecContext},
gstd::{ExecContext},
prelude::*,
};

Expand Down Expand Up @@ -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<H160, Error> {
self.data()
.vara_to_eth_token_id
Expand Down
4 changes: 2 additions & 2 deletions gear-programs/vft-gateway/src/services/token_operations.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
2 changes: 1 addition & 1 deletion gear-programs/vft-gateway/src/services/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ fn decode_bridge_reply(bytes: &[u8]) -> Result<Option<U256>, Error> {
let reply = gbuiltin_eth_bridge::Response::decode(&mut bytes.as_ref())

Check failure on line 135 in gear-programs/vft-gateway/src/services/utils.rs

View workflow job for this annotation

GitHub Actions / lints

this call to `as_ref` does nothing
.map_err(|_| Error::BuiltinDecodeError)?;


match reply {
gbuiltin_eth_bridge::Response::EthMessageQueued { nonce, .. } => Ok(Some(nonce)),
_ => Ok(None),
}
}

Expand Down
7 changes: 6 additions & 1 deletion gear-programs/vft-gateway/src/services/vft.rs
Original file line number Diff line number Diff line change
@@ -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::*;
12 changes: 0 additions & 12 deletions gear-programs/vft-gateway/src/wasm/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down
6 changes: 3 additions & 3 deletions gear-programs/vft-gateway/src/wasm/tests/vft_gateway.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand Down

0 comments on commit fb6c00d

Please sign in to comment.