Skip to content

Commit

Permalink
Merge pull request #86 from kinode-dao/develop
Browse files Browse the repository at this point in the history
Develop 0.9.0
  • Loading branch information
dr-frmr committed Aug 16, 2024
2 parents 9a53504 + 5c1d8ed commit 284f202
Show file tree
Hide file tree
Showing 24 changed files with 2,759 additions and 1,819 deletions.
4 changes: 3 additions & 1 deletion Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
[package]
name = "kinode_process_lib"
description = "A library for writing Kinode processes in Rust."
version = "0.8.5"
version = "0.9.0"
edition = "2021"
license-file = "LICENSE"
homepage = "https://kinode.org"
repository = "https://github.com/kinode-dao/process_lib"

[dependencies]
alloy-primitives = "0.7.0"
alloy-primitives = "0.7.6"
alloy-sol-macro = "0.7.6"
alloy-sol-types = "0.7.6"
alloy = { version = "0.1.1", features = [
"json-rpc",
"rpc-types",
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@

END OF TERMS AND CONDITIONS

Copyright 2024 Unzentrum DAO
Copyright 2024 Sybil Technologies AG

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
32 changes: 28 additions & 4 deletions src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ pub use alloy_primitives::{Address, BlockHash, BlockNumber, Bytes, TxHash, U128,
use serde::{Deserialize, Serialize};
use std::collections::{HashMap, HashSet};

//
// types mirrored from runtime module
//

/// The Action and Request type that can be made to eth:distro:sys. Any process with messaging
/// capabilities can send this action to the eth provider.
///
Expand Down Expand Up @@ -555,6 +551,16 @@ impl Provider {
self.send_request_and_parse_response::<Bytes>(action)
}

/// Returns a Kimap instance with the default address using this provider.
pub fn kimap(&self) -> crate::kimap::Kimap {
crate::kimap::Kimap::default(self.request_timeout)
}

/// Returns a Kimap instance with a custom address using this provider.
pub fn kimap_with_address(self, address: Address) -> crate::kimap::Kimap {
crate::kimap::Kimap::new(self, address)
}

/// Sends a raw transaction to the network.
///
/// # Parameters
Expand Down Expand Up @@ -617,6 +623,24 @@ impl Provider {
}
}

/// Subscribe in a loop until successful
pub fn subscribe_loop(&self, sub_id: u64, filter: Filter) {
loop {
match self.subscribe(sub_id, filter.clone()) {
Ok(()) => break,
Err(_) => {
crate::print_to_terminal(
0,
"failed to subscribe to chain! trying again in 5s...",
);
std::thread::sleep(std::time::Duration::from_secs(5));
continue;
}
}
}
crate::print_to_terminal(0, "subscribed to logs successfully");
}

/// Unsubscribes from a previously created subscription.
///
/// # Parameters
Expand Down
13 changes: 13 additions & 0 deletions src/homepage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use crate::Request;
/// Add a new icon and/or widget to the Kinode homepage. Note that the process calling this
/// function must have the `homepage:homepage:sys` messaging capability.
///
/// This should be called upon process startup to ensure that the process is added to the homepage.
///
/// An icon must be a base64 encoded SVG.
///
/// A path will be automatically placed underneath the namespace of the process. For example,
Expand All @@ -26,3 +28,14 @@ pub fn add_to_homepage(label: &str, icon: Option<&str>, path: Option<&str>, widg
.send()
.unwrap();
}

/// Remove the caller process from the Kinode homepage. Note that the process calling this function
/// must have the `homepage:homepage:sys` messaging capability.
///
/// This usually isn't necessary as processes are not persisted on homepage between boots.
pub fn remove_from_homepage() {
Request::to(("our", "homepage", "homepage", "sys"))
.body("\"Remove\"")
.send()
.unwrap();
}
Loading

0 comments on commit 284f202

Please sign in to comment.