diff --git a/src/rgb20/issuer.rs b/src/rgb20/issuer.rs index 61f36b4..8c8500b 100644 --- a/src/rgb20/issuer.rs +++ b/src/rgb20/issuer.rs @@ -270,7 +270,7 @@ impl PrimaryIssue { self.builder = self .builder .add_asset_tag("inflationAllowance", tag) - .expect("invalid RGB20 schema (max supply mismatch)"); + .expect("invalid RGB20 inflation allowance tag (inflation allowance mismatch)"); self.inflation = Some(supply) } } diff --git a/src/rgb20/wrapper.rs b/src/rgb20/wrapper.rs index 4bcaf37..2e9d5f4 100644 --- a/src/rgb20/wrapper.rs +++ b/src/rgb20/wrapper.rs @@ -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")