Skip to content

Commit

Permalink
add max supply global state for inflation asset (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Choi authored Jul 11, 2024
1 parent 6072373 commit 05166e9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/rgb20/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ impl Rgb20 {
.sum()
}

// Max supply for the inflation asset, if there is no `max supply`, then it will
// default to the non-inflatable asset `issued supply`
pub fn max_supply(&self) -> Amount {
self.0
.global("maxSupply")
.unwrap_or_else(|_| {
self.0
.global("issuedSupply")
.expect("RGB20 interface requires global `issuedSupply`")
})
.iter()
.map(Amount::from_strict_val_unchecked)
.sum()
}

pub fn total_burned_supply(&self) -> Amount {
self.0
.global("burnedSupply")
Expand Down

0 comments on commit 05166e9

Please sign in to comment.