Skip to content

Commit

Permalink
Genesis config for pallet-ddc-payouts (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
khssnv authored Dec 20, 2023
1 parent 5febf20 commit ab4c93e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
12 changes: 11 additions & 1 deletion node/service/chain-specs/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
"mode": "Storage"
}
}
],
]
},
"ddcClusters": {
"clusters": [
Expand Down Expand Up @@ -233,6 +233,16 @@
]
]
]
},
"ddcPayouts": {
"authorisedCaller": "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
"debtorCustomers": [
[
"0x0000000000000000000000000000000000000001",
"5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
10000000000
]
]
}
}
}
Expand Down
1 change: 1 addition & 0 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ pub fn cere_dev_genesis(
nomination_pools: Default::default(),
ddc_clusters: Default::default(),
ddc_nodes: Default::default(),
ddc_payouts: Default::default(),
}
}

Expand Down
27 changes: 27 additions & 0 deletions pallets/ddc-payouts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,33 @@ pub mod pallet {
Finalized = 7,
}

#[pallet::genesis_config]
pub struct GenesisConfig<T: Config> {
pub authorised_caller: Option<T::AccountId>,
pub debtor_customers: Vec<(ClusterId, T::AccountId, u128)>,
}

#[cfg(feature = "std")]
impl<T: Config> Default for GenesisConfig<T> {
fn default() -> Self {
GenesisConfig {
authorised_caller: Default::default(),
debtor_customers: Default::default(),
}
}
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) {
AuthorisedCaller::<T>::set(self.authorised_caller.clone());

for (cluster_id, customer_id, debt) in &self.debtor_customers {
DebtorCustomers::<T>::insert(cluster_id, customer_id, debt);
}
}
}

#[pallet::call]
impl<T: Config> Pallet<T> {
#[pallet::weight(T::WeightInfo::set_authorised_caller())]
Expand Down

0 comments on commit ab4c93e

Please sign in to comment.