Skip to content

Commit

Permalink
simulate consumtion (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l authored Oct 14, 2024
1 parent c905ad8 commit 4a1de29
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions contracts/src/vrf_provider/vrf_provider_component.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 4a1de29

Please sign in to comment.