Skip to content

Commit

Permalink
[WIP] Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-eiger authored and luke-lorenzini committed Dec 10, 2024
1 parent 8260866 commit dc7eb43
Show file tree
Hide file tree
Showing 15 changed files with 398 additions and 93 deletions.
1 change: 1 addition & 0 deletions rust/main/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/main/chains/hyperlane-sovereign/Cargo.toml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ serde_json.workspace = true
tokio = { workspace = true, features = [
"macros",
] }
tracing.workspace = true
url.workspace = true

bech32 = "0.11.0"
42 changes: 42 additions & 0 deletions rust/main/chains/hyperlane-sovereign/src/interchain_gas.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,51 @@
use crate::{ConnectionConf, Signer, SovereignProvider};
use async_trait::async_trait;
use hyperlane_core::{
Indexer, SequenceAwareIndexer, Indexed, LogMeta, InterchainGasPayment,
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain,
HyperlaneProvider, InterchainGasPaymaster, H256,
};
use tracing::info;
use core::ops::RangeInclusive;

/// A reference to a InterchainGasPaymasterIndexer contract on some Cosmos chain
#[derive(Debug, Clone)]
pub struct SovereignInterchainGasPaymasterIndexer {
provider: Box<SovereignProvider>,
}

impl SovereignInterchainGasPaymasterIndexer {
pub async fn new(conf: ConnectionConf, locator: ContractLocator<'_>) -> ChainResult<Self> {
let provider = SovereignProvider::new(locator.domain.clone(), &conf, None).await;

Ok(SovereignInterchainGasPaymasterIndexer {
provider: Box::new(provider)
})
}
}

#[async_trait]
impl Indexer<InterchainGasPayment> for SovereignInterchainGasPaymasterIndexer {
async fn fetch_logs_in_range(&self, range: RangeInclusive<u32>) -> ChainResult<Vec<(Indexed<InterchainGasPayment>, LogMeta)>> {
info!("interchain: range:{:?}", range);
todo!()
}

async fn get_finalized_block_number(&self) -> ChainResult<u32> {
info!("interchain_gas: get_finalized_block_number");
todo!()
}
}

#[async_trait]
impl SequenceAwareIndexer<InterchainGasPayment> for SovereignInterchainGasPaymasterIndexer {
async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option<u32>, u32)> {
let tip = u32::default();
let sequence = u32::default();

Ok((Some(sequence), tip))
}
}

#[derive(Debug)]
pub struct SovereignInterchainGasPaymaster {
Expand Down
53 changes: 49 additions & 4 deletions rust/main/chains/hyperlane-sovereign/src/mailbox.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
use crate::{ConnectionConf, Signer, SovereignProvider};
use crate::{provider, ConnectionConf, Signer, SovereignProvider};
use async_trait::async_trait;
use hyperlane_core::{
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain,
HyperlaneMessage, HyperlaneProvider, Mailbox, TxCostEstimate, TxOutcome, H256, U256,
use hyperlane_core::{Indexed, LogMeta,
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain, HyperlaneMessage, HyperlaneProvider, Indexer, Mailbox, SequenceAwareIndexer, TxCostEstimate, TxOutcome, H256, U256
};
use core::ops::RangeInclusive;

use std::{fmt::Debug, num::NonZeroU64};
use tracing::info;

/// Struct that retrieves event data for a Cosmos Mailbox contract
#[derive(Debug, Clone)]
pub struct SovereignMailboxIndexer {
mailbox: SovereignMailbox,
provider: Box<SovereignProvider>,
}

impl SovereignMailboxIndexer {
pub async fn new(conf: ConnectionConf, locator: ContractLocator<'_>, signer: Option<Signer>) -> ChainResult<Self> {
let mailbox = SovereignMailbox::new(&conf, locator.clone(), signer).await?;
let provider = SovereignProvider::new(locator.domain.clone(), &conf, None).await;

Ok(SovereignMailboxIndexer {
mailbox,
provider: Box::new(provider)
})
}
}

#[async_trait]
impl Indexer<HyperlaneMessage> for SovereignMailboxIndexer {
async fn fetch_logs_in_range(&self, range: RangeInclusive<u32>) -> ChainResult<Vec<(Indexed<HyperlaneMessage>, LogMeta)>> {
info!("mailbox: range:{:?}", range);
todo!()
}

async fn get_finalized_block_number(&self) -> ChainResult<u32> {
info!("mailbox: get_finalized_block_number");
todo!()
}
}

#[async_trait]
impl SequenceAwareIndexer<HyperlaneMessage> for SovereignMailboxIndexer {
async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option<u32>, u32)> {
let tip = u32::default();

let sequence = u32::default();

Ok((Some(sequence), tip))
}
}

/// A reference to a Mailbox contract on some Sovereign chain.
#[derive(Clone, Debug)]
Expand Down
45 changes: 45 additions & 0 deletions rust/main/chains/hyperlane-sovereign/src/merkle_tree_hook.rs
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,55 @@
use crate::{ConnectionConf, Signer, SovereignProvider};
use async_trait::async_trait;
use hyperlane_core::{
SequenceAwareIndexer, MerkleTreeInsertion, Indexer, LogMeta, Indexed,
accumulator::incremental::IncrementalMerkle, ChainResult, Checkpoint, ContractLocator,
HyperlaneChain, HyperlaneContract, HyperlaneDomain, HyperlaneProvider, MerkleTreeHook, H256,
};
use std::num::NonZeroU64;
use core::ops::RangeInclusive;
use tracing::info;

/// Struct that retrieves event data for a Cosmos Mailbox contract
#[derive(Debug, Clone)]
pub struct SovereignMerkleTreeHookIndexer {
// mailbox: SovereignMailbox,
provider: Box<SovereignProvider>,
}

impl SovereignMerkleTreeHookIndexer {
pub async fn new(conf: ConnectionConf, locator: ContractLocator<'_>, signer: Option<Signer>) -> ChainResult<Self> {
// let mailbox = SovereignMailbox::new(&conf, locator.clone(), signer).await?;
let provider = SovereignProvider::new(locator.domain.clone(), &conf, None).await;

Ok(SovereignMerkleTreeHookIndexer {
// mailbox,
provider: Box::new(provider)
})
}
}

#[async_trait]
impl Indexer<MerkleTreeInsertion> for SovereignMerkleTreeHookIndexer {
async fn fetch_logs_in_range(&self, range: RangeInclusive<u32>) -> ChainResult<Vec<(Indexed<MerkleTreeInsertion>, LogMeta)>> {
info!("merkle_tree: range:{:?}", range);
todo!()
}

async fn get_finalized_block_number(&self) -> ChainResult<u32> {
info!("merkle_tree_hook: get_finalized_block_number");
todo!()
}
}

#[async_trait]
impl SequenceAwareIndexer<MerkleTreeInsertion> for SovereignMerkleTreeHookIndexer {
async fn latest_sequence_count_and_tip(&self) -> ChainResult<(Option<u32>, u32)> {
let tip = u32::default();
let sequence = u32::default();

Ok((Some(sequence), tip))
}
}

#[derive(Debug)]
pub struct SovereignMerkleTreeHook {
Expand Down
2 changes: 2 additions & 0 deletions rust/main/chains/hyperlane-sovereign/src/provider.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use hyperlane_core::{
BlockInfo, ChainInfo, ChainResult, HyperlaneChain, HyperlaneDomain, HyperlaneProvider, TxnInfo,
H256, U256,
};
use tracing::info;

mod rest_client;

Expand Down Expand Up @@ -66,6 +67,7 @@ impl HyperlaneProvider for SovereignProvider {
}

async fn get_balance(&self, address: String) -> ChainResult<U256> {
info!("get_balance(&self, address: String)");
let token_id = "token_1nyl0e0yweragfsatygt24zmd8jrr2vqtvdfptzjhxkguz2xxx3vs0y07u7";
let balance = self.client.get_balance(token_id, address.as_str()).await?;
Ok(balance)
Expand Down
Loading

0 comments on commit dc7eb43

Please sign in to comment.