diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-04 07:04:03 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2025-11-04 07:04:03 +0000 |
| commit | 5f053c46622ab21275d5ec881fd509cc0808cf8f (patch) | |
| tree | 4936e9475a0af24a9e921e4cc59939ed0d1a84ed /grasp-audit/src/audit.rs | |
| parent | 31ed54dab458cb3c0a6472f3e508ccdc7a9b4d79 (diff) | |
Upgrade to nostr-sdk 0.43 (from 0.35)
Major upgrade of nostr-sdk dependency from 0.35 to 0.43 (8 minor versions).
All breaking API changes fixed, all tests passing.
Breaking Changes Fixed:
- EventBuilder::new() - Removed tags parameter, use .tags() method
- EventBuilder::to_event() → sign_with_keys() - Renamed signing method
- Client::new() - Takes ownership of keys (clone instead of reference)
- Relay::is_connected() - No longer async
- Client::get_events_of() → fetch_events() - Complete API redesign
- EventSource - Removed entirely
- Filter::custom_tag() - Takes single value instead of array
- Client::send_event() - Takes reference instead of ownership
- Multiple filters - Loop and combine instead of vec parameter
- Events type - New return type, convert with .into_iter().collect()
Files Modified:
- Cargo.toml: nostr-sdk = "0.43"
- src/audit.rs: EventBuilder API changes
- src/client.rs: Client, query, and filter API changes
- src/specs/nip01_smoke.rs: Event building changes
Documentation:
- NOSTR_SDK_0.43_UPGRADE.md: Comprehensive upgrade guide
- COMPILATION_FIXES.md: Marked as obsolete (0.35 fixes)
- SESSION_2025_11_04_SUMMARY.md: Session summary
- NEXT_SESSION_QUICKSTART.md: Updated status
Test Results:
✅ All 12 unit tests passing
✅ CLI builds successfully
✅ Examples build successfully
✅ Clean build with no warnings
Benefits:
- Latest stable nostr-sdk version
- Cleaner, more intuitive APIs
- Better performance (reference passing, sync operations)
- 8 versions of bug fixes and improvements
- Future compatibility
Diffstat (limited to 'grasp-audit/src/audit.rs')
| -rw-r--r-- | grasp-audit/src/audit.rs | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/grasp-audit/src/audit.rs b/grasp-audit/src/audit.rs index 0ca8737..9efb61a 100644 --- a/grasp-audit/src/audit.rs +++ b/grasp-audit/src/audit.rs | |||
| @@ -1,7 +1,6 @@ | |||
| 1 | //! Audit configuration and event tagging | 1 | //! Audit configuration and event tagging |
| 2 | 2 | ||
| 3 | use nostr_sdk::prelude::*; | 3 | use nostr_sdk::prelude::*; |
| 4 | use std::time::Duration; | ||
| 5 | 4 | ||
| 6 | /// Audit configuration | 5 | /// Audit configuration |
| 7 | #[derive(Debug, Clone)] | 6 | #[derive(Debug, Clone)] |
| @@ -113,13 +112,13 @@ impl AuditEventBuilder { | |||
| 113 | } | 112 | } |
| 114 | 113 | ||
| 115 | /// Build the event with audit tags | 114 | /// Build the event with audit tags |
| 116 | pub async fn build(self, keys: &Keys) -> anyhow::Result<Event> { | 115 | pub fn build(self, keys: &Keys) -> anyhow::Result<Event> { |
| 117 | let mut all_tags = self.tags; | 116 | let mut all_tags = self.tags; |
| 118 | all_tags.extend(self.config.audit_tags()); | 117 | all_tags.extend(self.config.audit_tags()); |
| 119 | 118 | ||
| 120 | let event = EventBuilder::new(self.kind, self.content, all_tags) | 119 | let event = EventBuilder::new(self.kind, self.content) |
| 121 | .to_event(keys) | 120 | .tags(all_tags) |
| 122 | .await?; | 121 | .sign_with_keys(keys)?; |
| 123 | 122 | ||
| 124 | Ok(event) | 123 | Ok(event) |
| 125 | } | 124 | } |
| @@ -168,15 +167,14 @@ mod tests { | |||
| 168 | })); | 167 | })); |
| 169 | } | 168 | } |
| 170 | 169 | ||
| 171 | #[tokio::test] | 170 | #[test] |
| 172 | async fn test_audit_event_builder() { | 171 | fn test_audit_event_builder() { |
| 173 | let config = AuditConfig::ci(); | 172 | let config = AuditConfig::ci(); |
| 174 | let keys = Keys::generate(); | 173 | let keys = Keys::generate(); |
| 175 | 174 | ||
| 176 | let event = AuditEventBuilder::new(Kind::TextNote, "test", config.clone()) | 175 | let event = AuditEventBuilder::new(Kind::TextNote, "test", config.clone()) |
| 177 | .tag(Tag::custom(TagKind::Custom("test".into()), vec!["value"])) | 176 | .tag(Tag::custom(TagKind::Custom("test".into()), vec!["value"])) |
| 178 | .build(&keys) | 177 | .build(&keys) |
| 179 | .await | ||
| 180 | .unwrap(); | 178 | .unwrap(); |
| 181 | 179 | ||
| 182 | // Should have our custom tag + 3 audit tags | 180 | // Should have our custom tag + 3 audit tags |