Skip to content

Commit 8914ada

Browse files
committed
✨ Add WebSocket events
1 parent 152d9c9 commit 8914ada

File tree

9 files changed

+565
-143
lines changed

9 files changed

+565
-143
lines changed

Cargo.lock

Lines changed: 25 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ members = ["contracts", "contracts/wallet", "server"]
77
# client-sdk = { default-features = false, package = "hyle-client-sdk", version = "0.13.0-rc.4" }
88
# hyle = { version = "0.13.0-rc.4" }
99

10-
sdk = { git = "https://github.com/Hyle-org/hyle.git", package = "hyle-contract-sdk", branch = "refacto/multiproof" }
11-
client-sdk = { git = "https://github.com/Hyle-org/hyle.git", default-features = false, package = "hyle-client-sdk", branch = "refacto/multiproof" }
12-
hyle = { git = "https://github.com/Hyle-org/hyle.git", branch = "refacto/multiproof" }
13-
hyle-hyllar = { git = "https://github.com/Hyle-org/hyle.git", package = "hyle-hyllar", branch = "refacto/multiproof" }
10+
sdk = { git = "https://github.com/Hyle-org/hyle.git", package = "hyle-contract-sdk", branch = "feat/csi_events" }
11+
client-sdk = { git = "https://github.com/Hyle-org/hyle.git", default-features = false, package = "hyle-client-sdk", branch = "feat/csi_events" }
12+
hyle = { git = "https://github.com/Hyle-org/hyle.git", branch = "feat/csi_events" }
13+
hyle-hyllar = { git = "https://github.com/Hyle-org/hyle.git", package = "hyle-hyllar", branch = "feat/csi_events" }
1414

1515
contracts = { path = "contracts", default-features = false, package = "contracts" }
1616
wallet = { path = "contracts/wallet", package = "wallet" }

contracts/wallet/src/client/indexer.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ use crate::*;
1717
use client_sdk::contract_indexer::axum;
1818
use client_sdk::contract_indexer::utoipa;
1919

20-
impl ContractHandler for Wallet {
20+
#[derive(Debug, Clone, Default, Serialize)]
21+
pub struct WalletEvent {
22+
pub account: sdk::Identity,
23+
pub program_outputs: String,
24+
}
25+
26+
impl ContractHandler<WalletEvent> for Wallet {
2127
async fn api(store: ContractHandlerStore<Wallet>) -> (Router<()>, OpenApi) {
2228
let (router, api) = OpenApiRouter::default()
2329
.routes(routes!(get_state))
@@ -31,7 +37,7 @@ impl ContractHandler for Wallet {
3137
tx: &sdk::BlobTransaction,
3238
index: sdk::BlobIndex,
3339
tx_context: sdk::TxContext,
34-
) -> Result<()> {
40+
) -> Result<Option<WalletEvent>> {
3541
let sdk::Blob {
3642
contract_name,
3743
data: _,
@@ -55,7 +61,10 @@ impl ContractHandler for Wallet {
5561
handler = %contract_name,
5662
"hyle_output: {:?}", hyle_output
5763
);
58-
Ok(())
64+
Ok(Some(WalletEvent {
65+
account: tx.identity.clone(),
66+
program_outputs: program_outputs.to_string(),
67+
}))
5968
}
6069
}
6170

server/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ clap = "4.5.28"
2626
opentelemetry = { version = "0.28" }
2727
prometheus = { version = "0.13.4" }
2828
rand = "0.9.0"
29+
serde_json = "1.0.140"
30+
futures = "0.3.31"
2931

3032
[package.metadata.cargo-machete]
3133
ignored = ["tracing-subscriber", "opentelemetry", "prometheus", "rand"]

0 commit comments

Comments
 (0)