upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/sub_commands/init.rs
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-06-25 09:06:47 +0100
committerDanConwayDev <DanConwayDev@protonmail.com>2024-06-25 09:06:47 +0100
commitb63bfc9a34657c5767c507deb7c059e24dd22779 (patch)
tree462be1e29e6f21c5e0d75458e4966f574389451c /src/sub_commands/init.rs
parent20d201740f0ace8437cf595476a52f9e42407724 (diff)
refactor: replace keys with signer
so that nip46 bunker signing can be added
Diffstat (limited to 'src/sub_commands/init.rs')
-rw-r--r--src/sub_commands/init.rs17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs
index 4d1bdfb..4afe83c 100644
--- a/src/sub_commands/init.rs
+++ b/src/sub_commands/init.rs
@@ -59,7 +59,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
59 #[cfg(test)] 59 #[cfg(test)]
60 let mut client = <MockConnect as std::default::Default>::default(); 60 let mut client = <MockConnect as std::default::Default>::default();
61 61
62 let (keys, user_ref) = login::launch( 62 let (signer, user_ref) = login::launch(
63 &git_repo, 63 &git_repo,
64 &cli_args.nsec, 64 &cli_args.nsec,
65 &cli_args.password, 65 &cli_args.password,
@@ -68,8 +68,6 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
68 ) 68 )
69 .await?; 69 .await?;
70 70
71 client.set_keys(&keys).await;
72
73 let repo_ref = if let Ok(rep_ref) = repo_ref::fetch( 71 let repo_ref = if let Ok(rep_ref) = repo_ref::fetch(
74 &git_repo, 72 &git_repo,
75 root_commit.to_string(), 73 root_commit.to_string(),
@@ -180,7 +178,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
180 let mut maintainers_string = if !args.other_maintainers.is_empty() { 178 let mut maintainers_string = if !args.other_maintainers.is_empty() {
181 [args.other_maintainers.clone()].concat().join(" ") 179 [args.other_maintainers.clone()].concat().join(" ")
182 } else if repo_ref.is_none() && repo_config_result.is_err() { 180 } else if repo_ref.is_none() && repo_config_result.is_err() {
183 keys.public_key().to_bech32()? 181 signer.public_key().await?.to_bech32()?
184 } else { 182 } else {
185 let maintainers = if let Ok(config) = &repo_config_result { 183 let maintainers = if let Ok(config) = &repo_config_result {
186 config.maintainers.clone() 184 config.maintainers.clone()
@@ -193,7 +191,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
193 .collect() 191 .collect()
194 } else { 192 } else {
195 //unreachable 193 //unreachable
196 vec![keys.public_key().to_bech32()?] 194 vec![signer.public_key().await?.to_bech32()?]
197 }; 195 };
198 // add current user if not present 196 // add current user if not present
199 if maintainers.iter().any(|m| { 197 if maintainers.iter().any(|m| {
@@ -205,7 +203,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
205 }) { 203 }) {
206 maintainers.join(" ") 204 maintainers.join(" ")
207 } else { 205 } else {
208 [maintainers, vec![keys.public_key().to_bech32()?]] 206 [maintainers, vec![signer.public_key().await?.to_bech32()?]]
209 .concat() 207 .concat()
210 .join(" ") 208 .join(" ")
211 } 209 }
@@ -231,7 +229,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
231 } 229 }
232 // add current user incase removed 230 // add current user incase removed
233 if !maintainers.iter().any(|m| user_ref.public_key.eq(m)) { 231 if !maintainers.iter().any(|m| user_ref.public_key.eq(m)) {
234 maintainers.push(keys.public_key()); 232 maintainers.push(signer.public_key().await?);
235 } 233 }
236 break maintainers; 234 break maintainers;
237 } 235 }
@@ -300,7 +298,10 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> {
300 relays: relays.clone(), 298 relays: relays.clone(),
301 maintainers: maintainers.clone(), 299 maintainers: maintainers.clone(),
302 } 300 }
303 .to_event(&keys)?; 301 .to_event(&signer)
302 .await?;
303
304 client.set_signer(signer).await;
304 305
305 send_events( 306 send_events(
306 &client, 307 &client,