Skip to content

Commit

Permalink
Adjust multicall function
Browse files Browse the repository at this point in the history
  • Loading branch information
clint419 committed Dec 1, 2023
1 parent a94263d commit fa07c21
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/contracts/multicall.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,24 @@ mod Multicall {
impl Multicall of super::IMulticall<ContractState> {
fn multicall(ref self: ContractState, _targets: Array<Call>) -> Array<MulticallResult> {
let mut results: Array<MulticallResult> = array![];
let mut i = 0;

let mut targets = _targets;
loop {
if i == _targets.len() {
break;
match targets.pop_front() {
Option::Some(Call{address,
selector,
calldata }) => {
let returnData = starknet::call_contract_syscall(
address, selector, calldata.span()
)
.unwrap_syscall();

// TODO: when Sierra has the ability to catch a revert to resume execution
// we should add false to the result to indicate a failure
results.append(MulticallResult { success: true, returnData: returnData });
},
Option::None => { break; }
}
let Call{address, selector, calldata } = _targets[i].clone();
let returnData = starknet::call_contract_syscall(
address: address, entry_point_selector: selector, calldata: calldata.span(),
)
.unwrap_syscall();

// TODO: when Sierra has the ability to catch a revert to resume execution
// we should add false to the result to indicate a failure
results.append(MulticallResult { success: true, returnData: returnData });
i += 1;
};

results
}

Expand Down

0 comments on commit fa07c21

Please sign in to comment.