From e7d3282bf79bd53f556bebeb7ab5303271e35c8d Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 27 Mar 2024 12:11:51 -0700 Subject: [PATCH] =?UTF-8?q?Terms::limit=20=E2=86=92=20Terms::amount=20(#33?= =?UTF-8?q?83)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index/entry.rs | 53 +++++++++--------- src/index/updater/rune_updater.rs | 8 +-- src/runes.rs | 90 +++++++++++++++---------------- src/runes/runestone.rs | 36 ++++++------- src/runes/tag.rs | 2 +- src/runes/terms.rs | 2 +- src/subcommand/wallet/inscribe.rs | 12 ++--- src/subcommand/wallet/mint.rs | 4 +- src/templates/rune.rs | 8 +-- src/wallet/batch/plan.rs | 2 +- src/wallet/batch/terms.rs | 2 +- templates/rune.html | 6 +-- tests/lib.rs | 6 +-- tests/wallet/inscribe.rs | 34 ++++++------ tests/wallet/mint.rs | 4 +- tests/wallet/selection.rs | 2 +- 16 files changed, 138 insertions(+), 133 deletions(-) diff --git a/src/index/entry.rs b/src/index/entry.rs index 9d655c28d4..38c4b44de2 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -67,11 +67,16 @@ impl RuneEntry { return Err(MintError::Cap(cap)); } - Ok(terms.limit.unwrap_or_default()) + Ok(terms.amount.unwrap_or_default()) } pub fn supply(&self) -> u128 { - self.premine + self.mints * self.terms.and_then(|terms| terms.limit).unwrap_or_default() + self.premine + + self.mints + * self + .terms + .and_then(|terms| terms.amount) + .unwrap_or_default() } pub fn pile(&self, amount: u128) -> Pile { @@ -120,7 +125,7 @@ impl RuneEntry { type TermsEntryValue = ( Option, // cap (Option, Option), // height - Option, // limit + Option, // amount (Option, Option), // offset ); @@ -196,10 +201,10 @@ impl Entry for RuneEntry { spacers, }, symbol, - terms: terms.map(|(cap, height, limit, offset)| Terms { + terms: terms.map(|(cap, height, amount, offset)| Terms { cap, height, - limit, + amount, offset, }), timestamp, @@ -233,9 +238,9 @@ impl Entry for RuneEntry { |Terms { cap, height, - limit, + amount, offset, - }| (cap, height, limit, offset), + }| (cap, height, amount, offset), ), self.timestamp, ) @@ -543,7 +548,7 @@ mod tests { terms: Some(Terms { cap: Some(1), height: (Some(2), Some(3)), - limit: Some(4), + amount: Some(4), offset: (Some(5), Some(6)), }), mints: 11, @@ -611,7 +616,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 0, @@ -625,7 +630,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 1, @@ -639,7 +644,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: None, - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 0, @@ -657,7 +662,7 @@ mod tests { block: 1, terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), offset: (Some(1), None), ..default() }), @@ -673,7 +678,7 @@ mod tests { block: 1, terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), offset: (Some(1), None), ..default() }), @@ -692,7 +697,7 @@ mod tests { block: 1, terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), offset: (None, Some(1)), ..default() }), @@ -708,7 +713,7 @@ mod tests { block: 1, terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), offset: (None, Some(1)), ..default() }), @@ -726,7 +731,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), height: (Some(1), None), ..default() }), @@ -741,7 +746,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), height: (Some(1), None), ..default() }), @@ -759,7 +764,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), height: (None, Some(1)), ..default() }), @@ -774,7 +779,7 @@ mod tests { RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), height: (None, Some(1)), ..default() }), @@ -791,7 +796,7 @@ mod tests { let entry = RuneEntry { terms: Some(Terms { cap: Some(1), - limit: Some(1000), + amount: Some(1000), height: (Some(10), Some(20)), offset: (Some(0), Some(10)), }), @@ -838,7 +843,7 @@ mod tests { assert_eq!( RuneEntry { terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 0, @@ -851,7 +856,7 @@ mod tests { assert_eq!( RuneEntry { terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 1, @@ -864,7 +869,7 @@ mod tests { assert_eq!( RuneEntry { terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 0, @@ -878,7 +883,7 @@ mod tests { assert_eq!( RuneEntry { terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), mints: 1, diff --git a/src/index/updater/rune_updater.rs b/src/index/updater/rune_updater.rs index 58a5fdc13c..3cecf9401d 100644 --- a/src/index/updater/rune_updater.rs +++ b/src/index/updater/rune_updater.rs @@ -5,7 +5,7 @@ use { struct Mint { id: RuneId, - limit: u128, + amount: u128, } struct Etched { @@ -54,7 +54,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> { .and_then(|id| self.mint(id).transpose()) .transpose()? { - *unallocated.entry(mint.id).or_default() += mint.limit; + *unallocated.entry(mint.id).or_default() += mint.amount; } let etched = self.etched(tx_index, tx, &runestone)?; @@ -337,7 +337,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> { let mut rune_entry = RuneEntry::load(entry.value()); - let Ok(limit) = rune_entry.mintable(self.height.into()) else { + let Ok(amount) = rune_entry.mintable(self.height.into()) else { return Ok(None); }; @@ -347,7 +347,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> { self.id_to_entry.insert(&id.store(), rune_entry.store())?; - Ok(Some(Mint { id, limit })) + Ok(Some(Mint { id, amount })) } fn tx_commits_to_rune(&self, tx: &Transaction, rune: Rune) -> Result { diff --git a/src/runes.rs b/src/runes.rs index 048653f3d8..e9fa662c8d 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -860,7 +860,7 @@ mod tests { rune: Some(Rune(RUNE)), terms: Some(Terms { cap: Some(1), - limit: Some(1), + amount: Some(1), offset: (Some(1), Some(1)), height: (None, None), }), @@ -3869,7 +3869,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -3893,7 +3893,7 @@ mod tests { timestamp: id.block, mints: 0, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -3924,7 +3924,7 @@ mod tests { block: id.block, etching: txid0, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -3949,7 +3949,7 @@ mod tests { } #[test] - fn etching_with_limit_can_be_minted() { + fn etching_with_amount_can_be_minted() { let context = Context::builder().arg("--index-runes").build(); let (txid0, id) = context.etch( @@ -3958,7 +3958,7 @@ mod tests { rune: Some(Rune(RUNE)), terms: Some(Terms { cap: Some(100), - limit: Some(1000), + amount: Some(1000), ..default() }), ..default() @@ -3982,7 +3982,7 @@ mod tests { premine: 0, mints: 0, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4018,7 +4018,7 @@ mod tests { block: id.block, etching: txid0, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4068,7 +4068,7 @@ mod tests { block: id.block, etching: txid0, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4129,7 +4129,7 @@ mod tests { burned: 1000, etching: txid0, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4171,7 +4171,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), offset: (None, Some(2)), ..default() @@ -4191,7 +4191,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), offset: (None, Some(2)), cap: Some(100), ..default() @@ -4264,7 +4264,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), offset: (Some(2), None), ..default() @@ -4284,7 +4284,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), offset: (Some(2), None), cap: Some(100), ..default() @@ -4348,7 +4348,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), height: (Some(10), None), ..default() @@ -4368,7 +4368,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), height: (Some(10), None), cap: Some(100), ..default() @@ -4432,7 +4432,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), height: (None, Some(10)), ..default() @@ -4452,7 +4452,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), height: (None, Some(10)), cap: Some(100), ..default() @@ -4531,7 +4531,7 @@ mod tests { rune: Some(Rune(RUNE)), premine: Some(1111), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), offset: (None, Some(0)), ..default() }), @@ -4553,7 +4553,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), offset: (None, Some(0)), ..default() }), @@ -4592,7 +4592,7 @@ mod tests { }, timestamp: id.block, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), offset: (None, Some(0)), ..default() }), @@ -4613,7 +4613,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(2), ..default() }), @@ -4636,7 +4636,7 @@ mod tests { }, timestamp: id.block, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(2), ..default() }), @@ -4679,7 +4679,7 @@ mod tests { etching: txid0, terms: Some(Terms { cap: Some(2), - limit: Some(1000), + amount: Some(1000), ..default() }), ..default() @@ -4725,7 +4725,7 @@ mod tests { }, timestamp: id.block, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(2), ..default() }), @@ -4782,7 +4782,7 @@ mod tests { }, timestamp: id.block, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(2), ..default() }), @@ -4818,7 +4818,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4840,7 +4840,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4883,7 +4883,7 @@ mod tests { }, timestamp: id.block, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -4920,7 +4920,7 @@ mod tests { rune: Some(Rune(RUNE)), premine: Some(2000), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), ..default() @@ -4946,7 +4946,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), timestamp: id.block, @@ -4959,7 +4959,7 @@ mod tests { } #[test] - fn omitted_limit_defaults_to_max_limit() { + fn omitted_edicts_defaults_to_mint_amount() { let context = Context::builder().arg("--index-runes").build(); let (txid, id) = context.etch( @@ -4988,7 +4988,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: None, + amount: None, offset: (None, Some(1)), ..default() }), @@ -5001,7 +5001,7 @@ mod tests { } #[test] - fn premines_can_claim_over_the_max_limit() { + fn premines_can_claim_over_mint_amount() { let context = Context::builder().arg("--index-runes").build(); let (txid, id) = context.etch( @@ -5010,7 +5010,7 @@ mod tests { rune: Some(Rune(RUNE)), premine: Some(2000), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(1), ..default() }), @@ -5037,7 +5037,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(1), ..default() }), @@ -5052,7 +5052,7 @@ mod tests { } #[test] - fn transactions_cannot_claim_more_than_limit() { + fn transactions_cannot_claim_more_than_mint_amount() { let context = Context::builder().arg("--index-runes").build(); let (txid0, id) = context.etch( @@ -5060,7 +5060,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -5101,7 +5101,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -5129,7 +5129,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -5151,7 +5151,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -5204,7 +5204,7 @@ mod tests { spacers: 0, }, terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), cap: Some(100), ..default() }), @@ -5245,7 +5245,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), ..default() @@ -5305,7 +5305,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), ..default() @@ -5365,7 +5365,7 @@ mod tests { etching: Some(Etching { rune: Some(Rune(RUNE)), terms: Some(Terms { - limit: Some(1000), + amount: Some(1000), ..default() }), ..default() diff --git a/src/runes/runestone.rs b/src/runes/runestone.rs index efb03b5e59..7d2137543c 100644 --- a/src/runes/runestone.rs +++ b/src/runes/runestone.rs @@ -115,7 +115,7 @@ impl Runestone { (divisibility <= MAX_DIVISIBILITY).then_some(divisibility) }); - let limit = Tag::Limit.take(&mut fields, |[limit]| Some(limit)); + let amount = Tag::Amount.take(&mut fields, |[amount]| Some(amount)); let rune = Tag::Rune.take(&mut fields, |[rune]| Some(Rune(rune))); @@ -159,8 +159,8 @@ impl Runestone { let overflow = (|| { let premine = premine.unwrap_or_default(); let cap = cap.unwrap_or_default(); - let limit = limit.unwrap_or_default(); - premine.checked_add(cap.checked_mul(limit)?) + let amount = amount.unwrap_or_default(); + premine.checked_add(cap.checked_mul(amount)?) })() .is_none(); @@ -173,7 +173,7 @@ impl Runestone { terms: terms.then_some(Terms { cap, height, - limit, + amount, offset, }), }); @@ -207,7 +207,7 @@ impl Runestone { Tag::Premine.encode_option(etching.premine, &mut payload); if let Some(terms) = etching.terms { - Tag::Limit.encode_option(terms.limit, &mut payload); + Tag::Amount.encode_option(terms.amount, &mut payload); Tag::Cap.encode_option(terms.cap, &mut payload); Tag::HeightStart.encode_option(terms.height.0, &mut payload); Tag::HeightEnd.encode_option(terms.height.1, &mut payload); @@ -695,12 +695,12 @@ mod tests { } #[test] - fn decipher_etching_with_limit() { + fn decipher_etching_with_amount() { assert_eq!( decipher(&[ Tag::Flags.into(), Flag::Etching.mask() | Flag::Terms.mask(), - Tag::Limit.into(), + Tag::Amount.into(), 4, Tag::Body.into(), 1, @@ -716,7 +716,7 @@ mod tests { }], etching: Some(Etching { terms: Some(Terms { - limit: Some(4), + amount: Some(4), ..default() }), ..default() @@ -1065,7 +1065,7 @@ mod tests { 'a'.into(), Tag::OffsetEnd.into(), 2, - Tag::Limit.into(), + Tag::Amount.into(), 3, Tag::Premine.into(), 8, @@ -1094,7 +1094,7 @@ mod tests { terms: Some(Terms { cap: Some(9), offset: (None, Some(2)), - limit: Some(3), + amount: Some(3), height: (None, None), }), premine: Some(8), @@ -1121,7 +1121,7 @@ mod tests { 'a'.into(), Tag::OffsetEnd.into(), 2, - Tag::Limit.into(), + Tag::Amount.into(), 3, Tag::Body.into(), 1, @@ -1437,7 +1437,7 @@ mod tests { divisibility: Some(MAX_DIVISIBILITY), terms: Some(Terms { cap: Some(u32::MAX.into()), - limit: Some(u64::MAX.into()), + amount: Some(u64::MAX.into()), offset: (Some(u32::MAX.into()), Some(u32::MAX.into())), height: (Some(u32::MAX.into()), Some(u32::MAX.into())), }), @@ -1711,7 +1711,7 @@ mod tests { terms: Some(Terms { cap: Some(11), height: (Some(12), Some(13)), - limit: Some(14), + amount: Some(14), offset: (Some(15), Some(16)), }), }), @@ -1731,7 +1731,7 @@ mod tests { '@'.into(), Tag::Premine.into(), 8, - Tag::Limit.into(), + Tag::Amount.into(), 14, Tag::Cap.into(), 11, @@ -1912,7 +1912,7 @@ mod tests { Flag::Etching.mask() | Flag::Terms.mask(), Tag::Cap.into(), 1, - Tag::Limit.into(), + Tag::Amount.into(), u128::MAX ]) .cenotaph @@ -1924,7 +1924,7 @@ mod tests { Flag::Etching.mask() | Flag::Terms.mask(), Tag::Cap.into(), 2, - Tag::Limit.into(), + Tag::Amount.into(), u128::MAX ]) .cenotaph @@ -1936,7 +1936,7 @@ mod tests { Flag::Etching.mask() | Flag::Terms.mask(), Tag::Cap.into(), 2, - Tag::Limit.into(), + Tag::Amount.into(), u128::MAX / 2 + 1 ]) .cenotaph @@ -1950,7 +1950,7 @@ mod tests { 1, Tag::Cap.into(), 1, - Tag::Limit.into(), + Tag::Amount.into(), u128::MAX ]) .cenotaph diff --git a/src/runes/tag.rs b/src/runes/tag.rs index ee36a4d2fb..c8afa6313c 100644 --- a/src/runes/tag.rs +++ b/src/runes/tag.rs @@ -7,7 +7,7 @@ pub(super) enum Tag { Rune = 4, Premine = 6, Cap = 8, - Limit = 10, + Amount = 10, HeightStart = 12, HeightEnd = 14, OffsetStart = 16, diff --git a/src/runes/terms.rs b/src/runes/terms.rs index 768775b52a..9cd1e1a319 100644 --- a/src/runes/terms.rs +++ b/src/runes/terms.rs @@ -2,8 +2,8 @@ use super::*; #[derive(Default, Serialize, Deserialize, Debug, PartialEq, Copy, Clone, Eq)] pub struct Terms { + pub amount: Option, pub cap: Option, pub height: (Option, Option), - pub limit: Option, pub offset: (Option, Option), } diff --git a/src/subcommand/wallet/inscribe.rs b/src/subcommand/wallet/inscribe.rs index ef7ca90782..779dc4940f 100644 --- a/src/subcommand/wallet/inscribe.rs +++ b/src/subcommand/wallet/inscribe.rs @@ -244,8 +244,8 @@ impl Inscribe { .map(|terms| -> Result { terms .cap - .checked_mul(terms.limit.to_amount(etching.divisibility)?) - .ok_or_else(|| anyhow!("`terms.count` * `terms.limit` over maximum")) + .checked_mul(terms.amount.to_amount(etching.divisibility)?) + .ok_or_else(|| anyhow!("`terms.count` * `terms.amount` over maximum")) }) .transpose()? .unwrap_or_default(); @@ -254,8 +254,8 @@ impl Inscribe { supply == premine .checked_add(mintable) - .ok_or_else(|| anyhow!("`premine` + `terms.count` * `terms.limit` over maximum"))?, - "`supply` not equal to `premine` + `terms.count` * `terms.limit`" + .ok_or_else(|| anyhow!("`premine` + `terms.count` * `terms.amount` over maximum"))?, + "`supply` not equal to `premine` + `terms.count` * `terms.amount`" ); ensure!(supply > 0, "`supply` must be greater than zero"); @@ -298,8 +298,8 @@ impl Inscribe { ensure!(terms.cap > 0, "`terms.cap` must be greater than zero",); ensure!( - terms.limit.to_amount(etching.divisibility)? > 0, - "`terms.limit` must be greater than zero", + terms.amount.to_amount(etching.divisibility)? > 0, + "`terms.amount` must be greater than zero", ); } diff --git a/src/subcommand/wallet/mint.rs b/src/subcommand/wallet/mint.rs index 9b6a7d4649..95e1d6360d 100644 --- a/src/subcommand/wallet/mint.rs +++ b/src/subcommand/wallet/mint.rs @@ -32,7 +32,7 @@ impl Mint { bail!("rune {rune} has not been etched"); }; - let limit = rune_entry + let amount = rune_entry .mintable(block_height) .map_err(|err| anyhow!("rune {rune} {err}"))?; @@ -81,7 +81,7 @@ impl Mint { Ok(Some(Box::new(Output { rune: self.rune, pile: Pile { - amount: limit, + amount, divisibility: rune_entry.divisibility, symbol: rune_entry.symbol, }, diff --git a/src/templates/rune.rs b/src/templates/rune.rs index d9c969a47d..fbcfbbd0a8 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -32,7 +32,7 @@ mod tests { cap: Some(101), offset: (None, None), height: (Some(10), Some(11)), - limit: Some(1000000001), + amount: Some(1000000001), }), number: 25, premine: 123456789, @@ -70,7 +70,7 @@ mod tests {
10
end
11
-
limit
+
amount
1.000000001 %
mints
100
@@ -145,7 +145,7 @@ mod tests { cap: None, offset: (None, None), height: (None, None), - limit: None, + amount: None, }), divisibility: 9, etching: Txid::all_zeros(), @@ -172,7 +172,7 @@ mod tests {
none
end
none
-
limit
+
amount
none
mints
0
diff --git a/src/wallet/batch/plan.rs b/src/wallet/batch/plan.rs index 4135dbbeef..990cc17105 100644 --- a/src/wallet/batch/plan.rs +++ b/src/wallet/batch/plan.rs @@ -470,7 +470,7 @@ impl Plan { terms.height.and_then(|range| (range.start)), terms.height.and_then(|range| (range.end)), ), - limit: Some(terms.limit.to_amount(etching.divisibility)?), + amount: Some(terms.amount.to_amount(etching.divisibility)?), offset: ( terms.offset.and_then(|range| (range.start)), terms.offset.and_then(|range| (range.end)), diff --git a/src/wallet/batch/terms.rs b/src/wallet/batch/terms.rs index a0f7228e2a..c5fe8b7948 100644 --- a/src/wallet/batch/terms.rs +++ b/src/wallet/batch/terms.rs @@ -3,8 +3,8 @@ use super::*; #[derive(Serialize, Deserialize, PartialEq, Debug, Copy, Clone, Default)] #[serde(deny_unknown_fields)] pub struct Terms { + pub amount: Decimal, pub cap: u128, pub height: Option, - pub limit: Decimal, pub offset: Option, } diff --git a/templates/rune.html b/templates/rune.html index 282675be9e..19e6d72498 100644 --- a/templates/rune.html +++ b/templates/rune.html @@ -31,9 +31,9 @@

{{ self.entry.spaced_rune }}

%% } else {
none
%% } -
limit
-%% if let Some(limit) = terms.limit { -
{{ self.entry.pile(limit) }}
+
amount
+%% if let Some(amount) = terms.amount { +
{{ self.entry.pile(amount) }}
%% } else {
none
%% } diff --git a/tests/lib.rs b/tests/lib.rs index 1a84e390ce..2e3f833df6 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -261,7 +261,7 @@ fn batch( let premine = premine.to_amount(divisibility).unwrap(); let mintable = terms - .map(|terms| terms.cap * terms.limit.to_amount(divisibility).unwrap()) + .map(|terms| terms.cap * terms.amount.to_amount(divisibility).unwrap()) .unwrap_or_default(); assert_eq!(supply, premine + mintable); @@ -319,12 +319,12 @@ fn batch( } } - mint_definition.push("
limit
".into()); + mint_definition.push("
amount
".into()); mint_definition.push(format!( "
{}
", Pile { - amount: terms.limit.to_amount(divisibility).unwrap(), + amount: terms.amount.to_amount(divisibility).unwrap(), divisibility, symbol: Some(symbol), } diff --git a/tests/wallet/inscribe.rs b/tests/wallet/inscribe.rs index f117511f00..1f35ecde7b 100644 --- a/tests/wallet/inscribe.rs +++ b/tests/wallet/inscribe.rs @@ -2713,7 +2713,7 @@ fn batch_inscribe_can_etch_rune_with_offset() { symbol: '¢', terms: Some(batch::Terms { cap: 9, - limit: "1000".parse().unwrap(), + amount: "1000".parse().unwrap(), offset: Some(batch::Range { start: Some(10), end: Some(20), @@ -2789,7 +2789,7 @@ fn batch_inscribe_can_etch_rune_with_height() { symbol: '¢', terms: Some(batch::Terms { cap: 9, - limit: "1000".parse().unwrap(), + amount: "1000".parse().unwrap(), height: Some(batch::Range { start: Some(10), end: Some(20), @@ -3089,7 +3089,7 @@ fn etch_mintable_overflow_error() { end: Some(2), start: None, }), - limit: "340282366920938463463374607431768211455".parse().unwrap(), + amount: "340282366920938463463374607431768211455".parse().unwrap(), height: None, }), }), @@ -3103,7 +3103,7 @@ fn etch_mintable_overflow_error() { ) .bitcoin_rpc_server(&bitcoin_rpc_server) .ord_rpc_server(&ord_rpc_server) - .expected_stderr("error: `terms.count` * `terms.limit` over maximum\n") + .expected_stderr("error: `terms.count` * `terms.amount` over maximum\n") .expected_exit_code(1) .run_and_extract_stdout(); } @@ -3141,7 +3141,7 @@ fn etch_mintable_plus_premine_overflow_error() { end: Some(2), start: None, }), - limit: "340282366920938463463374607431768211455".parse().unwrap(), + amount: "340282366920938463463374607431768211455".parse().unwrap(), height: None, }), }), @@ -3155,7 +3155,7 @@ fn etch_mintable_plus_premine_overflow_error() { ) .bitcoin_rpc_server(&bitcoin_rpc_server) .ord_rpc_server(&ord_rpc_server) - .expected_stderr("error: `premine` + `terms.count` * `terms.limit` over maximum\n") + .expected_stderr("error: `premine` + `terms.count` * `terms.amount` over maximum\n") .expected_exit_code(1) .run_and_extract_stdout(); } @@ -3193,7 +3193,7 @@ fn incorrect_supply_error() { end: Some(2), start: None, }), - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), height: None, }), }), @@ -3207,7 +3207,7 @@ fn incorrect_supply_error() { ) .bitcoin_rpc_server(&bitcoin_rpc_server) .ord_rpc_server(&ord_rpc_server) - .expected_stderr("error: `supply` not equal to `premine` + `terms.count` * `terms.limit`\n") + .expected_stderr("error: `supply` not equal to `premine` + `terms.count` * `terms.amount`\n") .expected_exit_code(1) .run_and_extract_stdout(); } @@ -3245,7 +3245,7 @@ fn zero_offset_interval_error() { end: Some(2), start: Some(2), }), - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), height: None, }), }), @@ -3297,7 +3297,7 @@ fn zero_height_interval_error() { end: Some(2), start: Some(2), }), - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), offset: None, }), }), @@ -3349,7 +3349,7 @@ fn invalid_start_height_error() { end: None, start: Some(0), }), - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), offset: None, }), }), @@ -3403,7 +3403,7 @@ fn invalid_end_height_error() { start: None, end: Some(0), }), - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), offset: None, }), }), @@ -3498,7 +3498,7 @@ fn zero_cap_error() { terms: Some(batch::Terms { cap: 0, height: None, - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), offset: None, }), }), @@ -3518,7 +3518,7 @@ fn zero_cap_error() { } #[test] -fn zero_limit_error() { +fn zero_amount_error() { let bitcoin_rpc_server = test_bitcoincore_rpc::builder() .network(Network::Regtest) .build(); @@ -3547,7 +3547,7 @@ fn zero_limit_error() { terms: Some(batch::Terms { cap: 1, height: None, - limit: "0".parse().unwrap(), + amount: "0".parse().unwrap(), offset: None, }), }), @@ -3561,7 +3561,7 @@ fn zero_limit_error() { ) .bitcoin_rpc_server(&bitcoin_rpc_server) .ord_rpc_server(&ord_rpc_server) - .expected_stderr("error: `terms.limit` must be greater than zero\n") + .expected_stderr("error: `terms.amount` must be greater than zero\n") .expected_exit_code(1) .run_and_extract_stdout(); } @@ -3603,7 +3603,7 @@ fn oversize_runestone_error() { start: Some(u64::MAX - 1), end: Some(u64::MAX), }), - limit: "1".parse().unwrap(), + amount: "1".parse().unwrap(), }), }), inscriptions: vec![batch::Entry { diff --git a/tests/wallet/mint.rs b/tests/wallet/mint.rs index 172e94566a..ba3a4a0102 100644 --- a/tests/wallet/mint.rs +++ b/tests/wallet/mint.rs @@ -35,7 +35,7 @@ fn minting_rune_and_fails_if_after_end() { end: Some(2), start: None, }), - limit: "111.1".parse().unwrap(), + amount: "111.1".parse().unwrap(), height: None, }), }), @@ -204,7 +204,7 @@ fn minting_rune_and_then_sending_works() { end: Some(10), start: None, }), - limit: "21".parse().unwrap(), + amount: "21".parse().unwrap(), height: None, }), }), diff --git a/tests/wallet/selection.rs b/tests/wallet/selection.rs index 46f37b0640..9cb2e2351c 100644 --- a/tests/wallet/selection.rs +++ b/tests/wallet/selection.rs @@ -132,7 +132,7 @@ fn mint_does_not_select_inscription() { symbol: '¢', terms: Some(batch::Terms { cap: 1, - limit: "1000".parse().unwrap(), + amount: "1000".parse().unwrap(), offset: None, height: None, }),