@@ -5,7 +5,7 @@ use authority_selection_inherents::{
55use derive_new:: new;
66use jsonrpsee:: core:: async_trait;
77use partner_chains_demo_runtime:: {
8- BlockAuthor , CrossChainPublic ,
8+ AccountId , BlockAuthor , CrossChainPublic ,
99 opaque:: { Block , SessionKeys } ,
1010} ;
1111use sc_consensus_aura:: { SlotDuration , find_pre_digest} ;
@@ -32,6 +32,9 @@ use sp_native_token_management::{
3232 NativeTokenManagementApi , NativeTokenManagementDataSource ,
3333 NativeTokenManagementInherentDataProvider as NativeTokenIDP ,
3434} ;
35+ use sp_partner_chains_bridge:: {
36+ TokenBridgeDataSource , TokenBridgeIDPRuntimeApi , TokenBridgeInherentDataProvider ,
37+ } ;
3538use sp_partner_chains_consensus_aura:: CurrentSlotProvider ;
3639use sp_runtime:: traits:: { Block as BlockT , Header , Zero } ;
3740use sp_session_validator_management:: SessionValidatorManagementApi ;
@@ -48,6 +51,7 @@ pub struct ProposalCIDP<T> {
4851 native_token_data_source : Arc < dyn NativeTokenManagementDataSource + Send + Sync > ,
4952 block_participation_data_source : Arc < dyn BlockParticipationDataSource + Send + Sync > ,
5053 governed_map_data_source : Arc < dyn GovernedMapDataSource + Send + Sync > ,
54+ bridge_data_source : Arc < dyn TokenBridgeDataSource < AccountId > + Send + Sync > ,
5155}
5256
5357#[ async_trait]
6569 T :: Api : BlockProductionLogApi < Block , CommitteeMember < CrossChainPublic , SessionKeys > > ,
6670 T :: Api : BlockParticipationApi < Block , BlockAuthor > ,
6771 T :: Api : GovernedMapIDPApi < Block > ,
72+ T :: Api : TokenBridgeIDPRuntimeApi < Block > ,
6873{
6974 type InherentDataProviders = (
7075 AuraIDP ,
7580 NativeTokenIDP ,
7681 BlockParticipationInherentDataProvider < BlockAuthor , DelegatorKey > ,
7782 GovernedMapInherentDataProvider ,
83+ TokenBridgeInherentDataProvider < AccountId > ,
7884 ) ;
7985
8086 async fn create_inherent_data_providers (
9096 native_token_data_source,
9197 block_participation_data_source,
9298 governed_map_data_source,
99+ bridge_data_source,
93100 } = self ;
94101 let CreateInherentDataConfig { mc_epoch_config, sc_slot_config, time_source } = config;
95102
@@ -145,6 +152,14 @@ where
145152 )
146153 . await ?;
147154
155+ let bridge = TokenBridgeInherentDataProvider :: new (
156+ client. as_ref ( ) ,
157+ parent_hash,
158+ mc_hash. mc_hash ( ) ,
159+ bridge_data_source. as_ref ( ) ,
160+ )
161+ . await ?;
162+
148163 Ok ( (
149164 slot,
150165 timestamp,
@@ -154,6 +169,7 @@ where
154169 native_token,
155170 payouts,
156171 governed_map,
172+ bridge,
157173 ) )
158174 }
159175}
@@ -167,6 +183,7 @@ pub struct VerifierCIDP<T> {
167183 native_token_data_source : Arc < dyn NativeTokenManagementDataSource + Send + Sync > ,
168184 block_participation_data_source : Arc < dyn BlockParticipationDataSource + Send + Sync > ,
169185 governed_map_data_source : Arc < dyn GovernedMapDataSource + Send + Sync > ,
186+ bridge_data_source : Arc < dyn TokenBridgeDataSource < AccountId > + Send + Sync > ,
170187}
171188
172189impl < T : Send + Sync > CurrentSlotProvider for VerifierCIDP < T > {
@@ -189,6 +206,7 @@ where
189206 T :: Api : BlockProductionLogApi < Block , CommitteeMember < CrossChainPublic , SessionKeys > > ,
190207 T :: Api : BlockParticipationApi < Block , BlockAuthor > ,
191208 T :: Api : GovernedMapIDPApi < Block > ,
209+ T :: Api : TokenBridgeIDPRuntimeApi < Block > ,
192210{
193211 type InherentDataProviders = (
194212 TimestampIDP ,
@@ -197,6 +215,7 @@ where
197215 NativeTokenIDP ,
198216 BlockParticipationInherentDataProvider < BlockAuthor , DelegatorKey > ,
199217 GovernedMapInherentDataProvider ,
218+ TokenBridgeInherentDataProvider < AccountId > ,
200219 ) ;
201220
202221 async fn create_inherent_data_providers (
@@ -212,6 +231,7 @@ where
212231 native_token_data_source,
213232 block_participation_data_source,
214233 governed_map_data_source,
234+ bridge_data_source,
215235 } = self ;
216236 let CreateInherentDataConfig { mc_epoch_config, sc_slot_config, time_source, .. } = config;
217237
@@ -264,19 +284,28 @@ where
264284 let governed_map = GovernedMapInherentDataProvider :: new (
265285 client. as_ref ( ) ,
266286 parent_hash,
267- mc_hash,
287+ mc_hash. clone ( ) ,
268288 mc_state_reference. previous_mc_hash ( ) ,
269289 governed_map_data_source. as_ref ( ) ,
270290 )
271291 . await ?;
272292
293+ let bridge = TokenBridgeInherentDataProvider :: new (
294+ client. as_ref ( ) ,
295+ parent_hash,
296+ mc_hash,
297+ bridge_data_source. as_ref ( ) ,
298+ )
299+ . await ?;
300+
273301 Ok ( (
274302 timestamp,
275303 ariadne_data_provider,
276304 block_producer_id_provider,
277305 native_token,
278306 payouts,
279307 governed_map,
308+ bridge,
280309 ) )
281310 }
282311}
0 commit comments