Skip to content

Commit

Permalink
add account contract impl for simulation only (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem authored Jun 14, 2024
1 parent 16f9c87 commit 8c8fbd9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/governor.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub mod Governor {
use governance::staker::{IStakerDispatcherTrait};
use starknet::{
get_block_timestamp, get_caller_address, get_contract_address,
syscalls::{replace_class_syscall}
syscalls::{replace_class_syscall}, AccountContract
};
use super::{
IStakerDispatcher, ContractAddress, IGovernor, Config, ProposalInfo, Call, ExecutionState,
Expand Down Expand Up @@ -448,4 +448,23 @@ pub mod Governor {
replace_class_syscall(class_hash).unwrap();
}
}

// This implementation exists solely for the purpose of allowing simulation of calls from the governor with the flag to skip validation
impl GovernorAccountContractForSimulation of AccountContract<ContractState> {
fn __validate_declare__(self: @ContractState, class_hash: felt252) -> felt252 {
panic!("Not allowed");
0
}
fn __validate__(ref self: ContractState, calls: Array<Call>) -> felt252 {
panic!("Not allowed");
0
}
fn __execute__(ref self: ContractState, mut calls: Array<Call>) -> Array<Span<felt252>> {
let mut results: Array<Span<felt252>> = array![];
while let Option::Some(call) = calls.pop_front() {
results.append(call.execute());
};
results
}
}
}

0 comments on commit 8c8fbd9

Please sign in to comment.