Skip to content

Commit

Permalink
chore: fix package info and clippy
Browse files Browse the repository at this point in the history
Signed-off-by: Minh Huy Tran <[email protected]>
  • Loading branch information
NhoxxKienn committed Apr 23, 2024
1 parent 38b3ecf commit 0b969e0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 50 deletions.
5 changes: 2 additions & 3 deletions node/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 4 additions & 31 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[workspace.package]
authors = ["Substrate DevHub <https://github.com/substrate-developer-hub>"]
authors = ["PolyCrypt GmbH <[email protected]>"]
edition = "2021"
repository = "https://github.com/substrate-developer-hub/substrate-node-template/"
repository = "https://github.com/perun-network/perun-polkadot-node"
license = "MIT-0"
homepage = "https://substrate.io"
homepage = "https://perun.network/"

[workspace]
members = [
Expand All @@ -15,31 +15,4 @@ resolver = "2"
[profile.release]
panic = "unwind"

[workspace.lints.rust]
suspicious_double_ref_op = { level = "allow", priority = 2 }

[workspace.lints.clippy]
all = { level = "allow", priority = 0 }
correctness = { level = "warn", priority = 1 }
complexity = { level = "warn", priority = 1 }
if-same-then-else = { level = "allow", priority = 2 }
zero-prefixed-literal = { level = "allow", priority = 2 } # 00_1000_000
type_complexity = { level = "allow", priority = 2 } # raison d'etre
nonminimal-bool = { level = "allow", priority = 2 } # maybe
borrowed-box = { level = "allow", priority = 2 } # Reasonable to fix this one
too-many-arguments = { level = "allow", priority = 2 } # (Turning this on would lead to)
needless-lifetimes = { level = "allow", priority = 2 } # generated code
unnecessary_cast = { level = "allow", priority = 2 } # Types may change
identity-op = { level = "allow", priority = 2 } # One case where we do 0 +
useless_conversion = { level = "allow", priority = 2 } # Types may change
unit_arg = { level = "allow", priority = 2 } # stylistic
option-map-unit-fn = { level = "allow", priority = 2 } # stylistic
bind_instead_of_map = { level = "allow", priority = 2 } # stylistic
erasing_op = { level = "allow", priority = 2 } # E.g. 0 * DOLLARS
eq_op = { level = "allow", priority = 2 } # In tests we test equality.
while_immutable_condition = { level = "allow", priority = 2 } # false positives
needless_option_as_deref = { level = "allow", priority = 2 } # false positives
derivable_impls = { level = "allow", priority = 2 } # false positives
stable_sort_primitive = { level = "allow", priority = 2 } # prefer stable sort
extra-unused-type-parameters = { level = "allow", priority = 2 } # stylistic
default_constructed_unit_structs = { level = "allow", priority = 2 } # stylistic
[workspace.lints.rust]
2 changes: 1 addition & 1 deletion node/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "node-template"
description = "A solochain node template built with Substrate, part of Polkadot Sdk."
version = "0.0.0"
version = "0.5.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion node/pallets/pallet-perun
2 changes: 1 addition & 1 deletion node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "node-template-runtime"
description = "A solochain runtime template built with Substrate, part of Polkadot Sdk."
version = "0.0.0"
version = "0.5.0"
license = "MIT-0"
authors.workspace = true
homepage.workspace = true
Expand Down
20 changes: 9 additions & 11 deletions node/runtime/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ pub fn valid_transition<T: Config>(
let actor = from_data.next_actor;
let signer_u8 = u8::try_from(signer).unwrap();
let num_parts = u8::try_from(NUM_PARTS).unwrap();
if actor != signer_u8 {
return false;
} else if (actor + 1) % num_parts != to_data.next_actor {
if actor != signer_u8 || (actor + 1) % num_parts != to_data.next_actor {
return false;
}

Expand All @@ -71,10 +69,10 @@ pub fn valid_transition<T: Config>(
require!(to.finalized == is_final);

// Check balances.
let actor_usize = usize::try_from(actor).unwrap();
let actor_usize = usize::from(actor);
let expected_balances = compute_next_balances::<T>(&from.balances, actor_usize, is_final, has_winner, winner);
require!(to.balances == expected_balances);
return true;
true
}

fn compute_next_balances<T: Config>(balances: &[BalanceOf<T>], actor: usize, is_final: bool, has_winner: bool, winner: usize) -> Vec::<BalanceOf::<T>> {
Expand All @@ -84,9 +82,9 @@ fn compute_next_balances<T: Config>(balances: &[BalanceOf<T>], actor: usize, is_
let mut next_bals = Vec::<BalanceOf::<T>>::with_capacity(num_parts);
for p in 0..num_parts {
if is_final && !has_winner {
next_bals.push(draw_bal.clone());
next_bals.push(draw_bal);
} else if has_winner && winner == p || actor == p {
next_bals.push(total.clone());
next_bals.push(total);
} else {
next_bals.push(BalanceOf::<T>::default());
}
Expand All @@ -99,11 +97,11 @@ fn accumulate_balances<T: Config>(balances: &[BalanceOf<T>]) -> BalanceOf<T> {
for b in balances.iter() {
acc += *b;
}
return acc;
acc
}

fn valid_value(v: u8) -> bool {
return v == FIELD_EMPTY || v == FIELD_PLAYER1 || v == FIELD_PLAYER2;
v == FIELD_EMPTY || v == FIELD_PLAYER1 || v == FIELD_PLAYER2
}

fn check_final(data: &TicTacToeAppData) -> (bool, bool, usize) {
Expand Down Expand Up @@ -139,7 +137,7 @@ fn check_final(data: &TicTacToeAppData) -> (bool, bool, usize) {
return (false, false, 0);
}
}
return (true, false, 0);
(true, false, 0)
}

fn same_value(data: &TicTacToeAppData, v: &[usize; 3]) -> (bool, u8) {
Expand All @@ -149,5 +147,5 @@ fn same_value(data: &TicTacToeAppData, v: &[usize; 3]) -> (bool, u8) {
return (false, 0);
}
}
return (true, first);
(true, first)
}
4 changes: 2 additions & 2 deletions node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ impl AppRegistry<Runtime> for DefaultAppRegistry {
return true;
}
frame_support::runtime_print!("PerunPallet:ValidTransition: different app");
return false;
false
}

fn transition_weight(_params: &ParamsOf<Runtime>) -> Weight {
return Weight::from_all(0);
Weight::from_all(0)
}
}

Expand Down

0 comments on commit 0b969e0

Please sign in to comment.