Skip to content

Commit 3a6541c

Browse files
authored
Merge pull request #147 from hyperware-ai/develop
develop
2 parents 2bfa627 + 948a519 commit 3a6541c

File tree

9 files changed

+1572
-14
lines changed

9 files changed

+1572
-14
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "hyperware_process_lib"
33
authors = ["Sybil Technologies AG"]
4-
version = "1.1.0"
4+
version = "1.2.0"
55
edition = "2021"
66
description = "A library for writing Hyperware processes in Rust."
77
homepage = "https://hyperware.ai"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
interface hypermap-cacher {
2+
// Metadata associated with a batch of Ethereum logs.
3+
record logs-metadata {
4+
chain-id: string,
5+
from-block: string,
6+
to-block: string,
7+
time-created: string,
8+
created-by: string,
9+
signature: string,
10+
}
11+
12+
// Represents an item in the manifest, detailing a single log cache file.
13+
record manifest-item {
14+
metadata: logs-metadata,
15+
is-empty: bool,
16+
file-hash: string,
17+
file-name: string,
18+
}
19+
20+
// The main manifest structure, listing all available log cache files.
21+
// WIT does not support direct map types, so a list of key-value tuples is used.
22+
record manifest {
23+
// The key is the filename of the log cache.
24+
items: list<tuple<string, manifest-item>>,
25+
manifest-filename: string,
26+
chain-id: string,
27+
protocol-version: string,
28+
}
29+
30+
record get-logs-by-range-request {
31+
from-block: u64,
32+
to-block: option<u64>, // If None, signifies to the latest available/relevant cached block.
33+
}
34+
35+
variant get-logs-by-range-ok-response {
36+
logs(tuple<u64, string>),
37+
latest(u64),
38+
}
39+
40+
// Defines the types of requests that can be sent to the Hypermap Cacher process.
41+
variant cacher-request {
42+
get-manifest,
43+
get-log-cache-content(string),
44+
get-status,
45+
get-logs-by-range(get-logs-by-range-request),
46+
start-providing,
47+
stop-providing,
48+
set-nodes(list<string>),
49+
reset(option<list<string>>),
50+
}
51+
52+
// Represents the operational status of the cacher.
53+
record cacher-status {
54+
last-cached-block: u64,
55+
chain-id: string,
56+
protocol-version: string,
57+
next-cache-attempt-in-seconds: option<u64>,
58+
manifest-filename: string,
59+
log-files-count: u32,
60+
our-address: string,
61+
is-providing: bool,
62+
}
63+
64+
// Defines the types of responses the Hypermap Cacher process can send.
65+
variant cacher-response {
66+
get-manifest(option<manifest>),
67+
get-log-cache-content(result<option<string>, string>),
68+
get-status(cacher-status),
69+
get-logs-by-range(result<get-logs-by-range-ok-response, string>),
70+
start-providing(result<string, string>),
71+
stop-providing(result<string, string>),
72+
set-nodes(result<string, string>),
73+
reset(result<string, string>),
74+
rejected,
75+
is-starting,
76+
}
77+
}
78+
79+
world hypermap-cacher-sys-v0 {
80+
import sign;
81+
import hypermap-cacher;
82+
include process-v1;
83+
}

hyperware-wit/process-lib.wit

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
world process-lib {
2+
import sign;
3+
import hypermap-cacher;
4+
include lib;
5+
}

hyperware-wit/sign:sys-v0.wit

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
interface sign {
2+
use standard.{address};
3+
4+
variant request {
5+
/// Request to sign the message given in blob with net key.
6+
///
7+
/// lazy-load-blob: required; the message to sign.
8+
net-key-sign,
9+
/// Request to verify the message given in blob with net key.
10+
///
11+
/// lazy-load-blob: required; the message to verify.
12+
net-key-verify(net-key-verify-request),
13+
/// Request to transform the message to the form that is signed with net key.
14+
/// For use by outside verifiers (net-key-verify transforms naked message
15+
/// properly under-the-hood).
16+
///
17+
/// lazy-load-blob: required; the message to transform.
18+
net-key-make-message,
19+
}
20+
21+
variant response {
22+
/// Response containing the net key signature in blob.
23+
/// The source (address) will always be prepended to the payload.
24+
/// The source (address) of sign:sign:sys will also be prepended.
25+
/// Thus the message signed looks like
26+
/// [sign-address, address, blob.bytes].concat()
27+
///
28+
/// Using request::net-key-verify handles the concatenation under-the-hood,
29+
/// but verifying the signature will require the proper transformation of
30+
/// the message.
31+
///
32+
/// lazy-load-blob: required; signature.
33+
net-key-sign,
34+
/// Response: whether the net key signature is valid.
35+
///
36+
/// lazy-load-blob: none.
37+
net-key-verify(bool),
38+
/// Response containing modified message in blob.
39+
/// The source (address) will always be prepended to the payload.
40+
/// The source (address) of sign:sign:sys will also be prepended.
41+
/// Thus the message signed looks like
42+
/// [sign-address, address, blob.bytes].concat()
43+
///
44+
/// Using request::net-key-verify handles the concatenation under-the-hood,
45+
/// but verifying the signature will require the proper transformation of
46+
/// the message.
47+
///
48+
/// lazy-load-blob: required; the transformed message.
49+
net-key-make-message,
50+
}
51+
52+
record net-key-verify-request {
53+
node: string,
54+
signature: list<u8>,
55+
}
56+
}
57+
58+
world sign-sys-v0 {
59+
import sign;
60+
include process-v1;
61+
}

src/eth.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,11 @@ impl Provider {
318318
request_timeout,
319319
}
320320
}
321+
322+
pub fn get_chain_id(&self) -> u64 {
323+
self.chain_id
324+
}
325+
321326
/// Sends a request based on the specified [`EthAction`] and parses the response.
322327
///
323328
/// This function constructs a request targeting the Ethereum distribution system, serializes the provided [`EthAction`],

0 commit comments

Comments
 (0)