Skip to content

Commit 284f202

Browse files
authored
Merge pull request #86 from kinode-dao/develop
Develop 0.9.0
2 parents 9a53504 + 5c1d8ed commit 284f202

24 files changed

+2759
-1819
lines changed

Cargo.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
[package]
22
name = "kinode_process_lib"
33
description = "A library for writing Kinode processes in Rust."
4-
version = "0.8.5"
4+
version = "0.9.0"
55
edition = "2021"
66
license-file = "LICENSE"
77
homepage = "https://kinode.org"
88
repository = "https://github.com/kinode-dao/process_lib"
99

1010
[dependencies]
11-
alloy-primitives = "0.7.0"
11+
alloy-primitives = "0.7.6"
12+
alloy-sol-macro = "0.7.6"
13+
alloy-sol-types = "0.7.6"
1214
alloy = { version = "0.1.1", features = [
1315
"json-rpc",
1416
"rpc-types",

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175

176176
END OF TERMS AND CONDITIONS
177177

178-
Copyright 2024 Unzentrum DAO
178+
Copyright 2024 Sybil Technologies AG
179179

180180
Licensed under the Apache License, Version 2.0 (the "License");
181181
you may not use this file except in compliance with the License.

src/eth.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ pub use alloy_primitives::{Address, BlockHash, BlockNumber, Bytes, TxHash, U128,
1010
use serde::{Deserialize, Serialize};
1111
use std::collections::{HashMap, HashSet};
1212

13-
//
14-
// types mirrored from runtime module
15-
//
16-
1713
/// The Action and Request type that can be made to eth:distro:sys. Any process with messaging
1814
/// capabilities can send this action to the eth provider.
1915
///
@@ -555,6 +551,16 @@ impl Provider {
555551
self.send_request_and_parse_response::<Bytes>(action)
556552
}
557553

554+
/// Returns a Kimap instance with the default address using this provider.
555+
pub fn kimap(&self) -> crate::kimap::Kimap {
556+
crate::kimap::Kimap::default(self.request_timeout)
557+
}
558+
559+
/// Returns a Kimap instance with a custom address using this provider.
560+
pub fn kimap_with_address(self, address: Address) -> crate::kimap::Kimap {
561+
crate::kimap::Kimap::new(self, address)
562+
}
563+
558564
/// Sends a raw transaction to the network.
559565
///
560566
/// # Parameters
@@ -617,6 +623,24 @@ impl Provider {
617623
}
618624
}
619625

626+
/// Subscribe in a loop until successful
627+
pub fn subscribe_loop(&self, sub_id: u64, filter: Filter) {
628+
loop {
629+
match self.subscribe(sub_id, filter.clone()) {
630+
Ok(()) => break,
631+
Err(_) => {
632+
crate::print_to_terminal(
633+
0,
634+
"failed to subscribe to chain! trying again in 5s...",
635+
);
636+
std::thread::sleep(std::time::Duration::from_secs(5));
637+
continue;
638+
}
639+
}
640+
}
641+
crate::print_to_terminal(0, "subscribed to logs successfully");
642+
}
643+
620644
/// Unsubscribes from a previously created subscription.
621645
///
622646
/// # Parameters

src/homepage.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::Request;
33
/// Add a new icon and/or widget to the Kinode homepage. Note that the process calling this
44
/// function must have the `homepage:homepage:sys` messaging capability.
55
///
6+
/// This should be called upon process startup to ensure that the process is added to the homepage.
7+
///
68
/// An icon must be a base64 encoded SVG.
79
///
810
/// A path will be automatically placed underneath the namespace of the process. For example,
@@ -26,3 +28,14 @@ pub fn add_to_homepage(label: &str, icon: Option<&str>, path: Option<&str>, widg
2628
.send()
2729
.unwrap();
2830
}
31+
32+
/// Remove the caller process from the Kinode homepage. Note that the process calling this function
33+
/// must have the `homepage:homepage:sys` messaging capability.
34+
///
35+
/// This usually isn't necessary as processes are not persisted on homepage between boots.
36+
pub fn remove_from_homepage() {
37+
Request::to(("our", "homepage", "homepage", "sys"))
38+
.body("\"Remove\"")
39+
.send()
40+
.unwrap();
41+
}

0 commit comments

Comments
 (0)