From 4a1de29b3a666d7fb84ab2ef7b0557b9ab902d57 Mon Sep 17 00:00:00 2001 From: notV4l <122404722+notV4l@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:29:38 +0200 Subject: [PATCH] simulate consumtion (#16) --- .../src/vrf_provider/vrf_provider_component.cairo | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contracts/src/vrf_provider/vrf_provider_component.cairo b/contracts/src/vrf_provider/vrf_provider_component.cairo index 680438e..a770dd0 100644 --- a/contracts/src/vrf_provider/vrf_provider_component.cairo +++ b/contracts/src/vrf_provider/vrf_provider_component.cairo @@ -110,11 +110,6 @@ pub mod VrfProviderComponent { let caller = get_caller_address(); 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 source { Source::Nonce(addr) => { let nonce = self.VrfProvider_nonces.read(addr); @@ -125,6 +120,13 @@ pub mod VrfProviderComponent { poseidon_hash_span(array![salt, caller.into(), tx_info.chain_id].span()) }, }; + + // Always return 0 during fee estimation to avoid leaking vrf info. + if tx_info.max_fee == 0 { + // simulate consumed + self.VrfProvider_random.write(seed, 0); + return 0; + } let random = self.VrfProvider_random.read(seed); assert(random != 0, Errors::NOT_FULFILLED);