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.
#[allow(clippy::too_many_arguments)]
async fn announce_repository_and_push(
async fn announce_repository_and_push<S>(
client: &Client,
signer: &UniversalSigner,
signer: &S,
announcement: GitRepositoryAnnouncement,
repo_id: &str,
owner: &str,
@@ -1201,7 +1201,10 @@ async fn announce_repository_and_push(
path: &Path,
cx: &mut AsyncApp,
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 {
if let Err(e) = client.add_relay(url).and_connect().await {
log::warn!("failed to connect grasp relay {url}: {e}");
@@ -1227,7 +1230,7 @@ async fn announce_repository_and_push(
} else {
let push = {
let client = client.clone();
let signer = signer.clone();
let signer = S::clone(signer);
let repo_id = repo_id.to_owned();
let owner = owner.to_owned();
let servers = servers.to_vec();
+6 -4
View File
@@ -4,7 +4,6 @@ use anyhow::Error;
use nostr::prelude::Url;
use nostr_sdk::prelude::*;
use signed_core::RepoState;
use signed_nostr::UniversalSigner;
/// `ws://` grasp servers, like ngit, use `http(s)://<host>`.
pub(crate) fn grasp_base_url(relay: &RelayUrl) -> Option<String> {
@@ -130,9 +129,9 @@ impl PushOutcome {
}
#[allow(clippy::too_many_arguments)]
pub(crate) async fn push_staged_to_grasps(
pub(crate) async fn push_staged_to_grasps<S>(
client: &Client,
signer: &UniversalSigner,
signer: &S,
repo_id: &str,
refs: &[(String, String)],
head: Option<&str>,
@@ -140,7 +139,10 @@ pub(crate) async fn push_staged_to_grasps(
owner: &str,
servers: &[RelayUrl],
push: impl Fn(&Path, &str, &str, &str) -> Result<(), Error>,
) -> PushOutcome {
) -> PushOutcome
where
S: AsyncGetPublicKey + AsyncSignEvent + ?Sized,
{
let mut outcome = PushOutcome::default();
for relay in servers {
+6 -4
View File
@@ -12,7 +12,6 @@ use signed_core::{
filters,
};
use signed_git::{Nip34Binding, Repo};
use signed_nostr::UniversalSigner;
use crate::backend::{Backend, BackendEvent};
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.
#[allow(clippy::too_many_arguments)]
async fn publish_patch_series(
async fn publish_patch_series<S>(
client: &Client,
signer: &UniversalSigner,
signer: &S,
addr: &RepoAddr,
owner: PublicKey,
euc: Option<&str>,
series: &PatchSeries,
first_marker: &str,
reply_to: Option<EventId>,
) -> Result<Event, Error> {
) -> Result<Event, Error>
where
S: AsyncGetPublicKey + AsyncSignEvent + ?Sized,
{
let mut root: Option<Event> = None;
let mut previous = reply_to;