-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
662 additions
and
225 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use super::*; | ||
|
||
#[derive(Debug, Serialize, Deserialize)] | ||
pub(crate) struct Rune { | ||
pub(crate) name: String, | ||
pub(crate) network: Network, | ||
pub(crate) ordinal: Ordinal, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use super::*; | ||
|
||
mod publish; | ||
|
||
#[derive(Debug, Parser)] | ||
pub(crate) enum Rune { | ||
Publish(publish::Publish), | ||
} | ||
|
||
impl Rune { | ||
pub(crate) fn run(self, options: Options) -> Result<()> { | ||
match self { | ||
Self::Publish(publish) => publish.run(options), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
use {super::*, reqwest::Url}; | ||
|
||
#[derive(Debug, Parser)] | ||
pub(crate) struct Publish { | ||
#[clap(long, help = "Give rune <NAME>.")] | ||
name: String, | ||
#[clap(long, help = "Inscribe rune on <ORDINAL>.")] | ||
ordinal: Ordinal, | ||
#[clap( | ||
long, | ||
default_value = "https://ordinals.com/", | ||
help = "Publish rune to <PUBLISH_URL>." | ||
)] | ||
publish_url: Url, | ||
} | ||
|
||
impl Publish { | ||
pub(crate) fn run(self, options: Options) -> Result { | ||
options.bitcoin_rpc_client_mainnet_forbidden("ord rune publish")?; | ||
|
||
let rune = crate::Rune { | ||
network: options.chain.network(), | ||
name: self.name, | ||
ordinal: self.ordinal, | ||
}; | ||
|
||
let json = serde_json::to_string(&rune)?; | ||
|
||
let url = self.publish_url.join("rune")?; | ||
|
||
let response = reqwest::blocking::Client::new() | ||
.put(url.clone()) | ||
.header( | ||
reqwest::header::CONTENT_TYPE, | ||
mime::APPLICATION_JSON.as_ref(), | ||
) | ||
.body(json) | ||
.send()?; | ||
|
||
let status = response.status(); | ||
|
||
if !status.is_success() { | ||
bail!("Failed to post rune to `{}`:\n{}", url, response.text()?) | ||
} | ||
|
||
eprintln!("Rune published: {}", response.status()); | ||
println!("{}", response.text()?); | ||
|
||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.