Skip to content

Commit

Permalink
Merge pull request #188 from starknet-id/ayush/add-decimals
Browse files Browse the repository at this point in the history
feat: add decimals supports
  • Loading branch information
Th0rgal authored Jan 27, 2024
2 parents 0dce46f + 7e0995f commit 474dfef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/endpoints/quest_boost/get_claim_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ pub async fn handler(

let boost: Document = res.unwrap();
let num_of_winners = boost.get("num_of_winners").unwrap().as_i32().unwrap();
let amount = boost.get("amount").unwrap().as_i32().unwrap() as u32 / num_of_winners as u32;
let decimals = boost.get("token_decimals").unwrap().as_i32().unwrap();
let amount: u128 = boost.get("amount").unwrap().as_i32().unwrap() as u128 * 10u128.pow(decimals as u32);
let modified_amount = amount / num_of_winners as u128;
let token = boost.get("token").unwrap().as_str().unwrap();

let winner_list = boost.get("winner").unwrap().as_array().unwrap();
let bson_value: Bson = Bson::String(address.clone());

Expand All @@ -63,7 +65,7 @@ pub async fn handler(
let hashed = pedersen_hash(
&FieldElement::from(boost_id),
&pedersen_hash(
&FieldElement::from(amount),
&FieldElement::from(modified_amount),
&pedersen_hash(
&FieldElement::from(0 as u32),
&pedersen_hash(
Expand Down
1 change: 1 addition & 0 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ pub_struct!(Debug, Serialize, Deserialize; BoostTable {
name: String,
hidden: bool,
num_of_winners: i64,
token_decimals: i64,
});

pub_struct!(Debug, Serialize, Deserialize; NftBalance {
Expand Down

0 comments on commit 474dfef

Please sign in to comment.