Skip to content

Commit

Permalink
Search for ordinals in TSV using ord wallet identify (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph authored Oct 29, 2022
1 parent d330bda commit ea096e8
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 77 deletions.
2 changes: 1 addition & 1 deletion docs/src/bounty/3.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ To search an ordinal wallet for ordinals with a name in `frequency.tsv`, use
the following [`ord`](https://github.com/casey/ord) command:

```
ord wallet identify --names frequency.tsv
ord wallet identify --ordinals frequency.tsv
```

### Part 0
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use {
reqwest::Url,
serde::{Deserialize, Serialize},
std::{
cmp::Ordering,
collections::VecDeque,
env,
fmt::{self, Display, Formatter},
Expand Down
12 changes: 12 additions & 0 deletions src/ordinal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ impl PartialEq<u64> for Ordinal {
}
}

impl PartialOrd<u64> for Ordinal {
fn partial_cmp(&self, other: &u64) -> Option<Ordering> {
self.0.partial_cmp(other)
}
}

impl Add<u64> for Ordinal {
type Output = Self;

Expand Down Expand Up @@ -433,6 +439,12 @@ mod tests {
assert_eq!(Ordinal(1), 1);
}

#[test]
fn partial_ord() {
assert!(Ordinal(1) > 0);
assert!(Ordinal(0) < 1);
}

#[test]
fn add() {
assert_eq!(Ordinal(0) + 1, 1);
Expand Down
1 change: 0 additions & 1 deletion src/subcommand/epochs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ pub(crate) fn run() -> Result {
for ordinal in Epoch::STARTING_ORDINALS {
println!("{}", ordinal);
}

Ok(())
}
4 changes: 2 additions & 2 deletions src/subcommand/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ fn list_unspent(options: &Options, index: &Index) -> Result<Vec<(OutPoint, Vec<(

#[derive(Debug, Parser)]
pub(crate) enum Wallet {
Identify,
Identify(identify::Identify),
List,
Send(send::Send),
}

impl Wallet {
pub(crate) fn run(self, options: Options) -> Result {
match self {
Self::Identify => identify::run(options),
Self::Identify(identify) => identify.run(options),
Self::List => list::run(options),
Self::Send(send) => send.run(options),
}
Expand Down
Loading

0 comments on commit ea096e8

Please sign in to comment.