-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch simply adds a cancel core script that can be used (a) as a nop to cancel a chain, or (b) to directly call `nonceManager.cancel(nonce)` with one or more nonces. These are merely given as helpers for the end-users.
- Loading branch information
Showing
5 changed files
with
74 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
pragma solidity 0.8.27; | ||
|
||
import {IQuarkWallet} from "quark-core/src/QuarkWallet.sol"; | ||
import {QuarkNonceManager} from "quark-core/src/QuarkNonceManager.sol"; | ||
|
||
/** | ||
* @title Cancel Core Script | ||
* @notice Core transaction script that can be used to cancel quark operations. | ||
* @author Compound Labs, Inc. | ||
*/ | ||
contract Cancel { | ||
|
||
/** | ||
* @notice May cancel a script by being run as a no-op (no operation). | ||
*/ | ||
function nop() external pure {} | ||
|
||
/** | ||
* @notice Cancels a script by calling into nonce manager to cancel the script's nonce. | ||
* @param nonce The nonce of the quark operation to cancel (exhaust) | ||
*/ | ||
function cancel(bytes32 nonce) external { | ||
nonceManager().cancel(nonce); | ||
} | ||
|
||
/** | ||
* @notice Cancels many scripts by calling into nonce manager to cancel each script's nonce. | ||
* @param nonces A list of nonces of the quark operations to cancel (exhaust) | ||
*/ | ||
function cancelMany(bytes32[] calldata nonces) external { | ||
QuarkNonceManager manager = nonceManager(); | ||
for (uint256 i = 0; i < nonces.length; i++) { | ||
bytes32 nonce = nonces[i]; | ||
manager.cancel(nonce); | ||
} | ||
} | ||
|
||
function nonceManager() internal view returns (QuarkNonceManager) { | ||
return QuarkNonceManager(IQuarkWallet(address(this)).nonceManager()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters