From 96769e4cdbc6b694a4ea7da29a20277ed6510726 Mon Sep 17 00:00:00 2001 From: gaetbout Date: Thu, 6 Jun 2024 09:44:15 +0200 Subject: [PATCH] move compute max fee back onto the account --- src/contracts/claim_account.cairo | 18 ++++++++++++++++-- src/contracts/utils.cairo | 15 --------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/contracts/claim_account.cairo b/src/contracts/claim_account.cairo index 724d10c..19265b5 100644 --- a/src/contracts/claim_account.cairo +++ b/src/contracts/claim_account.cairo @@ -13,8 +13,7 @@ mod ClaimAccount { use starknet_gifting::contracts::claim_utils::calculate_claim_account_address; use starknet_gifting::contracts::interface::{IAccount, IGiftAccount, ClaimData, AccountConstructorArguments}; use starknet_gifting::contracts::utils::{ - full_deserialize, STRK_ADDRESS, ETH_ADDRESS, TX_V1_ESTIMATE, TX_V1, TX_V3, TX_V3_ESTIMATE, compute_max_fee_v3, - execute_multicall + full_deserialize, STRK_ADDRESS, ETH_ADDRESS, TX_V1_ESTIMATE, TX_V1, TX_V3, TX_V3_ESTIMATE, execute_multicall }; #[storage] struct Storage {} @@ -97,4 +96,19 @@ mod ClaimAccount { assert(calculated_address == get_contract_address(), 'gift-acc/invalid-claim-address'); } } + + + fn compute_max_fee_v3(mut resource_bounds: Span, tip: u128) -> u128 { + let mut max_fee: u128 = 0; + let mut max_tip: u128 = 0; + while let Option::Some(r) = resource_bounds + .pop_front() { + let max_resource_amount: u128 = (*r.max_amount).into(); + max_fee += *r.max_price_per_unit * max_resource_amount; + if *r.resource == 'L2_GAS' { + max_tip += tip * max_resource_amount; + } + }; + max_fee + max_tip + } } diff --git a/src/contracts/utils.cairo b/src/contracts/utils.cairo index 93131e0..adff7d5 100644 --- a/src/contracts/utils.cairo +++ b/src/contracts/utils.cairo @@ -37,21 +37,6 @@ fn serialize>(value: @E) -> Array { output } - -fn compute_max_fee_v3(mut resource_bounds: Span, tip: u128) -> u128 { - let mut max_fee: u128 = 0; - let mut max_tip: u128 = 0; - while let Option::Some(r) = resource_bounds - .pop_front() { - let max_resource_amount: u128 = (*r.max_amount).into(); - max_fee += *r.max_price_per_unit * max_resource_amount; - if *r.resource == 'L2_GAS' { - max_tip += tip * max_resource_amount; - } - }; - max_fee + max_tip -} - fn execute_multicall(mut calls: Span) -> Array> { let mut result = array![]; let mut index = 0;