Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terms::limit → Terms::amount #3383

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions src/index/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -120,7 +125,7 @@ impl RuneEntry {
type TermsEntryValue = (
Option<u128>, // cap
(Option<u64>, Option<u64>), // height
Option<u128>, // limit
Option<u128>, // amount
(Option<u64>, Option<u64>), // offset
);

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -233,9 +238,9 @@ impl Entry for RuneEntry {
|Terms {
cap,
height,
limit,
amount,
offset,
}| (cap, height, limit, offset),
}| (cap, height, amount, offset),
),
self.timestamp,
)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -611,7 +616,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: Some(1),
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 0,
Expand All @@ -625,7 +630,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: Some(1),
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 1,
Expand All @@ -639,7 +644,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: None,
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 0,
Expand All @@ -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()
}),
Expand All @@ -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()
}),
Expand All @@ -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()
}),
Expand All @@ -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()
}),
Expand All @@ -726,7 +731,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: Some(1),
limit: Some(1000),
amount: Some(1000),
height: (Some(1), None),
..default()
}),
Expand All @@ -741,7 +746,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: Some(1),
limit: Some(1000),
amount: Some(1000),
height: (Some(1), None),
..default()
}),
Expand All @@ -759,7 +764,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: Some(1),
limit: Some(1000),
amount: Some(1000),
height: (None, Some(1)),
..default()
}),
Expand All @@ -774,7 +779,7 @@ mod tests {
RuneEntry {
terms: Some(Terms {
cap: Some(1),
limit: Some(1000),
amount: Some(1000),
height: (None, Some(1)),
..default()
}),
Expand All @@ -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)),
}),
Expand Down Expand Up @@ -838,7 +843,7 @@ mod tests {
assert_eq!(
RuneEntry {
terms: Some(Terms {
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 0,
Expand All @@ -851,7 +856,7 @@ mod tests {
assert_eq!(
RuneEntry {
terms: Some(Terms {
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 1,
Expand All @@ -864,7 +869,7 @@ mod tests {
assert_eq!(
RuneEntry {
terms: Some(Terms {
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 0,
Expand All @@ -878,7 +883,7 @@ mod tests {
assert_eq!(
RuneEntry {
terms: Some(Terms {
limit: Some(1000),
amount: Some(1000),
..default()
}),
mints: 1,
Expand Down
8 changes: 4 additions & 4 deletions src/index/updater/rune_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {

struct Mint {
id: RuneId,
limit: u128,
amount: u128,
}

struct Etched {
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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);
};

Expand All @@ -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<bool> {
Expand Down
Loading
Loading