pub use blueprint_client_tangle::Error;
pub use blueprint_client_tangle::TangleClient;
pub use blueprint_client_tangle::TangleClientConfig;
pub use blueprint_client_tangle::TangleSettings;
use blueprint_runner::config::BlueprintEnvironment;
pub trait TangleClientContext {
fn tangle_client(
&self,
) -> impl core::future::Future<Output = Result<TangleClient, Error>> + Send;
}
impl TangleClientContext for BlueprintEnvironment {
async fn tangle_client(&self) -> Result<TangleClient, Error> {
let keystore = self.keystore();
let settings = self
.protocol_settings
.tangle()
.map_err(|e| Error::Config(e.to_string()))?;
let config = TangleClientConfig {
http_rpc_endpoint: self.http_rpc_endpoint.clone(),
ws_rpc_endpoint: self.ws_rpc_endpoint.clone(),
keystore_uri: self.keystore_uri.clone(),
data_dir: self.data_dir.clone(),
settings: TangleSettings {
blueprint_id: settings.blueprint_id,
service_id: settings.service_id,
tangle_contract: settings.tangle_contract,
restaking_contract: settings.restaking_contract,
status_registry_contract: settings.status_registry_contract,
},
test_mode: self.test_mode,
dry_run: self.dry_run,
};
TangleClient::with_keystore(config, keystore).await
}
}