-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
154 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
use crate::db::types::{pg_bigint_u32::PgBigIntU32, pg_numeric_u128::PgNumericU128}; | ||
use crate::db::types::pg_numeric_u128::PgNumericU128; | ||
|
||
/// An update to a rune that affects its total counts. | ||
#[derive(Debug, Clone)] | ||
pub struct DbRuneUpdate { | ||
pub id: String, | ||
pub minted: PgNumericU128, | ||
pub total_mints: PgBigIntU32, | ||
pub total_mints: PgNumericU128, | ||
pub burned: PgNumericU128, | ||
pub total_burns: PgBigIntU32, | ||
pub total_operations: PgBigIntU32, | ||
pub total_burns: PgNumericU128, | ||
pub total_operations: PgNumericU128, | ||
} | ||
|
||
impl DbRuneUpdate { | ||
pub fn from_mint(id: String, amount: PgNumericU128) -> Self { | ||
DbRuneUpdate { | ||
id, | ||
minted: amount, | ||
total_mints: PgBigIntU32(1), | ||
total_mints: PgNumericU128(1), | ||
burned: PgNumericU128(0), | ||
total_burns: PgBigIntU32(0), | ||
total_operations: PgBigIntU32(1), | ||
total_burns: PgNumericU128(0), | ||
total_operations: PgNumericU128(1), | ||
} | ||
} | ||
|
||
pub fn from_burn(id: String, amount: PgNumericU128) -> Self { | ||
DbRuneUpdate { | ||
id, | ||
minted: PgNumericU128(0), | ||
total_mints: PgBigIntU32(0), | ||
total_mints: PgNumericU128(0), | ||
burned: amount, | ||
total_burns: PgBigIntU32(1), | ||
total_operations: PgBigIntU32(1), | ||
total_burns: PgNumericU128(1), | ||
total_operations: PgNumericU128(1), | ||
} | ||
} | ||
|
||
pub fn from_operation(id: String) -> Self { | ||
DbRuneUpdate { | ||
id, | ||
minted: PgNumericU128(0), | ||
total_mints: PgBigIntU32(0), | ||
total_mints: PgNumericU128(0), | ||
burned: PgNumericU128(0), | ||
total_burns: PgBigIntU32(0), | ||
total_operations: PgBigIntU32(1), | ||
total_burns: PgNumericU128(0), | ||
total_operations: PgNumericU128(1), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters