Skip to content

Commit

Permalink
Return 0 during fee estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
tarrencev committed Oct 11, 2024
1 parent d7ad794 commit b29fedf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions contracts/src/vrf_provider/vrf_provider_component.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,21 @@ pub mod VrfProviderComponent {
ref self: ComponentState<TContractState>, salt: Option<felt252>
) -> felt252 {
let caller = get_caller_address();
let chain_id = starknet::get_execution_info().tx_info.unbox().chain_id;
let tx_info = starknet::get_execution_info().tx_info.unbox();

// Always return 0 during fee estimation to avoid leaking vrf info.
if tx_info.max_fee == 0 {
return 0;
}

let seed = match salt {
Option::Some(s) => poseidon_hash_span(array![s, caller.into(), chain_id].span()),
Option::Some(s) => {
poseidon_hash_span(array![s, caller.into(), tx_info.chain_id].span())
},
Option::None => {
let nonce = self.VrfProvider_nonces.read(caller);
self.VrfProvider_nonces.write(caller, nonce + 1);
poseidon_hash_span(array![nonce, caller.into(), chain_id].span())
poseidon_hash_span(array![nonce, caller.into(), tx_info.chain_id].span())
}
};

Expand Down

0 comments on commit b29fedf

Please sign in to comment.