Skip to content

Commit 1a722f6

Browse files
committed
Linting. Project restructure.
1 parent 8757982 commit 1a722f6

File tree

30 files changed

+81
-103
lines changed

30 files changed

+81
-103
lines changed

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[workspace]
22
resolver = "3"
33
members = [
4-
"nostr_options_cli",
54
"crates/*"
65
]
76

@@ -18,11 +17,10 @@ anyhow = { version = "1.0.100" }
1817
clap = { version = "4.5.49", features = ["derive"] }
1918
dirs = {version = "6.0.0"}
2019
futures-util = { version = "0.3.31" }
21-
global_utils = { path = "./crates/global_utils" }
20+
global-utils = { path = "crates/global-utils" }
2221
nostr = { version = "0.43.1", features = ["std"] }
2322
nostr-sdk = { version = "0.43.0" }
24-
nostr_relay_connector = { path = "./crates/nostr_relay_connector"}
25-
nostr_relay_processor = { path = "./crates/nostr_relay_processor"}
23+
dex-nostr-relay = { path = "./crates/dex-nostr-relay"}
2624
serde = { version = "1.0.228", features = ["derive"] }
2725
serde_json = { version = "1.0.145" }
2826
thiserror = { version = "2.0.17" }

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@ The core of our DEX is the **PACT (PACT for Auditable Contract Transactions)** p
2222

2323
A PACT offer is implemented as a standard NOSTR event with kind `30078` (non-standard, ephemeral event kind for DEX offers). The event structure maps to PACT requirements as follows:
2424

25-
| NOSTR Field | PACT Field | Data Type | Required | Description |
26-
|-------------|------------|-----------|----------|-------------|
27-
| `id` | Event ID | string (64-char hex) | Yes | SHA-256 hash of canonical serialized event data (excluding `sig`). Serves as unique, content-addressed identifier |
28-
| `pubkey` | Maker Key | string (64-char hex) | Yes | 32-byte x-only Schnorr public key of market maker. Must be registered in on-chain Maker Identity Registry |
29-
| `created_at` | Timestamp | integer | Yes | Unix timestamp (seconds) when offer was created |
30-
| `description` | Description | string | No | Human-readable description of instrument and complex terms |
31-
| `kind` | Event Type | integer | Yes | Event type identifier. Value `1` reserved for standard offers. Enables future protocol extensions |
32-
| `tags` | Metadata | array of arrays | Yes | Structured machine-readable metadata for filtering and discovery |
33-
| `content` | Contract Code | string | Yes | Stringified JSON containing full Simplicity contract code |
34-
| `sig` | Signature | string (128-char hex) | Yes | 64-byte Schnorr signature proving authenticity and integrity |
25+
| NOSTR Field | PACT Field | Data Type | Required | Description |
26+
|---------------|---------------|-----------------------|----------|-------------------------------------------------------------------------------------------------------------------|
27+
| `id` | Event ID | string (64-char hex) | Yes | SHA-256 hash of canonical serialized event data (excluding `sig`). Serves as unique, content-addressed identifier |
28+
| `pubkey` | Maker Key | string (64-char hex) | Yes | 32-byte x-only Schnorr public key of market maker. Must be registered in on-chain Maker Identity Registry |
29+
| `created_at` | Timestamp | integer | Yes | Unix timestamp (seconds) when offer was created |
30+
| `description` | Description | string | No | Human-readable description of instrument and complex terms |
31+
| `kind` | Event Type | integer | Yes | Event type identifier. Value `1` reserved for standard offers. Enables future protocol extensions |
32+
| `tags` | Metadata | array of arrays | Yes | Structured machine-readable metadata for filtering and discovery |
33+
| `content` | Contract Code | string | Yes | Stringified JSON containing full Simplicity contract code |
34+
| `sig` | Signature | string (128-char hex) | Yes | 64-byte Schnorr signature proving authenticity and integrity |
3535

3636
### Tag Examples
3737

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ edition = "2024"
66
[dependencies]
77
anyhow = { workspace = true }
88
nostr = { workspace = true }
9-
global_utils = { workspace = true }
9+
global-utils = { workspace = true }
1010
futures-util = { workspace = true }
1111
serde_json = { workspace = true }
1212
tokio = { workspace = true }
1313
clap = { workspace = true }
1414
dirs = { workspace = true }
1515
tracing = { workspace = true }
1616
thiserror = { workspace = true }
17-
nostr_relay_connector = { workspace = true }
18-
nostr_relay_processor = { workspace = true }
17+
dex-nostr-relay = { workspace = true }
1918

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use crate::utils::{
44
};
55
use clap::{Parser, Subcommand};
66
use nostr::{EventId, PublicKey};
7-
use nostr_relay_connector::relay_client::ClientConfig;
8-
use nostr_relay_processor::relay_processor::{OrderPlaceEventTags, OrderReplyEventTags, RelayProcessor};
7+
8+
use dex_nostr_relay::relay_client::ClientConfig;
9+
use dex_nostr_relay::relay_processor::{OrderPlaceEventTags, OrderReplyEventTags, RelayProcessor};
910
use std::path::PathBuf;
1011
use std::time::Duration;
1112
use tracing::instrument;

crates/dex-cli/src/error.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use crate::utils::FileError;
2+
use dex_nostr_relay::error::NostrRelayError;
3+
4+
pub type Result<T> = core::result::Result<T, CliError>;
5+
6+
#[derive(thiserror::Error, Debug)]
7+
pub enum CliError {
8+
#[error("Occurred error with io, err: {0}")]
9+
Io(#[from] std::io::Error),
10+
#[error(transparent)]
11+
File(#[from] FileError),
12+
#[error(transparent)]
13+
NostrRelay(#[from] NostrRelayError),
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use clap::Parser;
2+
23
use global_utils::logger::init_logger;
4+
35
use simplicity_dex::cli::Cli;
6+
47
use tracing::instrument;
58

69
#[tokio::main]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ pub fn write_into_stdout<T: AsRef<str> + std::fmt::Debug>(text: T) -> std::io::R
1616

1717
pub fn default_key_path() -> PathBuf {
1818
dirs::home_dir()
19-
.unwrap_or_else(|| PathBuf::from("."))
19+
.unwrap_or_else(|| PathBuf::from("../../.."))
2020
.join(DEFAULT_KEY_PATH)
2121
}
2222

2323
pub fn default_relays_path() -> PathBuf {
2424
dirs::home_dir()
25-
.unwrap_or_else(|| PathBuf::from("."))
25+
.unwrap_or_else(|| PathBuf::from("../../.."))
2626
.join(DEFAULT_RELAYS_FILEPATH)
2727
}
2828
#[derive(Debug, thiserror::Error)]
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "nostr_relay_processor"
2+
name = "dex-nostr-relay"
33
version.workspace = true
44
edition.workspace = true
55
rust-version.workspace = true
@@ -9,9 +9,8 @@ readme.workspace = true
99
[dependencies]
1010
anyhow = { workspace = true }
1111
tokio = { workspace = true }
12-
global_utils = { workspace = true }
12+
global-utils = { workspace = true }
1313
nostr-sdk = { workspace = true }
1414
nostr = { workspace = true }
15-
nostr_relay_connector = { workspace = true }
1615
tracing = { workspace = true }
1716
thiserror = { workspace = true }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
use nostr::SignerError;
2+
use nostr::filter::SingleLetterTagError;
3+
4+
#[derive(thiserror::Error, Debug)]
5+
pub enum NostrRelayError {
6+
#[error("Signer error: {0}")]
7+
Signer(#[from] SignerError),
8+
#[error("Single letter error: {0}")]
9+
SingleLetterTag(#[from] SingleLetterTagError),
10+
#[error("Failed to convert custom url to RelayURL, err: {err_msg}")]
11+
FailedToConvertRelayUrl { err_msg: String },
12+
#[error("An error occurred in Nostr Client, err: {0}")]
13+
NostrClientFailure(#[from] nostr_sdk::client::Error),
14+
#[error("Relay Client requires for operation signature, add key to the Client")]
15+
MissingSigner,
16+
}
17+
18+
pub type Result<T> = std::result::Result<T, NostrRelayError>;

0 commit comments

Comments
 (0)