From b17f0969c36dcbc2696fe7a245ceff89c6d4e944 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sun, 26 Nov 2023 16:24:31 -0300 Subject: [PATCH 1/5] Don't show .element --- src/inscription.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/inscription.rs b/src/inscription.rs index d08a012840..1d2ded987c 100644 --- a/src/inscription.rs +++ b/src/inscription.rs @@ -346,6 +346,10 @@ impl Inscription { return true; } + if trimmed.ends_with(".element") { + return true; + } + false } } @@ -817,6 +821,7 @@ mod tests { case(Some("text/plain"), None, false); case(Some("text/plain"), Some("foo{}bar"), false); case(Some("text/plain"), Some("foo.btc"), true); + case(Some("text/plain"), Some("foo.element"), true); case(Some("text/plain"), Some("foo.bitmap"), true); case(Some("text/plain"), Some("gib bc1"), true); From fd873981f6ebf39be1f113b7ad003875c5fd5968 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Mon, 27 Nov 2023 18:41:10 -0300 Subject: [PATCH 2/5] Hide all domains --- src/inscription.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/inscription.rs b/src/inscription.rs index 1d2ded987c..2ec0f4e104 100644 --- a/src/inscription.rs +++ b/src/inscription.rs @@ -308,6 +308,10 @@ impl Inscription { } pub(crate) fn hidden(&self) -> bool { + lazy_static! { + static ref DOMAINS: Regex = Regex::new(r"\..*$").unwrap(); + } + let Some(content_type) = self.content_type() else { return false; }; @@ -338,15 +342,7 @@ impl Inscription { return true; } - if trimmed.ends_with(".bitmap") { - return true; - } - - if trimmed.ends_with(".btc") { - return true; - } - - if trimmed.ends_with(".element") { + if DOMAINS.is_match(trimmed) { return true; } From b2c36122c9eb510b1bc4d167e2d49794aa84126f Mon Sep 17 00:00:00 2001 From: raphjaph Date: Mon, 27 Nov 2023 18:50:51 -0300 Subject: [PATCH 3/5] hide all text --- src/inscription.rs | 50 ++++++++-------------------------------------- 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/src/inscription.rs b/src/inscription.rs index 2ec0f4e104..624a08458b 100644 --- a/src/inscription.rs +++ b/src/inscription.rs @@ -308,41 +308,15 @@ impl Inscription { } pub(crate) fn hidden(&self) -> bool { - lazy_static! { - static ref DOMAINS: Regex = Regex::new(r"\..*$").unwrap(); - } - let Some(content_type) = self.content_type() else { - return false; - }; - - if content_type.starts_with("application/json") { return true; - } - - if !content_type.starts_with("text/plain") { - return false; - } - - let Some(body) = &self.body else { - return false; }; - let Ok(text) = str::from_utf8(body) else { - return false; - }; - - let trimmed = text.trim(); - - if trimmed.starts_with('{') && trimmed.ends_with('}') { - return true; - } - - if trimmed.starts_with("gib bc1") { + if content_type.starts_with("application/json") { return true; } - if DOMAINS.is_match(trimmed) { + if content_type.starts_with("text/plain") { return true; } @@ -811,23 +785,15 @@ mod tests { ); } - case(None, None, false); + case(None, None, true); case(Some("foo"), None, false); - case(Some("foo"), Some("{}"), false); - case(Some("text/plain"), None, false); - case(Some("text/plain"), Some("foo{}bar"), false); - case(Some("text/plain"), Some("foo.btc"), true); - case(Some("text/plain"), Some("foo.element"), true); - - case(Some("text/plain"), Some("foo.bitmap"), true); - case(Some("text/plain"), Some("gib bc1"), true); - case(Some("text/plain"), Some("{}"), true); - case(Some("text/plain"), Some(" {} "), true); - case(Some("text/plain;charset=utf-8"), Some("foo.bitmap"), true); - case(Some("text/plain;charset=cn-big5"), Some("foo.bitmap"), true); + case(Some("text/plain"), None, true); + case(Some("text/plain"), Some("The fox jumped. The cow danced."), true); + case(Some("text/plain;charset=utf-8"), Some("foo"), true); + case(Some("text/plain;charset=cn-big5"), Some("foo"), true); case(Some("application/json"), Some("foo"), true); - assert!(!Inscription { + assert!(Inscription { content_type: Some("text/plain".as_bytes().into()), body: Some(b"{\xc3\x28}".as_slice().into()), ..Default::default() From 54c7be8248c950ba2aa118099c05171e0f5ad89e Mon Sep 17 00:00:00 2001 From: raphjaph Date: Mon, 27 Nov 2023 18:52:13 -0300 Subject: [PATCH 4/5] quick fix --- src/inscription.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/inscription.rs b/src/inscription.rs index 624a08458b..89f503130e 100644 --- a/src/inscription.rs +++ b/src/inscription.rs @@ -788,7 +788,11 @@ mod tests { case(None, None, true); case(Some("foo"), None, false); case(Some("text/plain"), None, true); - case(Some("text/plain"), Some("The fox jumped. The cow danced."), true); + case( + Some("text/plain"), + Some("The fox jumped. The cow danced."), + true, + ); case(Some("text/plain;charset=utf-8"), Some("foo"), true); case(Some("text/plain;charset=cn-big5"), Some("foo"), true); case(Some("application/json"), Some("foo"), true); From 73a9407eaef2f5c8d4d07bb85304912e44c6a43c Mon Sep 17 00:00:00 2001 From: raphjaph Date: Mon, 27 Nov 2023 18:54:44 -0300 Subject: [PATCH 5/5] quick fix --- src/subcommand/server.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 3dc06980f2..22a74ac15c 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2796,7 +2796,7 @@ mod tests { for i in 0..101 { let txid = server.bitcoin_rpc_server.broadcast_tx(TransactionTemplate { - inputs: &[(i + 1, 0, 0, inscription("text/plain", "hello").to_witness())], + inputs: &[(i + 1, 0, 0, inscription("foo", "hello").to_witness())], ..Default::default() }); ids.push(InscriptionId { txid, index: 0 });