From 23fdd5982f226944981fc1e8bb0c41b262210013 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Fri, 29 Mar 2024 14:35:30 -0700 Subject: [PATCH] Add etching to example batchfile (#3407) --- batch.yaml | 31 ++++++++- src/subcommand/wallet/batch_command.rs | 5 -- src/wallet/batch/file.rs | 89 +++++++++++++++++++++++++- 3 files changed, 117 insertions(+), 8 deletions(-) diff --git a/batch.yaml b/batch.yaml index 9c9e94561f..707d2ef76b 100644 --- a/batch.yaml +++ b/batch.yaml @@ -19,6 +19,33 @@ reinscribe: true # sat to inscribe on, can only be used with `same-sat`: # sat: 5000000000 +# rune to etch (optional) +etching: + # rune name + rune: THE•BEST•RUNE + # allow subdividing super-unit into `10^divisibility` sub-units + divisibility: 2 + # premine + premine: 1000.00 + # total supply, must be equal to `premine + terms.cap * terms.amount` + supply: 10000.00 + # currency symbol + symbol: $ + # mint terms (optional) + terms: + # amount per mint + amount: 100.00 + # maximum number of mints + cap: 90 + # mint start and end absolute block height (optional) + height: + start: 840000 + end: 850000 + # mint start and end block height relative to etching height (optional) + offset: + start: 1000 + end: 9000 + # inscriptions to inscribe inscriptions: # path to inscription content @@ -36,10 +63,10 @@ inscriptions: metus est et odio. Nullam venenatis, urna et molestie vestibulum, orci mi efficitur risus, eu malesuada diam lorem sed velit. Nam fermentum dolor et luctus euismod. - # inscription metaprotocol (optional) - metaprotocol: DOPEPROTOCOL-42069 - file: token.json + # inscription metaprotocol (optional) + metaprotocol: DOPEPROTOCOL-42069 - file: tulip.png destination: bc1pdqrcrxa8vx6gy75mfdfj84puhxffh4fq46h3gkp6jxdd0vjcsdyspfxcv6 diff --git a/src/subcommand/wallet/batch_command.rs b/src/subcommand/wallet/batch_command.rs index 21fd3fe829..7c0e8727b9 100644 --- a/src/subcommand/wallet/batch_command.rs +++ b/src/subcommand/wallet/batch_command.rs @@ -250,9 +250,4 @@ inscriptions: .to_string() .contains("unknown field `unknown`")); } - - #[test] - fn example_batchfile_deserializes_successfully() { - batch::File::load(Path::new("batch.yaml")).unwrap(); - } } diff --git a/src/wallet/batch/file.rs b/src/wallet/batch/file.rs index dc659bfee4..68f8bae4f3 100644 --- a/src/wallet/batch/file.rs +++ b/src/wallet/batch/file.rs @@ -197,7 +197,7 @@ impl File { #[cfg(test)] mod tests { - use super::*; + use {super::*, pretty_assertions::assert_eq}; #[test] fn batchfile_not_sat_and_satpoint() { @@ -359,4 +359,91 @@ inscriptions: "duplicate satpoint bc4c30829a9564c0d58e6287195622b53ced54a25711d1b86be7cd3a70ef61ed:0:0" ); } + + #[test] + fn example_batchfile_deserializes_successfully() { + assert_eq!( + batch::File::load(Path::new("batch.yaml")).unwrap(), + batch::File { + mode: batch::Mode::SeparateOutputs, + parent: Some( + "6ac5cacb768794f4fd7a78bf00f2074891fce68bd65c4ff36e77177237aacacai0" + .parse() + .unwrap() + ), + postage: Some(12345), + reinscribe: true, + sat: None, + satpoint: None, + etching: Some(Etching { + rune: "THE•BEST•RUNE".parse().unwrap(), + divisibility: 2, + premine: "1000.00".parse().unwrap(), + supply: "10000.00".parse().unwrap(), + symbol: '$', + terms: Some(batch::Terms { + amount: "100.00".parse().unwrap(), + cap: 90, + height: Some(batch::Range { + start: Some(840000), + end: Some(850000), + }), + offset: Some(batch::Range { + start: Some(1000), + end: Some(9000), + }), + }), + }), + inscriptions: vec![ + batch::Entry { + file: "mango.avif".into(), + delegate: Some( + "6ac5cacb768794f4fd7a78bf00f2074891fce68bd65c4ff36e77177237aacacai0" + .parse() + .unwrap() + ), + destination: Some( + "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4" + .parse() + .unwrap() + ), + metadata: Some(serde_yaml::Value::Mapping({ + let mut mapping = serde_yaml::Mapping::new(); + mapping.insert("title".into(), "Delicious Mangos".into()); + mapping.insert( + "description".into(), + "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam semper, \ + ligula ornare laoreet tincidunt, odio nisi euismod tortor, vel blandit \ + metus est et odio. Nullam venenatis, urna et molestie vestibulum, orci \ + mi efficitur risus, eu malesuada diam lorem sed velit. Nam fermentum \ + dolor et luctus euismod.\n" + .into(), + ); + mapping + })), + ..default() + }, + batch::Entry { + file: "token.json".into(), + metaprotocol: Some("DOPEPROTOCOL-42069".into()), + ..default() + }, + batch::Entry { + file: "tulip.png".into(), + destination: Some( + "bc1pdqrcrxa8vx6gy75mfdfj84puhxffh4fq46h3gkp6jxdd0vjcsdyspfxcv6" + .parse() + .unwrap() + ), + metadata: Some(serde_yaml::Value::Mapping({ + let mut mapping = serde_yaml::Mapping::new(); + mapping.insert("author".into(), "Satoshi Nakamoto".into()); + mapping + })), + ..default() + }, + ], + } + ); + } }