mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-25 23:23:11 +00:00
feat: add nursery clippy lints
This commit is contained in:
@@ -97,7 +97,7 @@ impl TryFrom<&Data> for PoolDefinition {
|
||||
type Error = std::io::Error;
|
||||
|
||||
fn try_from(data: &Data) -> Result<Self, Self::Error> {
|
||||
PoolDefinition::try_from_slice(data.as_ref())
|
||||
Self::try_from_slice(data.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ impl From<&PoolDefinition> for Data {
|
||||
BorshSerialize::serialize(definition, &mut data)
|
||||
.expect("Serialization to Vec should not fail");
|
||||
|
||||
Data::try_from(data).expect("Token definition encoded data should fit into Data")
|
||||
Self::try_from(data).expect("Token definition encoded data should fit into Data")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -156,7 +156,7 @@ pub fn add_liquidity(
|
||||
pool_definition_lp_auth.is_authorized = true;
|
||||
let call_token_lp = ChainedCall::new(
|
||||
token_program_id,
|
||||
vec![pool_definition_lp_auth.clone(), user_holding_lp.clone()],
|
||||
vec![pool_definition_lp_auth, user_holding_lp.clone()],
|
||||
&token_core::Instruction::Mint {
|
||||
amount_to_mint: delta_lp,
|
||||
},
|
||||
|
||||
@@ -134,7 +134,7 @@ pub fn new_definition(
|
||||
|
||||
let call_token_lp = ChainedCall::new(
|
||||
token_program_id,
|
||||
vec![pool_lp_auth.clone(), user_holding_lp.clone()],
|
||||
vec![pool_lp_auth, user_holding_lp.clone()],
|
||||
&instruction,
|
||||
)
|
||||
.with_pda_seeds(vec![compute_liquidity_token_pda_seed(pool.account_id)]);
|
||||
@@ -151,5 +151,5 @@ pub fn new_definition(
|
||||
AccountPostState::new(user_holding_lp.account),
|
||||
];
|
||||
|
||||
(post_states.clone(), chained_calls)
|
||||
(post_states, chained_calls)
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ pub fn remove_liquidity(
|
||||
reserve_a: pool_def_data.reserve_a - withdraw_amount_a,
|
||||
reserve_b: pool_def_data.reserve_b - withdraw_amount_b,
|
||||
active,
|
||||
..pool_def_data.clone()
|
||||
..pool_def_data
|
||||
};
|
||||
|
||||
pool_post.data = Data::from(&pool_post_definition);
|
||||
|
||||
@@ -107,7 +107,7 @@ impl BalanceForTests {
|
||||
|
||||
fn lp_supply_init() -> u128 {
|
||||
// sqrt(vault_a_reserve_init * vault_b_reserve_init) = sqrt(1000 * 500) = 707
|
||||
(BalanceForTests::vault_a_reserve_init() * BalanceForTests::vault_b_reserve_init()).isqrt()
|
||||
(Self::vault_a_reserve_init() * Self::vault_b_reserve_init()).isqrt()
|
||||
}
|
||||
|
||||
fn vault_a_swap_test_1() -> u128 {
|
||||
@@ -365,7 +365,7 @@ impl IdForTests {
|
||||
}
|
||||
|
||||
fn token_lp_definition_id() -> AccountId {
|
||||
compute_liquidity_token_pda(AMM_PROGRAM_ID, IdForTests::pool_definition_id())
|
||||
compute_liquidity_token_pda(AMM_PROGRAM_ID, Self::pool_definition_id())
|
||||
}
|
||||
|
||||
fn user_token_a_id() -> AccountId {
|
||||
@@ -383,24 +383,24 @@ impl IdForTests {
|
||||
fn pool_definition_id() -> AccountId {
|
||||
compute_pool_pda(
|
||||
AMM_PROGRAM_ID,
|
||||
IdForTests::token_a_definition_id(),
|
||||
IdForTests::token_b_definition_id(),
|
||||
Self::token_a_definition_id(),
|
||||
Self::token_b_definition_id(),
|
||||
)
|
||||
}
|
||||
|
||||
fn vault_a_id() -> AccountId {
|
||||
compute_vault_pda(
|
||||
AMM_PROGRAM_ID,
|
||||
IdForTests::pool_definition_id(),
|
||||
IdForTests::token_a_definition_id(),
|
||||
Self::pool_definition_id(),
|
||||
Self::token_a_definition_id(),
|
||||
)
|
||||
}
|
||||
|
||||
fn vault_b_id() -> AccountId {
|
||||
compute_vault_pda(
|
||||
AMM_PROGRAM_ID,
|
||||
IdForTests::pool_definition_id(),
|
||||
IdForTests::token_b_definition_id(),
|
||||
Self::pool_definition_id(),
|
||||
Self::token_b_definition_id(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ impl TryFrom<&Data> for TokenDefinition {
|
||||
type Error = std::io::Error;
|
||||
|
||||
fn try_from(data: &Data) -> Result<Self, Self::Error> {
|
||||
TokenDefinition::try_from_slice(data.as_ref())
|
||||
Self::try_from_slice(data.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ impl From<&TokenDefinition> for Data {
|
||||
BorshSerialize::serialize(definition, &mut data)
|
||||
.expect("Serialization to Vec should not fail");
|
||||
|
||||
Data::try_from(data).expect("Token definition encoded data should fit into Data")
|
||||
Self::try_from(data).expect("Token definition encoded data should fit into Data")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,17 +128,17 @@ pub enum TokenHolding {
|
||||
|
||||
impl TokenHolding {
|
||||
#[must_use]
|
||||
pub fn zeroized_clone_from(other: &Self) -> Self {
|
||||
pub const fn zeroized_clone_from(other: &Self) -> Self {
|
||||
match other {
|
||||
TokenHolding::Fungible { definition_id, .. } => TokenHolding::Fungible {
|
||||
Self::Fungible { definition_id, .. } => Self::Fungible {
|
||||
definition_id: *definition_id,
|
||||
balance: 0,
|
||||
},
|
||||
TokenHolding::NftMaster { definition_id, .. } => TokenHolding::NftMaster {
|
||||
Self::NftMaster { definition_id, .. } => Self::NftMaster {
|
||||
definition_id: *definition_id,
|
||||
print_balance: 0,
|
||||
},
|
||||
TokenHolding::NftPrintedCopy { definition_id, .. } => TokenHolding::NftPrintedCopy {
|
||||
Self::NftPrintedCopy { definition_id, .. } => Self::NftPrintedCopy {
|
||||
definition_id: *definition_id,
|
||||
owned: false,
|
||||
},
|
||||
@@ -146,16 +146,16 @@ impl TokenHolding {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn zeroized_from_definition(
|
||||
pub const fn zeroized_from_definition(
|
||||
definition_id: AccountId,
|
||||
definition: &TokenDefinition,
|
||||
) -> Self {
|
||||
match definition {
|
||||
TokenDefinition::Fungible { .. } => TokenHolding::Fungible {
|
||||
TokenDefinition::Fungible { .. } => Self::Fungible {
|
||||
definition_id,
|
||||
balance: 0,
|
||||
},
|
||||
TokenDefinition::NonFungible { .. } => TokenHolding::NftPrintedCopy {
|
||||
TokenDefinition::NonFungible { .. } => Self::NftPrintedCopy {
|
||||
definition_id,
|
||||
owned: false,
|
||||
},
|
||||
@@ -163,11 +163,11 @@ impl TokenHolding {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn definition_id(&self) -> AccountId {
|
||||
pub const fn definition_id(&self) -> AccountId {
|
||||
match self {
|
||||
TokenHolding::Fungible { definition_id, .. }
|
||||
| TokenHolding::NftMaster { definition_id, .. }
|
||||
| TokenHolding::NftPrintedCopy { definition_id, .. } => *definition_id,
|
||||
Self::Fungible { definition_id, .. }
|
||||
| Self::NftMaster { definition_id, .. }
|
||||
| Self::NftPrintedCopy { definition_id, .. } => *definition_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,7 +176,7 @@ impl TryFrom<&Data> for TokenHolding {
|
||||
type Error = std::io::Error;
|
||||
|
||||
fn try_from(data: &Data) -> Result<Self, Self::Error> {
|
||||
TokenHolding::try_from_slice(data.as_ref())
|
||||
Self::try_from_slice(data.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ impl From<&TokenHolding> for Data {
|
||||
BorshSerialize::serialize(holding, &mut data)
|
||||
.expect("Serialization to Vec should not fail");
|
||||
|
||||
Data::try_from(data).expect("Token holding encoded data should fit into Data")
|
||||
Self::try_from(data).expect("Token holding encoded data should fit into Data")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ impl TryFrom<&Data> for TokenMetadata {
|
||||
type Error = std::io::Error;
|
||||
|
||||
fn try_from(data: &Data) -> Result<Self, Self::Error> {
|
||||
TokenMetadata::try_from_slice(data.as_ref())
|
||||
Self::try_from_slice(data.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,6 +239,6 @@ impl From<&TokenMetadata> for Data {
|
||||
BorshSerialize::serialize(metadata, &mut data)
|
||||
.expect("Serialization to Vec should not fail");
|
||||
|
||||
Data::try_from(data).expect("Token metadata encoded data should fit into Data")
|
||||
Self::try_from(data).expect("Token metadata encoded data should fit into Data")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user