forked from hyperlane-xyz/hyperlane-monorepo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2eb4a7
commit c16ed99
Showing
9 changed files
with
324 additions
and
12 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
rust/main/chains/hyperlane-sovereign/src/interchain_gas.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::{ConnectionConf, Signer, SovereignProvider}; | ||
use async_trait::async_trait; | ||
use hyperlane_core::{ | ||
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain, | ||
InterchainGasPaymaster, H256, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct SovereignInterchainGasPaymaster { | ||
domain: HyperlaneDomain, | ||
address: H256, | ||
provider: SovereignProvider, | ||
} | ||
|
||
impl SovereignInterchainGasPaymaster { | ||
pub async fn new( | ||
conf: &ConnectionConf, | ||
locator: ContractLocator<'_>, | ||
signer: Option<Signer>, | ||
) -> ChainResult<Self> { | ||
let provider = SovereignProvider::new(locator.domain.clone(), &conf.clone(), signer).await; | ||
Ok(SovereignInterchainGasPaymaster { | ||
domain: locator.domain.clone(), | ||
provider, | ||
address: locator.address, | ||
}) | ||
} | ||
} | ||
|
||
impl HyperlaneContract for SovereignInterchainGasPaymaster { | ||
fn address(&self) -> hyperlane_core::H256 { | ||
self.address | ||
} | ||
} | ||
|
||
impl HyperlaneChain for SovereignInterchainGasPaymaster { | ||
fn domain(&self) -> &hyperlane_core::HyperlaneDomain { | ||
&self.domain | ||
} | ||
|
||
fn provider(&self) -> Box<dyn hyperlane_core::HyperlaneProvider> { | ||
Box::new(self.provider.clone()) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl InterchainGasPaymaster for SovereignInterchainGasPaymaster {} |
59 changes: 59 additions & 0 deletions
59
rust/main/chains/hyperlane-sovereign/src/interchain_security_module.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use crate::{ConnectionConf, Signer, SovereignProvider}; | ||
use async_trait::async_trait; | ||
use hyperlane_core::{ | ||
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain, | ||
HyperlaneMessage, InterchainSecurityModule, ModuleType, H256, U256, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct SovereignInterchainSecurityModule { | ||
domain: HyperlaneDomain, | ||
address: H256, | ||
provider: SovereignProvider, | ||
} | ||
|
||
impl SovereignInterchainSecurityModule { | ||
pub async fn new( | ||
conf: &ConnectionConf, | ||
locator: ContractLocator<'_>, | ||
signer: Option<Signer>, | ||
) -> ChainResult<Self> { | ||
let provider = SovereignProvider::new(locator.domain.clone(), &conf.clone(), signer).await; | ||
Ok(SovereignInterchainSecurityModule { | ||
domain: locator.domain.clone(), | ||
provider, | ||
address: locator.address, | ||
}) | ||
} | ||
} | ||
|
||
impl HyperlaneContract for SovereignInterchainSecurityModule { | ||
fn address(&self) -> hyperlane_core::H256 { | ||
self.address | ||
} | ||
} | ||
|
||
impl HyperlaneChain for SovereignInterchainSecurityModule { | ||
fn domain(&self) -> &hyperlane_core::HyperlaneDomain { | ||
&self.domain | ||
} | ||
|
||
fn provider(&self) -> Box<dyn hyperlane_core::HyperlaneProvider> { | ||
Box::new(self.provider.clone()) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl InterchainSecurityModule for SovereignInterchainSecurityModule { | ||
async fn dry_run_verify( | ||
&self, | ||
_message: &HyperlaneMessage, | ||
_metadata: &[u8], | ||
) -> ChainResult<Option<U256>> { | ||
todo!() | ||
} | ||
|
||
async fn module_type(&self) -> ChainResult<ModuleType> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
pub use self::{ | ||
/*interchain_gas::*,*/ mailbox::*, /*multisig_ism::*,*/ provider::*, | ||
/*routing_ism::*,*/ signers::*, trait_builder::*, validator_announce::*, | ||
interchain_gas::*, interchain_security_module::*, mailbox::*, merkle_tree_hook::*, | ||
multisig_ism::*, provider::*, routing_ism::*, signers::*, trait_builder::*, | ||
validator_announce::*, | ||
}; | ||
|
||
mod interchain_gas; | ||
mod interchain_security_module; | ||
mod mailbox; | ||
mod merkle_tree_hook; | ||
mod multisig_ism; | ||
mod provider; | ||
mod routing_ism; | ||
mod signers; | ||
mod trait_builder; | ||
mod validator_announce; |
60 changes: 60 additions & 0 deletions
60
rust/main/chains/hyperlane-sovereign/src/merkle_tree_hook.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::{ConnectionConf, Signer, SovereignProvider}; | ||
use async_trait::async_trait; | ||
use hyperlane_core::{ | ||
accumulator::incremental::IncrementalMerkle, ChainResult, Checkpoint, ContractLocator, | ||
HyperlaneChain, HyperlaneContract, HyperlaneDomain, MerkleTreeHook, H256, | ||
}; | ||
use std::num::NonZeroU64; | ||
|
||
#[derive(Debug)] | ||
pub struct SovereignMerkleTreeHook { | ||
domain: HyperlaneDomain, | ||
address: H256, | ||
provider: SovereignProvider, | ||
} | ||
|
||
impl SovereignMerkleTreeHook { | ||
pub async fn new( | ||
conf: &ConnectionConf, | ||
locator: ContractLocator<'_>, | ||
signer: Option<Signer>, | ||
) -> ChainResult<Self> { | ||
let provider = SovereignProvider::new(locator.domain.clone(), &conf.clone(), signer).await; | ||
Ok(SovereignMerkleTreeHook { | ||
domain: locator.domain.clone(), | ||
provider, | ||
address: locator.address, | ||
}) | ||
} | ||
} | ||
|
||
impl HyperlaneChain for SovereignMerkleTreeHook { | ||
fn domain(&self) -> &hyperlane_core::HyperlaneDomain { | ||
&self.domain | ||
} | ||
|
||
fn provider(&self) -> Box<dyn hyperlane_core::HyperlaneProvider> { | ||
Box::new(self.provider.clone()) | ||
} | ||
} | ||
|
||
impl HyperlaneContract for SovereignMerkleTreeHook { | ||
fn address(&self) -> hyperlane_core::H256 { | ||
self.address | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl MerkleTreeHook for SovereignMerkleTreeHook { | ||
async fn tree(&self, _lag: Option<NonZeroU64>) -> ChainResult<IncrementalMerkle> { | ||
todo!() | ||
} | ||
|
||
async fn count(&self, _lag: Option<NonZeroU64>) -> ChainResult<u32> { | ||
todo!() | ||
} | ||
|
||
async fn latest_checkpoint(&self, _lag: Option<NonZeroU64>) -> ChainResult<Checkpoint> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use crate::{ConnectionConf, Signer, SovereignProvider}; | ||
use async_trait::async_trait; | ||
use hyperlane_core::{ | ||
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain, | ||
HyperlaneMessage, MultisigIsm, H256, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct SovereignMultisigIsm { | ||
domain: HyperlaneDomain, | ||
address: H256, | ||
provider: SovereignProvider, | ||
} | ||
|
||
impl SovereignMultisigIsm { | ||
pub async fn new( | ||
conf: &ConnectionConf, | ||
locator: ContractLocator<'_>, | ||
signer: Option<Signer>, | ||
) -> ChainResult<Self> { | ||
let provider = SovereignProvider::new(locator.domain.clone(), &conf.clone(), signer).await; | ||
Ok(SovereignMultisigIsm { | ||
domain: locator.domain.clone(), | ||
provider, | ||
address: locator.address, | ||
}) | ||
} | ||
} | ||
|
||
impl HyperlaneContract for SovereignMultisigIsm { | ||
fn address(&self) -> hyperlane_core::H256 { | ||
self.address | ||
} | ||
} | ||
|
||
impl HyperlaneChain for SovereignMultisigIsm { | ||
fn domain(&self) -> &hyperlane_core::HyperlaneDomain { | ||
&self.domain | ||
} | ||
|
||
fn provider(&self) -> Box<dyn hyperlane_core::HyperlaneProvider> { | ||
Box::new(self.provider.clone()) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl MultisigIsm for SovereignMultisigIsm { | ||
async fn validators_and_threshold( | ||
&self, | ||
_message: &HyperlaneMessage, | ||
) -> ChainResult<(Vec<H256>, u8)> { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use crate::{ConnectionConf, Signer, SovereignProvider}; | ||
use async_trait::async_trait; | ||
use hyperlane_core::{ | ||
ChainResult, ContractLocator, HyperlaneChain, HyperlaneContract, HyperlaneDomain, | ||
HyperlaneMessage, RoutingIsm, H256, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct SovereignRoutingIsm { | ||
domain: HyperlaneDomain, | ||
address: H256, | ||
provider: SovereignProvider, | ||
} | ||
|
||
impl SovereignRoutingIsm { | ||
pub async fn new( | ||
conf: &ConnectionConf, | ||
locator: ContractLocator<'_>, | ||
signer: Option<Signer>, | ||
) -> ChainResult<Self> { | ||
let provider = SovereignProvider::new(locator.domain.clone(), &conf.clone(), signer).await; | ||
Ok(SovereignRoutingIsm { | ||
domain: locator.domain.clone(), | ||
provider, | ||
address: locator.address, | ||
}) | ||
} | ||
} | ||
|
||
impl HyperlaneContract for SovereignRoutingIsm { | ||
fn address(&self) -> hyperlane_core::H256 { | ||
self.address | ||
} | ||
} | ||
|
||
impl HyperlaneChain for SovereignRoutingIsm { | ||
fn domain(&self) -> &hyperlane_core::HyperlaneDomain { | ||
&self.domain | ||
} | ||
|
||
fn provider(&self) -> Box<dyn hyperlane_core::HyperlaneProvider> { | ||
Box::new(self.provider.clone()) | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl RoutingIsm for SovereignRoutingIsm { | ||
async fn route(&self, _message: &HyperlaneMessage) -> ChainResult<H256> { | ||
todo!() | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
rust/main/chains/hyperlane-sovereign/src/validator_announce.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.