-
Notifications
You must be signed in to change notification settings - Fork 196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cheatcode for getting hash of the block #2648
Open
PedroRosalba
wants to merge
29
commits into
foundry-rs:master
Choose a base branch
from
PedroRosalba:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4298e64
cheatcode block_hash
PedroRosalba 7243cfd
fix: names
PedroRosalba 8abeeca
Merge remote-tracking branch 'upstream/master'
PedroRosalba 9c95d80
fix: types
PedroRosalba 26f10c4
still in progress
PedroRosalba df1a1ee
Merge branch 'master' into master
kkawula 59c5d76
minor fix
65b4839
minor fix: undo create book
9fee226
Merge remote-tracking branch 'origin/master'
845a2d9
minor fix
2b1690f
ran scarbfmt.sh
2fe2baa
Merge branch 'master' into master
kkawula a450fa1
added changelog and fix imports Felt252
7bc764f
added module to lib and fmt code
b35e0dd
Merge branch 'master' into master
kkawula 9b77098
fix: adding import
PedroRosalba cf6e429
Ignore .cargo/ and .rustup/ directories
PedroRosalba ab96aca
updates
PedroRosalba 8b75ef5
updating. should I get the contractAddress from the cheated block num…
PedroRosalba 40caccc
Merge branch 'foundry-rs:master' into master
PedroRosalba 634bb44
updating
PedroRosalba cad9900
Merge branch 'master' into master
kkawula cb477c1
Apply suggestions from code review
kkawula 2101152
Merge branch 'master' into master
kkawula e7b95f4
Merge branch 'master' into master
PedroRosalba 9d48bb0
updating
PedroRosalba 1ca9f84
Merge branch 'master' into master
kkawula 50759d0
Merge branch 'master' into master
kkawula 49096fc
Merge branch 'master' into master
kkawula File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ Scarb.lock | |
snfoundry_trace/ | ||
coverage/ | ||
**/.forge_e2e_cache/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
scarb 2.7.0 | ||
scarb 2.7.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...es/cheatnet/src/runtime_extensions/forge_runtime_extension/cheatcodes/cheat_block_hash.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use super::cheat_execution_info::{ | ||
BlockInfoMockOperations, CheatArguments, ExecutionInfoMockOperations, Operation, | ||
}; | ||
use crate::state::CheatSpan; | ||
use crate::CheatnetState; | ||
use cairo_vm::Felt252; | ||
use starknet_api::core::ContractAddress; | ||
|
||
impl CheatnetState { | ||
pub fn cheat_block_hash( | ||
&mut self, | ||
contract_address: ContractAddress, | ||
block_hash: Felt252, | ||
span: CheatSpan, | ||
) { | ||
self.cheat_execution_info(ExecutionInfoMockOperations { | ||
block_info: BlockInfoMockOperations { | ||
block_hash: Operation::Start(CheatArguments { | ||
value: block_hash, | ||
span, | ||
target: contract_address, | ||
}), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}); | ||
} | ||
|
||
pub fn start_cheat_block_hash_global(&mut self, block_hash: Felt252) { | ||
self.cheat_execution_info(ExecutionInfoMockOperations { | ||
block_info: BlockInfoMockOperations { | ||
block_hash: Operation::StartGlobal(block_hash), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}); | ||
} | ||
|
||
pub fn start_cheat_block_hash( | ||
&mut self, | ||
contract_address: ContractAddress, | ||
block_hash: Felt252, | ||
) { | ||
self.cheat_block_hash(contract_address, block_hash, CheatSpan::Indefinite); | ||
} | ||
|
||
pub fn stop_cheat_block_hash(&mut self, contract_address: ContractAddress) { | ||
self.cheat_execution_info(ExecutionInfoMockOperations { | ||
block_info: BlockInfoMockOperations { | ||
block_hash: Operation::Stop(contract_address), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}); | ||
} | ||
|
||
pub fn stop_cheat_block_hash_global(&mut self) { | ||
self.cheat_execution_info(ExecutionInfoMockOperations { | ||
block_info: BlockInfoMockOperations { | ||
block_hash: Operation::StopGlobal, | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -178,4 +178,4 @@ impl CheatnetState { | |
|
||
for_all_fields!(decrement!); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.