Skip to content

Commit

Permalink
Add #[serde(skip)] to phantom definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
ebma committed Dec 4, 2024
1 parent 8cc27db commit aaf57c7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 87 deletions.
1 change: 1 addition & 0 deletions pallets/nomination/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub mod pallet {
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub is_nomination_enabled: bool,
#[serde(skip)]
pub _phantom: sp_std::marker::PhantomData<T>,
}

Expand Down
7 changes: 4 additions & 3 deletions pallets/oracle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ pub mod pallet {
pub struct GenesisConfig<T: Config> {
pub max_delay: u32,
pub oracle_keys: Vec<OracleKey>,
#[serde(skip)]
pub _phantom: sp_std::marker::PhantomData<T>,
}

Expand Down Expand Up @@ -247,9 +248,9 @@ impl<T: Config> Pallet<T> {
}

let current_status_is_online = Self::is_oracle_online();
let new_status_is_online = !oracle_keys.is_empty() &&
updated_items_len > 0 &&
updated_items_len == oracle_keys.len();
let new_status_is_online = !oracle_keys.is_empty()
&& updated_items_len > 0
&& updated_items_len == oracle_keys.len();

if current_status_is_online != new_status_is_online {
if new_status_is_online {
Expand Down
5 changes: 3 additions & 2 deletions pallets/security/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub mod pallet {
#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub initial_status: StatusCode,
#[serde(skip)]
pub _phantom: sp_std::marker::PhantomData<T>,
}

Expand Down Expand Up @@ -212,8 +213,8 @@ impl<T: Config> Pallet<T> {

/// Checks if the Parachain has a OracleOffline Error state
pub fn is_parachain_error_oracle_offline() -> bool {
Self::parachain_status() == StatusCode::Error &&
<Errors<T>>::get().contains(&ErrorCode::OracleOffline)
Self::parachain_status() == StatusCode::Error
&& <Errors<T>>::get().contains(&ErrorCode::OracleOffline)
}

/// Sets the given `StatusCode`.
Expand Down
9 changes: 5 additions & 4 deletions pallets/stellar-relay/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ pub mod pallet {
pub validators: Vec<ValidatorOf<T>>,
pub organizations: Vec<OrganizationOf<T>>,
pub enactment_block_height: BlockNumberFor<T>,
pub phantom: PhantomData<T>,
#[serde(skip)]
pub _phantom: PhantomData<T>,
}

impl<T: Config> Default for GenesisConfig<T> {
Expand Down Expand Up @@ -381,7 +382,7 @@ pub mod pallet {
validators,
organizations,
enactment_block_height,
phantom: Default::default(),
_phantom: Default::default(),
}
}
}
Expand Down Expand Up @@ -512,8 +513,8 @@ pub mod pallet {

// update only when new organization or validators not equal to old organization or
// validators
if new_organization_vec != current_organizations ||
new_validator_vec != current_validators
if new_organization_vec != current_organizations
|| new_validator_vec != current_validators
{
OldValidators::<T>::put(current_validators);
OldOrganizations::<T>::put(current_organizations);
Expand Down
2 changes: 1 addition & 1 deletion pallets/stellar-relay/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl ExtBuilder {
validators,
organizations,
enactment_block_height: 0,
phantom: Default::default(),
_phantom: Default::default(),
}
.assimilate_storage(&mut storage)
.unwrap();
Expand Down
79 changes: 2 additions & 77 deletions testchain/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,82 +368,7 @@ fn genesis(
coin_infos_map: vec![],
},
};
//serde_json::to_value(genesis_config).expect("Serialization of genesis config should work")
serde_json::json!({
"sudo": {
"key": genesis_config.sudo.key,
},
"balances": {
"balances": genesis_config.balances.balances,
},
"aura": {
"authorities": genesis_config.aura.authorities,
},
"grandpa": {
"authorities": genesis_config.grandpa.authorities,
},
"tokens": {
"balances": genesis_config.tokens.balances,
},
"issue": {
"issuePeriod": genesis_config.issue.issue_period,
"issueMinimumTransferAmount": genesis_config.issue.issue_minimum_transfer_amount,
"limitVolumeAmount": genesis_config.issue.limit_volume_amount,
"limitVolumeCurrencyId": genesis_config.issue.limit_volume_currency_id,
"currentVolumeAmount": genesis_config.issue.current_volume_amount,
"intervalLength": genesis_config.issue.interval_length,
"lastIntervalIndex": genesis_config.issue.last_interval_index,
},
"redeem": {
"redeemPeriod": genesis_config.redeem.redeem_period,
"redeemMinimumTransferAmount": genesis_config.redeem.redeem_minimum_transfer_amount,
"limitVolumeAmount": genesis_config.redeem.limit_volume_amount,
"limitVolumeCurrencyId": genesis_config.redeem.limit_volume_currency_id,
"currentVolumeAmount": genesis_config.redeem.current_volume_amount,
"intervalLength": genesis_config.redeem.interval_length,
"lastIntervalIndex": genesis_config.redeem.last_interval_index,
},
"replace": {
"replacePeriod": genesis_config.replace.replace_period,
"replaceMinimumTransferAmount": genesis_config.replace.replace_minimum_transfer_amount,
},
"security": {
"initialStatus": genesis_config.security.initial_status,
},
"oracle": {
"maxDelay": genesis_config.oracle.max_delay,
"oracleKeys": genesis_config.oracle.oracle_keys,
},
"vaultRegistry": {
"minimumCollateralVault": genesis_config.vault_registry.minimum_collateral_vault,
"punishmentDelay": genesis_config.vault_registry.punishment_delay,
"secureCollateralThreshold": genesis_config.vault_registry.secure_collateral_threshold,
"premiumRedeemThreshold": genesis_config.vault_registry.premium_redeem_threshold,
"liquidationCollateralThreshold": genesis_config.vault_registry.liquidation_collateral_threshold,
"systemCollateralCeiling": genesis_config.vault_registry.system_collateral_ceiling,
},
"stellarRelay": {
"organizations": genesis_config.stellar_relay.organizations,
"validators": genesis_config.stellar_relay.validators
},
"fee": {
"issueFee": genesis_config.fee.issue_fee,
"issueGriefingCollateral": genesis_config.fee.issue_griefing_collateral,
"redeemFee": genesis_config.fee.redeem_fee,
"premiumRedeemFee": genesis_config.fee.premium_redeem_fee,
"punishmentFee": genesis_config.fee.punishment_fee,
"replaceGriefingCollateral": genesis_config.fee.replace_griefing_collateral,
},
"nomination": {
"isNominationEnabled": genesis_config.nomination.is_nomination_enabled,
},
"diaOracleModule": {
"authorizedAccounts": genesis_config.dia_oracle_module.authorized_accounts,
"supportedCurrencies": genesis_config.dia_oracle_module.supported_currencies,
"batchingApi": genesis_config.dia_oracle_module.batching_api,
"coinInfosMap": genesis_config.dia_oracle_module.coin_infos_map,
}
})
serde_json::to_value(genesis_config).expect("Serialization of genesis config should work")
}

fn create_stellar_testnet_config() -> StellarRelayConfig {
Expand Down Expand Up @@ -484,6 +409,6 @@ fn create_stellar_testnet_config() -> StellarRelayConfig {
validators,
organizations,
enactment_block_height: 0,
phantom: Default::default(),
_phantom: Default::default(),
}
}

0 comments on commit aaf57c7

Please sign in to comment.