|
|
@ -12,7 +12,7 @@ use tracing::{info, instrument}; |
|
|
|
use hyperlane_core::{ |
|
|
|
use hyperlane_core::{ |
|
|
|
config::StrOrIntParseError, ChainCommunicationError, ChainResult, ContractLocator, |
|
|
|
config::StrOrIntParseError, ChainCommunicationError, ChainResult, ContractLocator, |
|
|
|
HyperlaneChain, HyperlaneContract, HyperlaneDomain, HyperlaneProvider, Indexed, Indexer, |
|
|
|
HyperlaneChain, HyperlaneContract, HyperlaneDomain, HyperlaneProvider, Indexed, Indexer, |
|
|
|
InterchainGasPaymaster, InterchainGasPayment, LogMeta, SequenceAwareIndexer, H256, U256, |
|
|
|
InterchainGasPaymaster, InterchainGasPayment, LogMeta, SequenceAwareIndexer, H256, H512, U256, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
use crate::account::{search_accounts_by_discriminator, search_and_validate_account}; |
|
|
|
use crate::account::{search_accounts_by_discriminator, search_and_validate_account}; |
|
|
@ -91,7 +91,7 @@ impl InterchainGasPaymaster for SealevelInterchainGasPaymaster {} |
|
|
|
pub struct SealevelInterchainGasPaymasterIndexer { |
|
|
|
pub struct SealevelInterchainGasPaymasterIndexer { |
|
|
|
rpc_client: SealevelRpcClient, |
|
|
|
rpc_client: SealevelRpcClient, |
|
|
|
igp: SealevelInterchainGasPaymaster, |
|
|
|
igp: SealevelInterchainGasPaymaster, |
|
|
|
log_meta_composer: LogMetaComposer, |
|
|
|
_log_meta_composer: LogMetaComposer, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// IGP payment data on Sealevel
|
|
|
|
/// IGP payment data on Sealevel
|
|
|
@ -122,7 +122,7 @@ impl SealevelInterchainGasPaymasterIndexer { |
|
|
|
Ok(Self { |
|
|
|
Ok(Self { |
|
|
|
rpc_client, |
|
|
|
rpc_client, |
|
|
|
igp, |
|
|
|
igp, |
|
|
|
log_meta_composer, |
|
|
|
_log_meta_composer: log_meta_composer, |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -168,13 +168,24 @@ impl SealevelInterchainGasPaymasterIndexer { |
|
|
|
gas_amount: gas_payment_account.gas_amount.into(), |
|
|
|
gas_amount: gas_payment_account.gas_amount.into(), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
let log_meta = self |
|
|
|
// let log_meta = self
|
|
|
|
.interchain_payment_log_meta( |
|
|
|
// .interchain_payment_log_meta(
|
|
|
|
U256::from(sequence_number), |
|
|
|
// U256::from(sequence_number),
|
|
|
|
&valid_payment_pda_pubkey, |
|
|
|
// &valid_payment_pda_pubkey,
|
|
|
|
&gas_payment_account.slot, |
|
|
|
// &gas_payment_account.slot,
|
|
|
|
) |
|
|
|
// )
|
|
|
|
.await?; |
|
|
|
// .await?;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let log_meta = LogMeta { |
|
|
|
|
|
|
|
address: self.igp.program_id.to_bytes().into(), |
|
|
|
|
|
|
|
block_number: gas_payment_account.slot, |
|
|
|
|
|
|
|
// TODO: get these when building out scraper support.
|
|
|
|
|
|
|
|
// It's inconvenient to get these :|
|
|
|
|
|
|
|
|
block_hash: H256::zero(), |
|
|
|
|
|
|
|
transaction_id: H512::zero(), |
|
|
|
|
|
|
|
transaction_index: 0, |
|
|
|
|
|
|
|
log_index: sequence_number.into(), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
Ok(SealevelGasPayment::new( |
|
|
|
Ok(SealevelGasPayment::new( |
|
|
|
Indexed::new(igp_payment).with_sequence( |
|
|
|
Indexed::new(igp_payment).with_sequence( |
|
|
@ -187,19 +198,6 @@ impl SealevelInterchainGasPaymasterIndexer { |
|
|
|
)) |
|
|
|
)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async fn interchain_payment_log_meta( |
|
|
|
|
|
|
|
&self, |
|
|
|
|
|
|
|
log_index: U256, |
|
|
|
|
|
|
|
payment_pda_pubkey: &Pubkey, |
|
|
|
|
|
|
|
payment_pda_slot: &Slot, |
|
|
|
|
|
|
|
) -> ChainResult<LogMeta> { |
|
|
|
|
|
|
|
let block = self.rpc_client.get_block(*payment_pda_slot).await?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.log_meta_composer |
|
|
|
|
|
|
|
.log_meta(block, log_index, payment_pda_pubkey, payment_pda_slot) |
|
|
|
|
|
|
|
.map_err(Into::<ChainCommunicationError>::into) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn interchain_payment_account(&self, account: &Account) -> ChainResult<Pubkey> { |
|
|
|
fn interchain_payment_account(&self, account: &Account) -> ChainResult<Pubkey> { |
|
|
|
let unique_gas_payment_pubkey = Pubkey::new(&account.data); |
|
|
|
let unique_gas_payment_pubkey = Pubkey::new(&account.data); |
|
|
|
let (expected_pubkey, _bump) = Pubkey::try_find_program_address( |
|
|
|
let (expected_pubkey, _bump) = Pubkey::try_find_program_address( |
|
|
@ -213,6 +211,19 @@ impl SealevelInterchainGasPaymasterIndexer { |
|
|
|
})?; |
|
|
|
})?; |
|
|
|
Ok(expected_pubkey) |
|
|
|
Ok(expected_pubkey) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async fn _interchain_payment_log_meta( |
|
|
|
|
|
|
|
&self, |
|
|
|
|
|
|
|
log_index: U256, |
|
|
|
|
|
|
|
payment_pda_pubkey: &Pubkey, |
|
|
|
|
|
|
|
payment_pda_slot: &Slot, |
|
|
|
|
|
|
|
) -> ChainResult<LogMeta> { |
|
|
|
|
|
|
|
let block = self.rpc_client.get_block(*payment_pda_slot).await?; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._log_meta_composer |
|
|
|
|
|
|
|
.log_meta(block, log_index, payment_pda_pubkey, payment_pda_slot) |
|
|
|
|
|
|
|
.map_err(Into::<ChainCommunicationError>::into) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#[async_trait] |
|
|
|
#[async_trait] |
|
|
|