diff --git a/packages/kolme/src/core/execute.rs b/packages/kolme/src/core/execute.rs index 5047f774..044af190 100644 --- a/packages/kolme/src/core/execute.rs +++ b/packages/kolme/src/core/execute.rs @@ -339,10 +339,7 @@ impl ExecutionContext<'_, App> { account_id, }))?; } - BridgeEvent::Signed { - wallet: _, - action_id, - } => { + BridgeEvent::Signed { wallet, action_id } => { // TODO in the future we may track wallet addresses that submitted signed actions to give them rewards. let action_id = *action_id; let actions = &mut self.framework_state.chains.get_mut(chain)?.pending_actions; @@ -353,6 +350,10 @@ impl ExecutionContext<'_, App> { anyhow::ensure!(*next_action_id == action_id); let (old_id, _old) = actions.remove(&action_id).unwrap(); anyhow::ensure!(old_id == action_id); + self.log_event(LogEvent::ProcessedBridgeEvent(LogBridgeEvent::Signed { + wallet: wallet.clone(), + action_id, + }))?; } } } diff --git a/packages/kolme/src/core/types.rs b/packages/kolme/src/core/types.rs index dc69c497..741be910 100644 --- a/packages/kolme/src/core/types.rs +++ b/packages/kolme/src/core/types.rs @@ -1689,6 +1689,10 @@ pub enum LogBridgeEvent { bridge_event_id: BridgeEventId, account_id: AccountId, }, + Signed { + wallet: Wallet, + action_id: BridgeActionId, + }, } /// Whether we validate data loads during block processing. diff --git a/packages/kolme/src/pass_through.rs b/packages/kolme/src/pass_through.rs index d2678419..5d5a8b26 100644 --- a/packages/kolme/src/pass_through.rs +++ b/packages/kolme/src/pass_through.rs @@ -57,14 +57,18 @@ pub async fn execute( approvals: &BTreeMap, payload: &str, ) -> Result { - let url = format!("http://localhost:{port}/actions"); + let url = format!("http://localhost:{port}/msg"); tracing::debug!("Sending bridge action to {url}"); let resp = client .post(url) - .json(&Action { - processor, - approvers: approvals.values().copied().collect(), - payload: payload.to_owned(), + .json(&Msg { + wallet: "submitter".to_string(), // not currently used for anything + coins: vec![], + msg: ExecuteMsg::Signed { + processor, + approvers: approvals.values().copied().collect(), + payload: payload.to_owned(), + }, }) .send() .await?; @@ -93,7 +97,7 @@ impl PassThrough { let app = axum::Router::new() .route("/msg", post(msg)) .route("/notifications", get(ws_handler)) - .route("/actions", get(actions).post(new_action)) + .route("/actions", get(actions) /*.post(new_action)*/) .route("/actions/{bridge_action_id}", get(action)) .route("/actions/{bridge_action_id}/wait", get(action_wait)) .layer(cors) @@ -160,10 +164,21 @@ async fn msg(State(state): State, Json(msg): Json) -> impl Int keys: keys.into_iter().map(|x| x.key).collect(), }, ExecuteMsg::Signed { - processor: _, - approvers: _, - payload: _, - } => todo!(), + processor, + approvers, + payload, + } => { + new_action( + &state, + msg.wallet, + Action { + processor, + approvers, + payload, + }, + ) + .await + } }; state.notify.send(message).unwrap(); let bridge_event_id = *guard; @@ -196,10 +211,7 @@ async fn handle_websocket(mut socket: WebSocket, mut rx: broadcast::Receiver, - Json(action): Json, -) -> impl IntoResponse { +async fn new_action(state: &PassThrough, wallet: String, action: Action) -> BridgeEventMessage { tracing::debug!("new action to pass-through bridge: {action:?}"); let Transfer { bridge_action_id, .. @@ -208,6 +220,10 @@ async fn new_action( let mut guard = state.actions.write().await; guard.insert(bridge_action_id, action); state.latest_action.send(Some(bridge_action_id)).ok(); + BridgeEventMessage::Signed { + wallet, + action_id: bridge_action_id, + } } async fn actions(State(state): State) -> impl IntoResponse {