Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Jan 20, 2024
1 parent 0cef146 commit d9917e1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
74 changes: 37 additions & 37 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ mod test {
let metadata = Icrc2Canister::icrc1_metadata();
assert_eq!(metadata.len(), 5);
assert_eq!(
metadata.get(0).unwrap(),
metadata.first().unwrap(),
&(
"icrc1:symbol".to_string(),
MetadataValue::from(ICRC1_SYMBOL)
Expand Down Expand Up @@ -455,7 +455,7 @@ mod test {
init_canister();
assert_eq!(
Icrc2Canister::icrc1_total_supply(),
Nat::from(int_to_decimals(8_888_888))
int_to_decimals(8_888_888)
);
}

Expand All @@ -473,15 +473,15 @@ mod test {
init_canister();
assert_eq!(
Icrc2Canister::icrc1_balance_of(alice_account()),
Nat::from(int_to_decimals(50_000))
int_to_decimals(50_000)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(bob_account()),
Nat::from(int_to_decimals(50_000))
int_to_decimals(50_000)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(100_000))
int_to_decimals(100_000)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(Account {
Expand All @@ -498,19 +498,19 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE)),
created_at_time: Some(utils::time()),
memo: None,
};
assert!(Icrc2Canister::icrc1_transfer(transfer_args).is_ok());
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(90_000) - ICRC1_FEE)
(int_to_decimals(90_000) - ICRC1_FEE)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(bob_account()),
Nat::from(int_to_decimals(60_000))
int_to_decimals(60_000)
);
}

Expand All @@ -520,7 +520,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE)),
created_at_time: Some(0),
memo: None,
Expand All @@ -537,7 +537,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE)),
created_at_time: Some(utils::time() - (ICRC1_TX_TIME_SKID.as_nanos() as u64 * 2)),
memo: None,
Expand All @@ -554,7 +554,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE)),
created_at_time: Some(utils::time() + (ICRC1_TX_TIME_SKID.as_nanos() as u64 * 2)),
memo: None,
Expand All @@ -571,7 +571,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE / 2)),
created_at_time: Some(utils::time()),
memo: None,
Expand All @@ -589,15 +589,15 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
created_at_time: Some(utils::time()),
memo: None,
};
assert!(Icrc2Canister::icrc1_transfer(transfer_args).is_ok());
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(90_000) - ICRC1_FEE)
(int_to_decimals(90_000) - ICRC1_FEE)
);
}

Expand All @@ -607,15 +607,15 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE * 2)),
created_at_time: Some(utils::time()),
memo: None,
};
assert!(Icrc2Canister::icrc1_transfer(transfer_args).is_ok());
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(90_000) - (ICRC1_FEE * 2))
(int_to_decimals(90_000) - (ICRC1_FEE * 2))
);
}

Expand All @@ -625,7 +625,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
created_at_time: Some(utils::time()),
memo: Some("9888".as_bytes().to_vec().into()),
Expand All @@ -639,7 +639,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
created_at_time: Some(utils::time()),
memo: Some("988898889888988898889888988898889888988898889888988898889888988898889888988898889888988898889888".as_bytes().to_vec().into()),
Expand All @@ -657,7 +657,7 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: Some(Nat::from(ICRC1_FEE)),
created_at_time: Some(utils::time()),
memo: Some(
Expand All @@ -671,11 +671,11 @@ mod test {
assert!(Icrc2Canister::icrc1_transfer(transfer_args).is_ok());
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(90_000) - ICRC1_FEE)
(int_to_decimals(90_000) - ICRC1_FEE)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(bob_account()),
Nat::from(int_to_decimals(60_000))
int_to_decimals(60_000)
);
}

Expand All @@ -685,19 +685,19 @@ mod test {
let transfer_args = TransferArg {
from_subaccount: caller_account().subaccount,
to: Icrc2Canister::icrc1_minting_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
created_at_time: Some(utils::time()),
memo: None,
};
assert!(Icrc2Canister::icrc1_transfer(transfer_args).is_ok());
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(90_000))
int_to_decimals(90_000)
);
assert_eq!(
Icrc2Canister::icrc1_total_supply(),
Nat::from(int_to_decimals(8_888_888 - 10_000))
int_to_decimals(8_888_888 - 10_000)
);
}

Expand All @@ -707,7 +707,7 @@ mod test {
let extensions = Icrc2Canister::icrc1_supported_standards();
assert_eq!(extensions.len(), 2);
assert_eq!(
extensions.get(0).unwrap().name,
extensions.first().unwrap().name,
crate::TokenExtension::icrc1().name
);
assert_eq!(
Expand All @@ -722,7 +722,7 @@ mod test {
let approval_args = ApproveArgs {
from_subaccount: caller_account().subaccount,
spender: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
expires_at: None,
expected_allowance: None,
Expand All @@ -738,7 +738,7 @@ mod test {
spender: bob_account(),
}),
Allowance {
allowance: Nat::from(int_to_decimals(10_000)),
allowance: int_to_decimals(10_000),
expires_at: None,
}
);
Expand All @@ -755,8 +755,8 @@ mod test {
let approval_args = ApproveArgs {
from_subaccount: caller_account().subaccount,
spender: bob_account(),
amount: Nat::from(int_to_decimals(10_000)),
fee: Some(Nat::from(int_to_decimals(110_000))),
amount: int_to_decimals(10_000),
fee: Some(int_to_decimals(110_000)),
expires_at: None,
expected_allowance: None,
memo: None,
Expand All @@ -772,7 +772,7 @@ mod test {
let approval_args = ApproveArgs {
from_subaccount: bob_account().subaccount,
spender: caller_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
expires_at: None,
expected_allowance: None,
Expand All @@ -786,7 +786,7 @@ mod test {
spender: caller_account(),
}),
Allowance {
allowance: Nat::from(int_to_decimals(10_000)),
allowance: int_to_decimals(10_000),
expires_at: None,
}
);
Expand All @@ -796,7 +796,7 @@ mod test {
spender_subaccount: caller_account().subaccount,
from: bob_account(),
to: alice_account(),
amount: Nat::from(int_to_decimals(10_000)),
amount: int_to_decimals(10_000),
fee: None,
memo: None,
created_at_time: None,
Expand All @@ -805,15 +805,15 @@ mod test {
// verify balance
assert_eq!(
Icrc2Canister::icrc1_balance_of(bob_account()),
Nat::from(int_to_decimals(40_000))
int_to_decimals(40_000)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(alice_account()),
Nat::from(int_to_decimals(60_000))
int_to_decimals(60_000)
);
assert_eq!(
Icrc2Canister::icrc1_balance_of(caller_account()),
Nat::from(int_to_decimals(100_000) - ICRC1_FEE)
(int_to_decimals(100_000) - ICRC1_FEE)
);
// verify allowance
assert_eq!(
Expand All @@ -822,7 +822,7 @@ mod test {
spender: caller_account(),
}),
Allowance {
allowance: Nat::from(int_to_decimals(0)),
allowance: int_to_decimals(0),
expires_at: None,
}
);
Expand All @@ -838,7 +838,7 @@ mod test {
symbol: ICRC1_SYMBOL.to_string(),
name: ICRC1_NAME.to_string(),
decimals: ICRC1_DECIMALS,
fee: ICRC1_FEE.into(),
fee: ICRC1_FEE,
logo: ICRC1_LOGO.to_string(),
total_supply: int_to_decimals(8_888_888),
minting_account: minting_account(),
Expand Down
4 changes: 2 additions & 2 deletions src/app/balance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ mod test {

Balance::init_balances(total_supply, initial_balances);

let canister_account = CANISTER_WALLET_ACCOUNT.with_borrow(|wallet| wallet.get().0.clone());
let canister_account = CANISTER_WALLET_ACCOUNT.with_borrow(|wallet| wallet.get().0);
assert_eq!(
Balance::balance_of(canister_account).unwrap(),
int_to_decimals(8_888_888 - 188_888 - 100_000)
Expand All @@ -206,7 +206,7 @@ mod test {
subaccount: Some(utils::random_subaccount().await),
};

let initial_balances = vec![(recipient_account.clone(), int_to_decimals(888))];
let initial_balances = vec![(recipient_account, int_to_decimals(888))];

Balance::init_balances(total_supply, initial_balances);

Expand Down
4 changes: 2 additions & 2 deletions src/app/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl Configuration {
}

pub fn get_decimals() -> u8 {
DECIMALS.with(|decimals| decimals.borrow().get().clone())
DECIMALS.with(|decimals| *decimals.borrow().get())
}

pub fn set_fee(fee: u64) {
Expand All @@ -92,7 +92,7 @@ impl Configuration {
}

pub fn get_fee() -> u64 {
FEE.with(|fee| fee.borrow().get().clone())
FEE.with(|fee| *fee.borrow().get())
}

pub fn set_logo(logo: String) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Inspect {
.unwrap_or(false)
{
return Err(ApproveError::BadFee {
expected_fee: default_fee.into(),
expected_fee: default_fee,
});
}
// check if expired
Expand Down Expand Up @@ -114,7 +114,7 @@ impl Inspect {
.unwrap_or(false)
{
return Err(TransferFromError::BadFee {
expected_fee: default_fee.into(),
expected_fee: default_fee,
});
}

Expand Down

0 comments on commit d9917e1

Please sign in to comment.