Skip to content

Commit

Permalink
Move elect docs to the cairo doc, merge into one file
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcticae committed Apr 16, 2024
1 parent 8f1a274 commit c312abc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 91 deletions.
5 changes: 1 addition & 4 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@
* [block_timestamp](appendix/cheatcodes/block_timestamp.md)
* [mock_call](appendix/cheatcodes/mock_call.md)
* [tx_info](appendix/cheatcodes/tx_info.md)
* [sequencer_address](appendix/cheatcodes/sequencer_address/README.md)
* [elect](appendix/cheatcodes/sequencer_address/elect.md)
* [start_elect](appendix/cheatcodes/sequencer_address/start_elect.md)
* [stop_elect](appendix/cheatcodes/sequencer_address/stop_elect.md)
* [sequencer_address](appendix/cheatcodes/sequencer_address.md)
* [get_class_hash](appendix/cheatcodes/get_class_hash.md)
* [replace_bytecode](appendix/cheatcodes/replace_bytecode.md)
* [l1_handler_execute](appendix/cheatcodes/l1_handler_execute.md)
Expand Down
6 changes: 3 additions & 3 deletions docs/src/appendix/cheatcodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
- [`warp`](cheatcodes/block_timestamp#warp) - changes the block timestamp for contracts, for a number of calls
- [`start_warp`](cheatcodes/block_timestamp#start_warp) - changes the block timestamp for contracts
- [`stop_warp`](cheatcodes/block_timestamp#stop_warp) - cancels the `warp` / `start_warp` for contracts
- [`elect`](cheatcodes/sequencer_address/elect.md) - changes the sequencer address for contracts, for a number of calls
- [`start_elect`](cheatcodes/sequencer_address/start_elect.md) - changes the sequencer address for contracts
- [`stop_elect`](cheatcodes/sequencer_address/stop_elect.md) - cancels the `elect` / `start_elect` for contracts
- [`elect`](cheatcodes/sequencer_address#elect) - changes the sequencer address for contracts, for a number of calls
- [`start_elect`](cheatcodes/sequencer_address#start_elect) - changes the sequencer address for contracts
- [`stop_elect`](cheatcodes/sequencer_address#stop_elect) - cancels the `elect` / `start_elect` for contracts
- [`spoof`](cheatcodes/tx_info#spoof) - changes the transaction context for contracts, for a number of calls
- [`start_spoof`](cheatcodes/tx_info#start_spoof) - changes the transaction context for contracts
- [`stop_spoof`](cheatcodes/tx_info#stop_spoof) - cancels the `spoof` / `start_spoof` for contracts
Expand Down
21 changes: 21 additions & 0 deletions docs/src/appendix/cheatcodes/sequencer_address.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# `sequencer_address`

Cheatcodes modifying `sequencer_address`:

## `elect`

> `fn elect(target: CheatTarget, sequencer_address: ContractAddress, span: CheatSpan)`
Changes the sequencer address for the given target and span.

## `start_elect`

> `fn start_elect(target: CheatTarget, sequencer_address: ContractAddress)`
Changes the sequencer address for a given target.

## `stop_elect`

> `fn stop_elect(target: CheatTarget)`
Cancels the `elect` / `start_elect` for the given target.
7 changes: 0 additions & 7 deletions docs/src/appendix/cheatcodes/sequencer_address/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions docs/src/appendix/cheatcodes/sequencer_address/elect.md

This file was deleted.

47 changes: 0 additions & 47 deletions docs/src/appendix/cheatcodes/sequencer_address/start_elect.md

This file was deleted.

20 changes: 0 additions & 20 deletions docs/src/appendix/cheatcodes/sequencer_address/stop_elect.md

This file was deleted.

10 changes: 10 additions & 0 deletions snforge_std/src/cheatcodes.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ fn stop_warp(target: CheatTarget) {
handle_cheatcode(cheatcode::<'stop_warp'>(inputs.span()));
}

/// Changes the sequencer address for the given target and span.
/// `target` - instance of `CheatTarget` specifying which contracts to elect
/// `sequencer_address` - sequencer address to be set
/// `span` - instance of `CheatSpan` specifying the number of target calls with the cheat applied
fn elect(target: CheatTarget, sequencer_address: ContractAddress, span: CheatSpan) {
validate_cheat_target_and_span(@target, @span);

Expand All @@ -129,10 +133,16 @@ fn elect(target: CheatTarget, sequencer_address: ContractAddress, span: CheatSpa
handle_cheatcode(cheatcode::<'elect'>(inputs.span()));
}

/// Changes the sequencer address for a given target.
/// - `target` - instance of `CheatTarget` specifying which contracts to elect
/// - `sequencer_address` - sequencer address to be set
fn start_elect(target: CheatTarget, sequencer_address: ContractAddress) {
elect(target, sequencer_address, CheatSpan::Indefinite);
}


/// Cancels the `elect` / `start_elect` for the given target.
/// - `target` - instance of `CheatTarget` specifying which contracts to stop electing
fn stop_elect(target: CheatTarget) {
let mut inputs = array![];
target.serialize(ref inputs);
Expand Down

0 comments on commit c312abc

Please sign in to comment.