generated from gnosisguild/zodiac-mod-starter-kit
-
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.
Hit an issue with the `moduleOnly` modifier. In `OSXAdapter.text.ts`, the call to `OSXAdapter.execTransactionFromModule()` fails with `NotAuthorized`, although the calling account is enabled as a module. For the time being, I've disabled the `onlyModule()` check and will return to this issue later.
- Loading branch information
1 parent
a04bcc6
commit a25581e
Showing
7 changed files
with
117 additions
and
90 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
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: LGPL-3.0-only | ||
pragma solidity >=0.8.26; | ||
|
||
import "../Types.sol"; | ||
|
||
contract MockOSXDAO { | ||
/// @notice The ID of the permission required to call the OSx `execute` function. | ||
bytes32 public constant EXECUTE_PERMISSION_ID = keccak256("EXECUTE_PERMISSION"); | ||
|
||
mapping(address sender => mapping(bytes32 permissionId => bool granted)) public permissions; | ||
|
||
error NotAuthorized(address unacceptedAddress); | ||
error RecipentAlreadyHasPermission(address recipient); | ||
|
||
receive() external payable {} | ||
|
||
function grantExecutePermission(address recipient) external { | ||
require(!permissions[recipient][EXECUTE_PERMISSION_ID], RecipentAlreadyHasPermission(recipient)); | ||
permissions[recipient][EXECUTE_PERMISSION_ID] = true; | ||
} | ||
|
||
function execute( | ||
bytes32, | ||
Action[] memory actions, | ||
uint256 | ||
) external returns (bytes[] memory responses, uint256 failureMap) { | ||
require(permissions[msg.sender][EXECUTE_PERMISSION_ID], NotAuthorized(msg.sender)); | ||
|
||
bool success; | ||
for (uint i = 0; i < actions.length; i++) { | ||
(success, responses[i]) = actions[i].to.call{value: actions[i].value}(actions[i].data); | ||
|
||
if (!success) { | ||
assembly { | ||
revert(add(responses, 0x20), mload(responses)) | ||
} | ||
} | ||
} | ||
|
||
failureMap = 0; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { expect } from "chai" | ||
import { ethers, deployments, getNamedAccounts } from "hardhat" | ||
|
||
const setup = async () => { | ||
await deployments.fixture(["moduleProxy"]) | ||
const { deployer, tester } = await getNamedAccounts() | ||
const buttonDeployment = await deployments.get("Button") | ||
const OSXAdapterProxyDeployment = await deployments.get("OSXAdapterProxy") | ||
const buttonContract = await ethers.getContractAt("Button", buttonDeployment.address) | ||
const OSXAdapterProxyContract = await ethers.getContractAt("OSXAdapter", OSXAdapterProxyDeployment.address) | ||
return { buttonContract, OSXAdapterProxyContract, deployer, tester } | ||
} | ||
|
||
describe("OSXAdapter", function () { | ||
it("Should be possible to 'press the button' through OSXAdapter", async function () { | ||
const { buttonContract, OSXAdapterProxyContract, deployer } = await setup() | ||
expect(await buttonContract.pushes()).to.equal(0) | ||
|
||
expect(await OSXAdapterProxyContract.enableModule(deployer)) | ||
|
||
const enabledModules = await OSXAdapterProxyContract.getModulesPaginated( | ||
"0x0000000000000000000000000000000000000001", | ||
10, | ||
) | ||
|
||
const data = buttonContract.interface.encodeFunctionData("pushButton") | ||
|
||
const txData = { | ||
to: await buttonContract.getAddress(), | ||
value: 0, | ||
data: data, | ||
operation: 0, | ||
} | ||
|
||
const tx = OSXAdapterProxyContract.interface.encodeFunctionData("execTransactionFromModule", [ | ||
txData.to, | ||
txData.value, | ||
txData.data, | ||
txData.operation, | ||
]) | ||
|
||
console.log("Enabled Modules:", enabledModules[1]) | ||
console.log("Deployer Address:", deployer) | ||
console.log("txData:", txData) | ||
console.log("tx:", tx) | ||
|
||
await OSXAdapterProxyContract.execTransactionFromModule(txData.to, txData.value, txData.data, txData.operation) | ||
|
||
expect(await buttonContract.pushes()).to.equal(1) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.