From 9600d1d29b89495bbd27797c9fd885b2312acfe7 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 5 Apr 2024 03:04:51 -0400 Subject: [PATCH 1/5] Add turbo flag --- batch.yaml | 1 + crates/ordinals/src/etching.rs | 1 + crates/ordinals/src/runestone.rs | 34 +++++++++------ crates/ordinals/src/runestone/flag.rs | 1 + src/index.rs | 1 + src/index/entry.rs | 8 ++++ src/index/updater/rune_updater.rs | 3 ++ src/runes.rs | 3 ++ src/subcommand/runes.rs | 3 ++ src/subcommand/server.rs | 4 ++ src/templates/rune.rs | 62 +++++++++++++++++++++++++++ src/wallet/batch/etching.rs | 3 +- src/wallet/batch/file.rs | 3 +- src/wallet/batch/plan.rs | 1 + templates/rune.html | 2 + tests/json_api.rs | 4 ++ tests/runes.rs | 3 ++ 17 files changed, 123 insertions(+), 14 deletions(-) diff --git a/batch.yaml b/batch.yaml index 707d2ef76b..5666497d84 100644 --- a/batch.yaml +++ b/batch.yaml @@ -45,6 +45,7 @@ etching: offset: start: 1000 end: 9000 + turbo: true, # inscriptions to inscribe inscriptions: diff --git a/crates/ordinals/src/etching.rs b/crates/ordinals/src/etching.rs index eab0421848..773486ac6b 100644 --- a/crates/ordinals/src/etching.rs +++ b/crates/ordinals/src/etching.rs @@ -8,6 +8,7 @@ pub struct Etching { pub spacers: Option, pub symbol: Option, pub terms: Option, + pub turbo: bool, } impl Etching { diff --git a/crates/ordinals/src/runestone.rs b/crates/ordinals/src/runestone.rs index 1d10339f73..feb85dd08d 100644 --- a/crates/ordinals/src/runestone.rs +++ b/crates/ordinals/src/runestone.rs @@ -83,6 +83,7 @@ impl Runestone { Tag::OffsetEnd.take(&mut fields, |[end_offset]| u64::try_from(end_offset).ok()), ), }), + turbo: Flag::Turbo.take(&mut flags), }); let mint = Tag::Mint.take(&mut fields, |[block, tx]| { @@ -136,6 +137,10 @@ impl Runestone { Flag::Terms.set(&mut flags); } + if etching.turbo { + Flag::Turbo.set(&mut flags); + } + Tag::Flags.encode([flags], &mut payload); Tag::Rune.encode_option(etching.rune.map(|rune| rune.0), &mut payload); @@ -1074,7 +1079,7 @@ mod tests { assert_eq!( decipher(&[ Tag::Flags.into(), - Flag::Etching.mask() | Flag::Terms.mask(), + Flag::Etching.mask() | Flag::Terms.mask() | Flag::Turbo.mask(), Tag::Rune.into(), 4, Tag::Divisibility.into(), @@ -1110,17 +1115,18 @@ mod tests { output: 0, }], etching: Some(Etching { + divisibility: Some(1), + premine: Some(8), rune: Some(Rune(4)), + spacers: Some(5), + symbol: Some('a'), terms: Some(Terms { cap: Some(9), offset: (None, Some(2)), amount: Some(3), height: (None, None), }), - premine: Some(8), - divisibility: Some(1), - symbol: Some('a'), - spacers: Some(5), + turbo: true, }), pointer: Some(0), mint: Some(RuneId::new(1, 1).unwrap()), @@ -1433,6 +1439,7 @@ mod tests { offset: (Some(u32::MAX.into()), Some(u32::MAX.into())), height: (Some(u32::MAX.into()), Some(u32::MAX.into())), }), + turbo: true, premine: Some(u64::MAX.into()), rune: Some(Rune(u128::MAX)), symbol: Some('\u{10FFFF}'), @@ -1704,13 +1711,14 @@ mod tests { amount: Some(14), offset: (Some(15), Some(16)), }), + turbo: true, }), mint: Some(RuneId::new(17, 18).unwrap()), pointer: Some(0), }, &[ Tag::Flags.into(), - Flag::Etching.mask() | Flag::Terms.mask(), + Flag::Etching.mask() | Flag::Terms.mask() | Flag::Turbo.mask(), Tag::Rune.into(), 9, Tag::Divisibility.into(), @@ -1754,12 +1762,13 @@ mod tests { case( Runestone { etching: Some(Etching { - premine: None, divisibility: None, - terms: None, - symbol: None, + premine: None, rune: Some(Rune(3)), spacers: None, + symbol: None, + terms: None, + turbo: false, }), ..default() }, @@ -1769,12 +1778,13 @@ mod tests { case( Runestone { etching: Some(Etching { - premine: None, divisibility: None, - terms: None, - symbol: None, + premine: None, rune: None, spacers: None, + symbol: None, + terms: None, + turbo: false, }), ..default() }, diff --git a/crates/ordinals/src/runestone/flag.rs b/crates/ordinals/src/runestone/flag.rs index 06cf463054..66b2d60dc9 100644 --- a/crates/ordinals/src/runestone/flag.rs +++ b/crates/ordinals/src/runestone/flag.rs @@ -1,6 +1,7 @@ pub(super) enum Flag { Etching = 0, Terms = 1, + Turbo = 2, #[allow(unused)] Cenotaph = 127, } diff --git a/src/index.rs b/src/index.rs index 0ce7f33203..c872d17eab 100644 --- a/src/index.rs +++ b/src/index.rs @@ -386,6 +386,7 @@ impl Index { spaced_rune: SpacedRune { rune, spacers: 128 }, symbol: Some('\u{29C9}'), timestamp: 0, + turbo: true, } .store(), )?; diff --git a/src/index/entry.rs b/src/index/entry.rs index f3cae51f22..faa3d2343a 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -53,6 +53,7 @@ pub struct RuneEntry { pub symbol: Option, pub terms: Option, pub timestamp: u64, + pub turbo: bool, } impl RuneEntry { @@ -153,6 +154,7 @@ pub(super) type RuneEntryValue = ( Option, // symbol Option, // terms u64, // timestamp + bool, // turbo ); impl Default for RuneEntry { @@ -169,6 +171,7 @@ impl Default for RuneEntry { symbol: None, terms: None, timestamp: 0, + turbo: false, } } } @@ -189,6 +192,7 @@ impl Entry for RuneEntry { symbol, terms, timestamp, + turbo, ): RuneEntryValue, ) -> Self { Self { @@ -220,6 +224,7 @@ impl Entry for RuneEntry { offset, }), timestamp, + turbo, } } @@ -255,6 +260,7 @@ impl Entry for RuneEntry { }| (cap, height, amount, offset), ), self.timestamp, + self.turbo, ) } } @@ -572,6 +578,7 @@ mod tests { }, symbol: Some('a'), timestamp: 10, + turbo: true, }; let value = ( @@ -589,6 +596,7 @@ mod tests { Some('a'), Some((Some(1), (Some(2), Some(3)), Some(4), (Some(5), Some(6)))), 10, + true, ); assert_eq!(entry.store(), value); diff --git a/src/index/updater/rune_updater.rs b/src/index/updater/rune_updater.rs index ab5bcedcfb..6aa509dd4a 100644 --- a/src/index/updater/rune_updater.rs +++ b/src/index/updater/rune_updater.rs @@ -243,6 +243,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> { spaced_rune: SpacedRune { rune, spacers: 0 }, symbol: None, timestamp: self.block_time.into(), + turbo: false, }, Artifact::Runestone(Runestone { etching, .. }) => { let Etching { @@ -251,6 +252,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> { premine, spacers, symbol, + turbo, .. } = etching.unwrap(); @@ -269,6 +271,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> { }, symbol, timestamp: self.block_time.into(), + turbo, } } }; diff --git a/src/runes.rs b/src/runes.rs index 1e22229c06..0117dbc5fc 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -843,6 +843,7 @@ mod tests { divisibility: Some(1), symbol: Some('$'), spacers: Some(1), + turbo: true, }), pointer: Some(10), ..default() @@ -868,6 +869,7 @@ mod tests { }, symbol: None, timestamp: id.block, + turbo: false, }, )], [], @@ -5486,6 +5488,7 @@ mod tests { offset: (None, None), }), timestamp: 0, + turbo: true, }, )], [], diff --git a/src/subcommand/runes.rs b/src/subcommand/runes.rs index 645cce331c..0ec292f75d 100644 --- a/src/subcommand/runes.rs +++ b/src/subcommand/runes.rs @@ -20,6 +20,7 @@ pub struct RuneInfo { pub symbol: Option, pub terms: Option, pub timestamp: DateTime, + pub turbo: bool, pub tx: u32, } @@ -52,6 +53,7 @@ pub(crate) fn run(settings: Settings) -> SubcommandResult { symbol, terms, timestamp, + turbo, }, )| { ( @@ -70,6 +72,7 @@ pub(crate) fn run(settings: Settings) -> SubcommandResult { symbol, terms, timestamp: crate::timestamp(timestamp), + turbo, tx: id.tx, }, ) diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 6dcd1af2d0..6d5e82735d 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2715,6 +2715,7 @@ mod tests { rune: Some(rune), symbol: Some('%'), premine: Some(u128::MAX), + turbo: true, ..default() }), ..default() @@ -2742,6 +2743,7 @@ mod tests { premine: u128::MAX, symbol: Some('%'), timestamp: id.block, + turbo: true, ..default() } )] @@ -2782,6 +2784,8 @@ mod tests {
0
symbol
%
+
turbo
+
yes
etching
{txid}
parent
diff --git a/src/templates/rune.rs b/src/templates/rune.rs index e772ff83f1..79fe2433e0 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -1,5 +1,28 @@ use super::*; +enum Foo { + No, + Yes, +} + +impl From for Foo { + fn from(b: bool) -> Self { + match b { + false => Self::No, + true => Self::Yes, + } + } +} + +impl Display for Foo { + fn fmt(&self, f: &mut Formatter) -> fmt::Result { + match self { + Self::No => write!(f, "no"), + Self::Yes => write!(f, "yes"), + } + } +} + #[derive(Boilerplate, Debug, PartialEq, Serialize, Deserialize)] pub struct RuneHtml { pub entry: RuneEntry, @@ -42,6 +65,7 @@ mod tests { }, symbol: Some('%'), timestamp: 0, + turbo: true, }, id: RuneId { block: 10, tx: 9 }, mintable: true, @@ -92,6 +116,8 @@ mod tests {
9
symbol
%
+
turbo
+
yes
etching
0{64}
parent
@@ -120,6 +146,7 @@ mod tests { }, symbol: Some('%'), timestamp: 0, + turbo: false, }, id: RuneId { block: 10, tx: 9 }, mintable: false, @@ -134,6 +161,40 @@ mod tests { ); } + #[test] + fn display_no_turbo() { + assert_regex_match!( + RuneHtml { + entry: RuneEntry { + block: 0, + burned: 123456789123456789, + terms: None, + divisibility: 9, + etching: Txid::all_zeros(), + mints: 0, + number: 25, + premine: 0, + spaced_rune: SpacedRune { + rune: Rune(u128::MAX), + spacers: 1 + }, + symbol: Some('%'), + timestamp: 0, + turbo: false, + }, + id: RuneId { block: 10, tx: 9 }, + mintable: false, + parent: None, + }, + "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

+
.* +
turbo
+
no
+.*
+" + ); + } + #[test] fn display_empty_mint() { assert_regex_match!( @@ -158,6 +219,7 @@ mod tests { }, symbol: Some('%'), timestamp: 0, + turbo: false, }, id: RuneId { block: 10, tx: 9 }, mintable: false, diff --git a/src/wallet/batch/etching.rs b/src/wallet/batch/etching.rs index 700e90eaf9..8b8e8db339 100644 --- a/src/wallet/batch/etching.rs +++ b/src/wallet/batch/etching.rs @@ -8,5 +8,6 @@ pub struct Etching { pub rune: SpacedRune, pub supply: Decimal, pub symbol: char, - pub terms: Option, + pub terms: Option, + pub turbo: bool, } diff --git a/src/wallet/batch/file.rs b/src/wallet/batch/file.rs index efec3c2eb0..d5d1eada17 100644 --- a/src/wallet/batch/file.rs +++ b/src/wallet/batch/file.rs @@ -9,7 +9,7 @@ pub struct File { pub postage: Option, #[serde(default)] pub reinscribe: bool, - pub etching: Option, + pub etching: Option, pub sat: Option, pub satpoint: Option, } @@ -393,6 +393,7 @@ inscriptions: end: Some(9000), }), }), + turbo: true, }), inscriptions: vec![ batch::Entry { diff --git a/src/wallet/batch/plan.rs b/src/wallet/batch/plan.rs index a8e7040a65..44f02d3faf 100644 --- a/src/wallet/batch/plan.rs +++ b/src/wallet/batch/plan.rs @@ -463,6 +463,7 @@ impl Plan { }) }) .transpose()?, + turbo: false, premine: (premine > 0).then_some(premine), rune: Some(etching.rune.rune), spacers: (etching.rune.spacers > 0).then_some(etching.rune.spacers), diff --git a/templates/rune.html b/templates/rune.html index 19e6d72498..0c5d4d33db 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -62,6 +62,8 @@

{{ self.entry.spaced_rune }}

symbol
{{ symbol }}
%% } +
turbo
+
{{ Foo::from(self.entry.turbo) }}
etching
{{ self.entry.etching }}
%% if let Some(parent) = self.parent { diff --git a/tests/json_api.rs b/tests/json_api.rs index 361ba19e8f..210d3c4164 100644 --- a/tests/json_api.rs +++ b/tests/json_api.rs @@ -546,6 +546,7 @@ fn get_runes() { }, symbol: Some('¢'), timestamp: 11, + turbo: false, }, id: RuneId { block: 11, tx: 1 }, mintable: false, @@ -583,6 +584,7 @@ fn get_runes() { }, symbol: Some('¢'), timestamp: 11, + turbo: false, } ), ( @@ -602,6 +604,7 @@ fn get_runes() { }, symbol: Some('¢'), timestamp: 19, + turbo: false, } ), ( @@ -621,6 +624,7 @@ fn get_runes() { }, symbol: Some('¢'), timestamp: 27, + turbo: false, } ) ] diff --git a/tests/runes.rs b/tests/runes.rs index 7e9810143f..c7ed56ea08 100644 --- a/tests/runes.rs +++ b/tests/runes.rs @@ -62,6 +62,7 @@ fn one_rune() { supply: 1000, symbol: Some('¢'), timestamp: ord::timestamp(8), + turbo: false, tx: 1, } )] @@ -107,6 +108,7 @@ fn two_runes() { supply: 1000, symbol: Some('¢'), timestamp: ord::timestamp(8), + turbo: false, tx: 1, } ), @@ -129,6 +131,7 @@ fn two_runes() { supply: 1000, symbol: Some('¢'), timestamp: ord::timestamp(16), + turbo: false, tx: 1, } ) From 5a676edbb1a5e0b9e26526f4ee42cd38f833a0ff Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 10 Apr 2024 17:13:53 -0700 Subject: [PATCH 2/5] Fix bugs --- tests/lib.rs | 2 ++ tests/wallet/balance.rs | 1 + tests/wallet/batch_command.rs | 21 +++++++++++++++++++++ tests/wallet/mint.rs | 3 +++ tests/wallet/selection.rs | 1 + tests/wallet/send.rs | 1 + 6 files changed, 29 insertions(+) diff --git a/tests/lib.rs b/tests/lib.rs index 597856abba..654fbb2cfe 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -166,6 +166,7 @@ fn etch(core: &mockcore::Handle, ord: &TestServer, rune: Rune) -> Etched { premine: "1000".parse().unwrap(), rune: SpacedRune { rune, spacers: 0 }, symbol: '¢', + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -225,6 +226,7 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E supply, symbol, terms, + turbo, } = batchfile.etching.unwrap(); { diff --git a/tests/wallet/balance.rs b/tests/wallet/balance.rs index e84184882b..1d9d839cdc 100644 --- a/tests/wallet/balance.rs +++ b/tests/wallet/balance.rs @@ -108,6 +108,7 @@ fn runic_utxos_are_deducted_from_cardinal() { supply: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), diff --git a/tests/wallet/batch_command.rs b/tests/wallet/batch_command.rs index e756078f80..74d65a5a6c 100644 --- a/tests/wallet/batch_command.rs +++ b/tests/wallet/batch_command.rs @@ -1437,6 +1437,7 @@ fn batch_can_etch_rune() { premine: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -1553,6 +1554,7 @@ fn batch_can_etch_rune_without_premine() { height: None, offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -1638,6 +1640,7 @@ fn batch_inscribe_can_etch_rune_with_offset() { }), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -1711,6 +1714,7 @@ fn batch_inscribe_can_etch_rune_with_height() { }), offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -1777,6 +1781,7 @@ fn etch_existing_rune_error() { premine: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -1818,6 +1823,7 @@ fn etch_reserved_rune_error() { supply: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -1859,6 +1865,7 @@ fn etch_sub_minimum_rune_error() { premine: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -1900,6 +1907,7 @@ fn etch_requires_rune_index() { premine: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -1941,6 +1949,7 @@ fn etch_divisibility_over_maximum_error() { premine: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -1990,6 +1999,7 @@ fn etch_mintable_overflow_error() { amount: "340282366920938463463374607431768211455".parse().unwrap(), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2039,6 +2049,7 @@ fn etch_mintable_plus_premine_overflow_error() { amount: "340282366920938463463374607431768211455".parse().unwrap(), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2088,6 +2099,7 @@ fn incorrect_supply_error() { amount: "1".parse().unwrap(), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2137,6 +2149,7 @@ fn zero_offset_interval_error() { amount: "1".parse().unwrap(), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2186,6 +2199,7 @@ fn zero_height_interval_error() { amount: "1".parse().unwrap(), offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2235,6 +2249,7 @@ fn invalid_start_height_error() { amount: "1".parse().unwrap(), offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2286,6 +2301,7 @@ fn invalid_end_height_error() { amount: "1".parse().unwrap(), offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2329,6 +2345,7 @@ fn zero_supply_error() { premine: "0".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2375,6 +2392,7 @@ fn zero_cap_error() { amount: "1".parse().unwrap(), offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2421,6 +2439,7 @@ fn zero_amount_error() { amount: "0".parse().unwrap(), offset: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2473,6 +2492,7 @@ fn oversize_runestone_error() { }), amount: "1".parse().unwrap(), }), + turbo: true, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), @@ -2527,6 +2547,7 @@ fn oversize_runestones_are_allowed_with_no_limit() { }), amount: "1".parse().unwrap(), }), + turbo: true, }), inscriptions: vec![batch::Entry { file: Some("inscription.txt".into()), diff --git a/tests/wallet/mint.rs b/tests/wallet/mint.rs index c829ef13e3..9ffb6f8726 100644 --- a/tests/wallet/mint.rs +++ b/tests/wallet/mint.rs @@ -32,6 +32,7 @@ fn minting_rune_and_fails_if_after_end() { amount: "111.1".parse().unwrap(), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -120,6 +121,7 @@ fn minting_rune_fails_if_not_mintable() { premine: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), @@ -193,6 +195,7 @@ fn minting_rune_and_then_sending_works() { amount: "21".parse().unwrap(), height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), diff --git a/tests/wallet/selection.rs b/tests/wallet/selection.rs index 655b984d16..23de048661 100644 --- a/tests/wallet/selection.rs +++ b/tests/wallet/selection.rs @@ -132,6 +132,7 @@ fn mint_does_not_select_inscription() { offset: None, height: None, }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), diff --git a/tests/wallet/send.rs b/tests/wallet/send.rs index d2ff59645d..45b76caab2 100644 --- a/tests/wallet/send.rs +++ b/tests/wallet/send.rs @@ -866,6 +866,7 @@ fn sending_rune_with_divisibility_works() { supply: "1000".parse().unwrap(), symbol: '¢', terms: None, + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), From 1d0070834a8a7b7a3399139dd39fff40ebafaf37 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 10 Apr 2024 17:50:47 -0700 Subject: [PATCH 3/5] Reform --- batch.yaml | 8 ++- src/subcommand/server.rs | 2 +- src/templates/rune.rs | 27 +-------- src/wallet/batch/plan.rs | 10 ++-- templates/rune.html | 2 +- tests/lib.rs | 2 + tests/wallet/batch_command.rs | 104 +++++++++++++++++++++++++++++++++- 7 files changed, 121 insertions(+), 34 deletions(-) diff --git a/batch.yaml b/batch.yaml index 5666497d84..20c05b3831 100644 --- a/batch.yaml +++ b/batch.yaml @@ -45,7 +45,13 @@ etching: offset: start: 1000 end: 9000 - turbo: true, + # future runes protocol changes may be opt-in. this may be for a variety of + # reasons, including that they make light client validation harder, or simply + # because they are too degenerate. + # + # setting `turbo` to `true` opts in to these future protocol changes, + # whatever they may be. + turbo: true # inscriptions to inscribe inscriptions: diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 6d5e82735d..2093898eea 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2785,7 +2785,7 @@ mod tests {
symbol
%
turbo
-
yes
+
true
etching
{txid}
parent
diff --git a/src/templates/rune.rs b/src/templates/rune.rs index 79fe2433e0..9e4aaf404a 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -1,28 +1,5 @@ use super::*; -enum Foo { - No, - Yes, -} - -impl From for Foo { - fn from(b: bool) -> Self { - match b { - false => Self::No, - true => Self::Yes, - } - } -} - -impl Display for Foo { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - match self { - Self::No => write!(f, "no"), - Self::Yes => write!(f, "yes"), - } - } -} - #[derive(Boilerplate, Debug, PartialEq, Serialize, Deserialize)] pub struct RuneHtml { pub entry: RuneEntry, @@ -117,7 +94,7 @@ mod tests {
symbol
%
turbo
-
yes
+
true
etching
0{64}
parent
@@ -189,7 +166,7 @@ mod tests { "

B•CGDENLQRQWDSLRUGSNLBTMFIJAV

.*
turbo
-
no
+
false
.*
" ); diff --git a/src/wallet/batch/plan.rs b/src/wallet/batch/plan.rs index 44f02d3faf..ed37d47adf 100644 --- a/src/wallet/batch/plan.rs +++ b/src/wallet/batch/plan.rs @@ -446,6 +446,10 @@ impl Plan { edicts: Vec::new(), etching: Some(ordinals::Etching { divisibility: (etching.divisibility > 0).then_some(etching.divisibility), + premine: (premine > 0).then_some(premine), + rune: Some(etching.rune.rune), + spacers: (etching.rune.spacers > 0).then_some(etching.rune.spacers), + symbol: Some(etching.symbol), terms: etching .terms .map(|terms| -> Result { @@ -463,11 +467,7 @@ impl Plan { }) }) .transpose()?, - turbo: false, - premine: (premine > 0).then_some(premine), - rune: Some(etching.rune.rune), - spacers: (etching.rune.spacers > 0).then_some(etching.rune.spacers), - symbol: Some(etching.symbol), + turbo: etching.turbo, }), mint: None, pointer: (premine > 0).then_some((reveal_outputs.len() - 1).try_into().unwrap()), diff --git a/templates/rune.html b/templates/rune.html index 0c5d4d33db..63f4f8e86d 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -63,7 +63,7 @@

{{ self.entry.spaced_rune }}

{{ symbol }}
%% }
turbo
-
{{ Foo::from(self.entry.turbo) }}
+
{{ self.entry.turbo }}
etching
{{ self.entry.etching }}
%% if let Some(parent) = self.parent { diff --git a/tests/lib.rs b/tests/lib.rs index 654fbb2cfe..98fdc317fa 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -342,6 +342,8 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E
{divisibility}
symbol
{symbol}
+
turbo
+
{turbo}
etching
{reveal}
parent
diff --git a/tests/wallet/batch_command.rs b/tests/wallet/batch_command.rs index 74d65a5a6c..cacff80ce8 100644 --- a/tests/wallet/batch_command.rs +++ b/tests/wallet/batch_command.rs @@ -1463,7 +1463,109 @@ fn batch_can_etch_rune() { ord.assert_response_regex( "/rune/AAAAAAAAAAAAA", format!( - r".*
parent
\s*
{parent}
.*" + r".*\s*
turbo
\s*
false
.*
parent
\s*
{parent}
.*" + ), + ); + + let destination = batch + .output + .rune + .unwrap() + .destination + .unwrap() + .require_network(Network::Regtest) + .unwrap(); + + assert!(core.state().is_wallet_address(&destination)); + + let reveal = core.tx_by_id(batch.output.reveal); + + assert_eq!( + reveal.input[0].sequence, + Sequence::from_height(Runestone::COMMIT_CONFIRMATIONS - 1) + ); + + let Artifact::Runestone(runestone) = Runestone::decipher(&reveal).unwrap() else { + panic!(); + }; + + let pointer = reveal.output.len() - 2; + + assert_eq!(runestone.pointer, Some(pointer.try_into().unwrap())); + + assert_eq!( + reveal.output[pointer].script_pubkey, + destination.script_pubkey(), + ); + + assert_eq!( + CommandBuilder::new("--regtest wallet balance") + .core(&core) + .ord(&ord) + .run_and_deserialize_output::(), + Balance { + cardinal: 44999980000, + ordinal: 10000, + runic: Some(10000), + runes: Some(vec![(rune, 1000)].into_iter().collect()), + total: 450 * COIN_VALUE, + } + ); +} + +#[test] +fn batch_can_etch_turbo_rune() { + let core = mockcore::builder().network(Network::Regtest).build(); + + let ord = TestServer::spawn_with_server_args(&core, &["--regtest", "--index-runes"], &[]); + + create_wallet(&core, &ord); + + core.mine_blocks(1); + + let rune = SpacedRune { + rune: Rune(RUNE), + spacers: 0, + }; + + let batch = batch( + &core, + &ord, + batch::File { + etching: Some(batch::Etching { + divisibility: 0, + rune, + supply: "1000".parse().unwrap(), + premine: "1000".parse().unwrap(), + symbol: '¢', + terms: None, + turbo: true, + }), + inscriptions: vec![batch::Entry { + file: "inscription.jpeg".into(), + ..default() + }], + ..default() + }, + ); + + let parent = batch.output.inscriptions[0].id; + + let request = ord.request(format!("/content/{parent}")); + + assert_eq!(request.status(), 200); + assert_eq!(request.headers().get("content-type").unwrap(), "image/jpeg"); + assert_eq!(request.text().unwrap(), "inscription"); + + ord.assert_response_regex( + format!("/inscription/{parent}"), + r".*
rune
\s*
AAAAAAAAAAAAA
.*", + ); + + ord.assert_response_regex( + "/rune/AAAAAAAAAAAAA", + format!( + r".*\s*
turbo
\s*
true
.*
parent
\s*
{parent}
.*" ), ); From b778862debbda7ea6403a71217841b7014c8b66f Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 10 Apr 2024 18:48:32 -0700 Subject: [PATCH 4/5] Revise --- src/index.rs | 2 +- tests/wallet/balance.rs | 1 + tests/wallet/batch_command.rs | 80 +++++------------------------------ 3 files changed, 13 insertions(+), 70 deletions(-) diff --git a/src/index.rs b/src/index.rs index c872d17eab..ec997e6447 100644 --- a/src/index.rs +++ b/src/index.rs @@ -48,7 +48,7 @@ mod updater; #[cfg(test)] pub(crate) mod testing; -const SCHEMA_VERSION: u64 = 24; +const SCHEMA_VERSION: u64 = 25; define_multimap_table! { SATPOINT_TO_SEQUENCE_NUMBER, &SatPointValue, u32 } define_multimap_table! { SAT_TO_SEQUENCE_NUMBER, u64, u32 } diff --git a/tests/wallet/balance.rs b/tests/wallet/balance.rs index 1d9d839cdc..6d1fb14a94 100644 --- a/tests/wallet/balance.rs +++ b/tests/wallet/balance.rs @@ -224,6 +224,7 @@ fn runic_utxos_are_displayed_with_decimal_amount() { cap: 1, ..default() }), + turbo: false, }), inscriptions: vec![batch::Entry { file: Some("inscription.jpeg".into()), diff --git a/tests/wallet/batch_command.rs b/tests/wallet/batch_command.rs index cacff80ce8..39c96a2fc5 100644 --- a/tests/wallet/batch_command.rs +++ b/tests/wallet/batch_command.rs @@ -1507,7 +1507,17 @@ fn batch_can_etch_rune() { cardinal: 44999980000, ordinal: 10000, runic: Some(10000), - runes: Some(vec![(rune, 1000)].into_iter().collect()), + runes: Some( + vec![( + rune, + Decimal { + value: 1000, + scale: 0, + } + )] + .into_iter() + .collect() + ), total: 450 * COIN_VALUE, } ); @@ -1549,80 +1559,12 @@ fn batch_can_etch_turbo_rune() { }, ); - let parent = batch.output.inscriptions[0].id; - - let request = ord.request(format!("/content/{parent}")); - - assert_eq!(request.status(), 200); - assert_eq!(request.headers().get("content-type").unwrap(), "image/jpeg"); - assert_eq!(request.text().unwrap(), "inscription"); - - ord.assert_response_regex( - format!("/inscription/{parent}"), - r".*
rune
\s*
AAAAAAAAAAAAA
.*", - ); - ord.assert_response_regex( "/rune/AAAAAAAAAAAAA", format!( r".*\s*
turbo
\s*
true
.*
parent
\s*
{parent}
.*" ), ); - - let destination = batch - .output - .rune - .unwrap() - .destination - .unwrap() - .require_network(Network::Regtest) - .unwrap(); - - assert!(core.state().is_wallet_address(&destination)); - - let reveal = core.tx_by_id(batch.output.reveal); - - assert_eq!( - reveal.input[0].sequence, - Sequence::from_height(Runestone::COMMIT_CONFIRMATIONS - 1) - ); - - let Artifact::Runestone(runestone) = Runestone::decipher(&reveal).unwrap() else { - panic!(); - }; - - let pointer = reveal.output.len() - 2; - - assert_eq!(runestone.pointer, Some(pointer.try_into().unwrap())); - - assert_eq!( - reveal.output[pointer].script_pubkey, - destination.script_pubkey(), - ); - - assert_eq!( - CommandBuilder::new("--regtest wallet balance") - .core(&core) - .ord(&ord) - .run_and_deserialize_output::(), - Balance { - cardinal: 44999980000, - ordinal: 10000, - runic: Some(10000), - runes: Some( - vec![( - rune, - Decimal { - value: 1000, - scale: 0, - } - )] - .into_iter() - .collect() - ), - total: 450 * COIN_VALUE, - } - ); } #[test] From 4094973681b2b1ec1136a8738e563f45c2fa9197 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 10 Apr 2024 18:53:13 -0700 Subject: [PATCH 5/5] Adjust --- tests/wallet/batch_command.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/wallet/batch_command.rs b/tests/wallet/batch_command.rs index 39c96a2fc5..423b903ddb 100644 --- a/tests/wallet/batch_command.rs +++ b/tests/wallet/batch_command.rs @@ -1552,13 +1552,15 @@ fn batch_can_etch_turbo_rune() { turbo: true, }), inscriptions: vec![batch::Entry { - file: "inscription.jpeg".into(), + file: Some("inscription.jpeg".into()), ..default() }], ..default() }, ); + let parent = batch.output.inscriptions[0].id; + ord.assert_response_regex( "/rune/AAAAAAAAAAAAA", format!(