Skip to content

Commit

Permalink
Display rune premine (ordinals#3313)
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Mar 19, 2024
1 parent 634c426 commit 6665ff8
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mod updater;
#[cfg(test)]
pub(crate) mod testing;

const SCHEMA_VERSION: u64 = 20;
const SCHEMA_VERSION: u64 = 21;

macro_rules! define_table {
($name:ident, $key:ty, $value:ty) => {
Expand Down
8 changes: 8 additions & 0 deletions src/index/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pub struct RuneEntry {
pub mint: Option<MintEntry>,
pub mints: u64,
pub number: u64,
pub premine: u128,
pub rune: Rune,
pub spacers: u32,
pub supply: u128,
Expand Down Expand Up @@ -92,6 +93,7 @@ pub(super) type RuneEntryValue = (
Option<MintEntryValue>, // mint parameters
u64, // mints
u64, // number
u128, // premine
u128, // rune
u32, // spacers
u128, // supply
Expand Down Expand Up @@ -130,6 +132,7 @@ impl Default for RuneEntry {
mint: None,
mints: 0,
number: 0,
premine: 0,
rune: Rune(0),
spacers: 0,
supply: 0,
Expand All @@ -150,6 +153,7 @@ impl Entry for RuneEntry {
mint,
mints,
number,
premine,
rune,
spacers,
supply,
Expand Down Expand Up @@ -177,6 +181,7 @@ impl Entry for RuneEntry {
}),
mints,
number,
premine,
rune: Rune(rune),
spacers,
supply,
Expand Down Expand Up @@ -211,6 +216,7 @@ impl Entry for RuneEntry {
),
self.mints,
self.number,
self.premine,
self.rune.0,
self.spacers,
self.supply,
Expand Down Expand Up @@ -524,6 +530,7 @@ mod tests {
}),
mints: 11,
number: 6,
premine: 12,
rune: Rune(7),
spacers: 8,
supply: 9,
Expand All @@ -541,6 +548,7 @@ mod tests {
Some((Some(2), Some(4), Some(5))),
11,
6,
12,
7,
8,
9,
Expand Down
10 changes: 8 additions & 2 deletions src/index/updater/rune_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,29 @@ impl<'a, 'db, 'tx> RuneUpdater<'a, 'db, 'tx> {

self.rune_to_id.insert(rune.0, id.store())?;
self.transaction_id_to_rune.insert(&txid.store(), rune.0)?;

let number = self.runes;
self.runes += 1;

let premine = u128::MAX - balance;

self
.statistic_to_count
.insert(&Statistic::Runes.into(), self.runes)?;

self.id_to_entry.insert(
id.store(),
RuneEntry {
burned: 0,
divisibility,
etching: txid,
mints: 0,
number,
mint: mint.and_then(|mint| (!burn).then_some(mint)),
number,
premine,
rune,
spacers,
supply: u128::MAX - balance,
supply: premine,
symbol,
timestamp: self.block_time,
}
Expand Down
Loading

0 comments on commit 6665ff8

Please sign in to comment.