Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/kolme/src/core/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,7 @@ impl<App: KolmeApp> 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;
Expand All @@ -353,6 +350,10 @@ impl<App: KolmeApp> 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,
}))?;
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions packages/kolme/src/core/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
44 changes: 30 additions & 14 deletions packages/kolme/src/pass_through.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,18 @@ pub async fn execute(
approvals: &BTreeMap<PublicKey, SignatureWithRecovery>,
payload: &str,
) -> Result<String> {
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?;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -160,10 +164,21 @@ async fn msg(State(state): State<PassThrough>, Json(msg): Json<Msg>) -> 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;
Expand Down Expand Up @@ -196,10 +211,7 @@ async fn handle_websocket(mut socket: WebSocket, mut rx: broadcast::Receiver<Bri
}
}

async fn new_action(
State(state): State<PassThrough>,
Json(action): Json<Action>,
) -> 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, ..
Expand All @@ -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<PassThrough>) -> impl IntoResponse {
Expand Down
Loading