-
Notifications
You must be signed in to change notification settings - Fork 13
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
Showing
16 changed files
with
206 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,33 @@ | ||
[package] | ||
name = "webb-bridge-registry-backends" | ||
version = "0.1.0" | ||
authors = { workspace = true } | ||
edition = { workspace = true } | ||
license = { workspace = true } | ||
documentation = { workspace = true } | ||
homepage = { workspace = true } | ||
repository = { workspace = true } | ||
|
||
[dependencies] | ||
webb-relayer-types = { path = "../relayer-types" } | ||
webb-relayer-store = { path = "../relayer-store" } | ||
webb-relayer-utils = { path = "../relayer-utils" } | ||
|
||
async-trait = { workspace = true } | ||
tracing = { workspace = true } | ||
sled = { workspace = true } | ||
futures = { workspace = true } | ||
tokio = { workspace = true } | ||
hex = { workspace = true } | ||
webb = { workspace = true } | ||
# Used by ethers (but we need it to be vendored with the lib). | ||
native-tls = { workspace = true, optional = true } | ||
webb-proposals = { workspace = true } | ||
ethereum-types = { workspace = true } | ||
sp-core = { workspace = true } | ||
|
||
typed-builder = "0.12.0" | ||
|
||
[features] | ||
default = ["std"] | ||
std = [] |
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,41 @@ | ||
use webb::substrate::subxt::{OnlineClient, PolkadotConfig}; | ||
use webb::substrate::dkg_runtime::api as RuntimeApi; | ||
use webb::substrate::dkg_runtime::api::runtime_types::pallet_bridge_registry::types::BridgeMetadata; | ||
|
||
pub struct DkgBridgeRegistryBackend { | ||
client: OnlineClient<PolkadotConfig>, | ||
} | ||
|
||
impl DkgBridgeRegistryBackend { | ||
pub fn new( | ||
client: OnlineClient<PolkadotConfig>, | ||
) -> Self { | ||
Self { | ||
client, | ||
} | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl super::BridgeRegistryBackend for DkgBridgeRegistryBackend { | ||
async fn next_bridge_index(&self) -> webb_relayer_utils::Result<u32> { | ||
// retrieve resource ids from bridge registry | ||
let storage = RuntimeApi::storage().bridge_registry(); | ||
let next_bridge_index = storage.next_bridge_index(); | ||
Ok(self.client.storage() | ||
.at(None) | ||
.await? | ||
.fetch(&next_bridge_index) | ||
.await? | ||
.unwrap()) | ||
} | ||
|
||
async fn bridges(&self, index: u32) -> webb_relayer_utils::Result<BridgeMetadata> { | ||
let storage = RuntimeApi::storage().bridge_registry(); | ||
let bridges = storage.bridges(index); | ||
Ok(self.client.storage() | ||
.at(None) | ||
.await? | ||
.fetch(&bridges).await?.unwrap()) | ||
} | ||
} |
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,18 @@ | ||
use webb::substrate::dkg_runtime::api::runtime_types::pallet_bridge_registry::types::BridgeMetadata; | ||
|
||
#[doc(hidden)] | ||
pub mod dkg; | ||
|
||
#[doc(hidden)] | ||
pub mod mocked; | ||
|
||
#[async_trait::async_trait] | ||
pub trait BridgeRegistryBackend { | ||
async fn next_bridge_index( | ||
&self, | ||
) -> webb_relayer_utils::Result<u32>; | ||
async fn bridges( | ||
&self, | ||
index: u32 | ||
) -> webb_relayer_utils::Result<BridgeMetadata>; | ||
} |
Oops, something went wrong.