Skip to content
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

add account contract impl for simulation only #57

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}
Loading