Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Mar 6, 2024
1 parent 96617c6 commit 6937bdf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/call_trait.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ pub impl HashCall<S, +HashStateTrait<S>, +Drop<S>, +Copy<S>> of Hash<@Call, S> {
let mut s = state.update_with((*value.to)).update_with(*value.selector);

let mut data_span: Span<felt252> = *value.calldata;
while let Option::Some(word) = data_span.pop_front() {
s = s.update(*word);
loop {
match data_span.pop_front() {
Option::Some(word) => { s = s.update(*word); },
Option::None => { break; }
};
};

s
Expand Down
19 changes: 12 additions & 7 deletions src/timelock.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,14 @@ pub mod Timelock {
// Take a list of calls and convert it to a unique identifier for the execution
// Two lists of calls will always have the same ID if they are equivalent
// A list of calls can only be queued and executed once. To make 2 different calls, add an empty call.
pub(crate) fn to_id(mut calls: Span<Call>) -> felt252 {
pub fn to_id(mut calls: Span<Call>) -> felt252 {
let mut state = selector!("ekubo::governance::Timelock");
while let Option::Some(call) = calls.pop_front() {
state = LegacyHash::hash(state, call);
};
state
loop {
match calls.pop_front() {
Option::Some(call) => { state = LegacyHash::hash(state, call) },
Option::None => { break state; }
};
}
}

#[generate_trait]
Expand Down Expand Up @@ -221,8 +223,11 @@ pub mod Timelock {

let mut results: Array<Span<felt252>> = ArrayTrait::new();

while let Option::Some(call) = calls.pop_front() {
results.append(call.execute());
loop {
match calls.pop_front() {
Option::Some(call) => { results.append(call.execute()); },
Option::None => { break; }
};
};

self.emit(Executed { id, });
Expand Down

0 comments on commit 6937bdf

Please sign in to comment.