Make signing functions generic over the signer trait
Rust / build (macos-latest, stable) (push) Canceled after 0s
Rust / build (ubuntu-latest, stable) (push) Canceled after 0s
Rust / build (windows-latest, stable) (push) Canceled after 0s
Rust / build (macos-latest, stable) (pull_request) Canceled after 0s
Rust / build (ubuntu-latest, stable) (pull_request) Canceled after 0s
Rust / build (windows-latest, stable) (pull_request) Canceled after 0s

This commit is contained in:
2026-10-13 10:41:44 +07:00
parent 3c307691aa
commit 56d3924e46
3 changed files with 19 additions and 12 deletions
+7 -4
View File
@@ -1189,9 +1189,9 @@ fn build_announcement(
// Announce the repository, then stage the state event and push. // Announce the repository, then stage the state event and push.
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
async fn announce_repository_and_push( async fn announce_repository_and_push<S>(
client: &Client, client: &Client,
signer: &UniversalSigner, signer: &S,
announcement: GitRepositoryAnnouncement, announcement: GitRepositoryAnnouncement,
repo_id: &str, repo_id: &str,
owner: &str, owner: &str,
@@ -1201,7 +1201,10 @@ async fn announce_repository_and_push(
path: &Path, path: &Path,
cx: &mut AsyncApp, cx: &mut AsyncApp,
push: impl Fn(&Path, &str, &str, &str) -> Result<(), Error> + Send + 'static, push: impl Fn(&Path, &str, &str, &str) -> Result<(), Error> + Send + 'static,
) -> Result<Event, Error> { ) -> Result<Event, Error>
where
S: AsyncGetPublicKey + AsyncSignEvent + Clone,
{
for url in servers { for url in servers {
if let Err(e) = client.add_relay(url).and_connect().await { if let Err(e) = client.add_relay(url).and_connect().await {
log::warn!("failed to connect grasp relay {url}: {e}"); log::warn!("failed to connect grasp relay {url}: {e}");
@@ -1227,7 +1230,7 @@ async fn announce_repository_and_push(
} else { } else {
let push = { let push = {
let client = client.clone(); let client = client.clone();
let signer = signer.clone(); let signer = S::clone(signer);
let repo_id = repo_id.to_owned(); let repo_id = repo_id.to_owned();
let owner = owner.to_owned(); let owner = owner.to_owned();
let servers = servers.to_vec(); let servers = servers.to_vec();
+6 -4
View File
@@ -4,7 +4,6 @@ use anyhow::Error;
use nostr::prelude::Url; use nostr::prelude::Url;
use nostr_sdk::prelude::*; use nostr_sdk::prelude::*;
use signed_core::RepoState; use signed_core::RepoState;
use signed_nostr::UniversalSigner;
/// `ws://` grasp servers, like ngit, use `http(s)://<host>`. /// `ws://` grasp servers, like ngit, use `http(s)://<host>`.
pub(crate) fn grasp_base_url(relay: &RelayUrl) -> Option<String> { pub(crate) fn grasp_base_url(relay: &RelayUrl) -> Option<String> {
@@ -130,9 +129,9 @@ impl PushOutcome {
} }
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub(crate) async fn push_staged_to_grasps( pub(crate) async fn push_staged_to_grasps<S>(
client: &Client, client: &Client,
signer: &UniversalSigner, signer: &S,
repo_id: &str, repo_id: &str,
refs: &[(String, String)], refs: &[(String, String)],
head: Option<&str>, head: Option<&str>,
@@ -140,7 +139,10 @@ pub(crate) async fn push_staged_to_grasps(
owner: &str, owner: &str,
servers: &[RelayUrl], servers: &[RelayUrl],
push: impl Fn(&Path, &str, &str, &str) -> Result<(), Error>, push: impl Fn(&Path, &str, &str, &str) -> Result<(), Error>,
) -> PushOutcome { ) -> PushOutcome
where
S: AsyncGetPublicKey + AsyncSignEvent + ?Sized,
{
let mut outcome = PushOutcome::default(); let mut outcome = PushOutcome::default();
for relay in servers { for relay in servers {
+6 -4
View File
@@ -12,7 +12,6 @@ use signed_core::{
filters, filters,
}; };
use signed_git::{Nip34Binding, Repo}; use signed_git::{Nip34Binding, Repo};
use signed_nostr::UniversalSigner;
use crate::backend::{Backend, BackendEvent}; use crate::backend::{Backend, BackendEvent};
use crate::bootstrap::user_grasp_list_servers; use crate::bootstrap::user_grasp_list_servers;
@@ -1401,16 +1400,19 @@ fn resolve_statuses(
/// Publish a patch series as a sequence of `git/patch` events. /// Publish a patch series as a sequence of `git/patch` events.
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
async fn publish_patch_series( async fn publish_patch_series<S>(
client: &Client, client: &Client,
signer: &UniversalSigner, signer: &S,
addr: &RepoAddr, addr: &RepoAddr,
owner: PublicKey, owner: PublicKey,
euc: Option<&str>, euc: Option<&str>,
series: &PatchSeries, series: &PatchSeries,
first_marker: &str, first_marker: &str,
reply_to: Option<EventId>, reply_to: Option<EventId>,
) -> Result<Event, Error> { ) -> Result<Event, Error>
where
S: AsyncGetPublicKey + AsyncSignEvent + ?Sized,
{
let mut root: Option<Event> = None; let mut root: Option<Event> = None;
let mut previous = reply_to; let mut previous = reply_to;