@ -33,7 +33,11 @@ use super::ChainSigner;
#[ async_trait ]
#[ async_trait ]
pub trait TryFromWithMetrics < T > : Sized {
pub trait TryFromWithMetrics < T > : Sized {
/// Try to convert the chain configuration into the type
/// Try to convert the chain configuration into the type
async fn try_from_with_metrics ( conf : & ChainConf , metrics : & CoreMetrics ) -> Result < Self > ;
async fn try_from_with_metrics (
conf : & ChainConf ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Self > ;
}
}
/// A chain setup is a domain ID, an address on that chain (where the mailbox is
/// A chain setup is a domain ID, an address on that chain (where the mailbox is
@ -72,22 +76,38 @@ pub type MerkleTreeHookIndexer = Arc<dyn SequenceAwareIndexer<MerkleTreeInsertio
#[ async_trait ]
#[ async_trait ]
impl TryFromWithMetrics < ChainConf > for MessageIndexer {
impl TryFromWithMetrics < ChainConf > for MessageIndexer {
async fn try_from_with_metrics ( conf : & ChainConf , metrics : & CoreMetrics ) -> Result < Self > {
async fn try_from_with_metrics (
conf . build_message_indexer ( metrics ) . await . map ( Into ::into )
conf : & ChainConf ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Self > {
conf . build_message_indexer ( metrics , advanced_log_meta )
. await
. map ( Into ::into )
}
}
}
}
#[ async_trait ]
#[ async_trait ]
impl TryFromWithMetrics < ChainConf > for DeliveryIndexer {
impl TryFromWithMetrics < ChainConf > for DeliveryIndexer {
async fn try_from_with_metrics ( conf : & ChainConf , metrics : & CoreMetrics ) -> Result < Self > {
async fn try_from_with_metrics (
conf . build_delivery_indexer ( metrics ) . await . map ( Into ::into )
conf : & ChainConf ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Self > {
conf . build_delivery_indexer ( metrics , advanced_log_meta )
. await
. map ( Into ::into )
}
}
}
}
#[ async_trait ]
#[ async_trait ]
impl TryFromWithMetrics < ChainConf > for IgpIndexer {
impl TryFromWithMetrics < ChainConf > for IgpIndexer {
async fn try_from_with_metrics ( conf : & ChainConf , metrics : & CoreMetrics ) -> Result < Self > {
async fn try_from_with_metrics (
conf . build_interchain_gas_payment_indexer ( metrics )
conf : & ChainConf ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Self > {
conf . build_interchain_gas_payment_indexer ( metrics , advanced_log_meta )
. await
. await
. map ( Into ::into )
. map ( Into ::into )
}
}
@ -95,8 +115,12 @@ impl TryFromWithMetrics<ChainConf> for IgpIndexer {
#[ async_trait ]
#[ async_trait ]
impl TryFromWithMetrics < ChainConf > for MerkleTreeHookIndexer {
impl TryFromWithMetrics < ChainConf > for MerkleTreeHookIndexer {
async fn try_from_with_metrics ( conf : & ChainConf , metrics : & CoreMetrics ) -> Result < Self > {
async fn try_from_with_metrics (
conf . build_merkle_tree_hook_indexer ( metrics )
conf : & ChainConf ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Self > {
conf . build_merkle_tree_hook_indexer ( metrics , advanced_log_meta )
. await
. await
. map ( Into ::into )
. map ( Into ::into )
}
}
@ -266,6 +290,7 @@ impl ChainConf {
pub async fn build_message_indexer (
pub async fn build_message_indexer (
& self ,
& self ,
metrics : & CoreMetrics ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Box < dyn SequenceAwareIndexer < HyperlaneMessage > > > {
) -> Result < Box < dyn SequenceAwareIndexer < HyperlaneMessage > > > {
let ctx = "Building delivery indexer" ;
let ctx = "Building delivery indexer" ;
let locator = self . locator ( self . addresses . mailbox ) ;
let locator = self . locator ( self . addresses . mailbox ) ;
@ -284,7 +309,11 @@ impl ChainConf {
}
}
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Sealevel ( conf ) = > {
ChainConnectionConf ::Sealevel ( conf ) = > {
let indexer = Box ::new ( h_sealevel ::SealevelMailboxIndexer ::new ( conf , locator ) ? ) ;
let indexer = Box ::new ( h_sealevel ::SealevelMailboxIndexer ::new (
conf ,
locator ,
advanced_log_meta ,
) ? ) ;
Ok ( indexer as Box < dyn SequenceAwareIndexer < HyperlaneMessage > > )
Ok ( indexer as Box < dyn SequenceAwareIndexer < HyperlaneMessage > > )
}
}
ChainConnectionConf ::Cosmos ( conf ) = > {
ChainConnectionConf ::Cosmos ( conf ) = > {
@ -306,6 +335,7 @@ impl ChainConf {
pub async fn build_delivery_indexer (
pub async fn build_delivery_indexer (
& self ,
& self ,
metrics : & CoreMetrics ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Box < dyn SequenceAwareIndexer < H256 > > > {
) -> Result < Box < dyn SequenceAwareIndexer < H256 > > > {
let ctx = "Building delivery indexer" ;
let ctx = "Building delivery indexer" ;
let locator = self . locator ( self . addresses . mailbox ) ;
let locator = self . locator ( self . addresses . mailbox ) ;
@ -324,7 +354,11 @@ impl ChainConf {
}
}
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Sealevel ( conf ) = > {
ChainConnectionConf ::Sealevel ( conf ) = > {
let indexer = Box ::new ( h_sealevel ::SealevelMailboxIndexer ::new ( conf , locator ) ? ) ;
let indexer = Box ::new ( h_sealevel ::SealevelMailboxIndexer ::new (
conf ,
locator ,
advanced_log_meta ,
) ? ) ;
Ok ( indexer as Box < dyn SequenceAwareIndexer < H256 > > )
Ok ( indexer as Box < dyn SequenceAwareIndexer < H256 > > )
}
}
ChainConnectionConf ::Cosmos ( conf ) = > {
ChainConnectionConf ::Cosmos ( conf ) = > {
@ -385,6 +419,7 @@ impl ChainConf {
pub async fn build_interchain_gas_payment_indexer (
pub async fn build_interchain_gas_payment_indexer (
& self ,
& self ,
metrics : & CoreMetrics ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Box < dyn SequenceAwareIndexer < InterchainGasPayment > > > {
) -> Result < Box < dyn SequenceAwareIndexer < InterchainGasPayment > > > {
let ctx = "Building IGP indexer" ;
let ctx = "Building IGP indexer" ;
let locator = self . locator ( self . addresses . interchain_gas_paymaster ) ;
let locator = self . locator ( self . addresses . interchain_gas_paymaster ) ;
@ -407,7 +442,12 @@ impl ChainConf {
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Sealevel ( conf ) = > {
ChainConnectionConf ::Sealevel ( conf ) = > {
let indexer = Box ::new (
let indexer = Box ::new (
h_sealevel ::SealevelInterchainGasPaymasterIndexer ::new ( conf , locator ) . await ? ,
h_sealevel ::SealevelInterchainGasPaymasterIndexer ::new (
conf ,
locator ,
advanced_log_meta ,
)
. await ? ,
) ;
) ;
Ok ( indexer as Box < dyn SequenceAwareIndexer < InterchainGasPayment > > )
Ok ( indexer as Box < dyn SequenceAwareIndexer < InterchainGasPayment > > )
}
}
@ -428,6 +468,7 @@ impl ChainConf {
pub async fn build_merkle_tree_hook_indexer (
pub async fn build_merkle_tree_hook_indexer (
& self ,
& self ,
metrics : & CoreMetrics ,
metrics : & CoreMetrics ,
advanced_log_meta : bool ,
) -> Result < Box < dyn SequenceAwareIndexer < MerkleTreeInsertion > > > {
) -> Result < Box < dyn SequenceAwareIndexer < MerkleTreeInsertion > > > {
let ctx = "Building merkle tree hook indexer" ;
let ctx = "Building merkle tree hook indexer" ;
let locator = self . locator ( self . addresses . merkle_tree_hook ) ;
let locator = self . locator ( self . addresses . merkle_tree_hook ) ;
@ -446,8 +487,11 @@ impl ChainConf {
}
}
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Fuel ( _ ) = > todo! ( ) ,
ChainConnectionConf ::Sealevel ( conf ) = > {
ChainConnectionConf ::Sealevel ( conf ) = > {
let mailbox_indexer =
let mailbox_indexer = Box ::new ( h_sealevel ::SealevelMailboxIndexer ::new (
Box ::new ( h_sealevel ::SealevelMailboxIndexer ::new ( conf , locator ) ? ) ;
conf ,
locator ,
advanced_log_meta ,
) ? ) ;
let indexer = Box ::new ( h_sealevel ::SealevelMerkleTreeHookIndexer ::new (
let indexer = Box ::new ( h_sealevel ::SealevelMerkleTreeHookIndexer ::new (
* mailbox_indexer ,
* mailbox_indexer ,
) ) ;
) ) ;