Skip to content

Commit

Permalink
Merge pull request #109 from gnosis/fix-guardable
Browse files Browse the repository at this point in the history
Fix guardable
  • Loading branch information
auryn-macmillan authored Feb 16, 2023
2 parents 2ddb81b + 22f0836 commit 66d8f6f
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 32 deletions.
Binary file added audits/ZodiacModifierUpdateFeb2023.pdf
Binary file not shown.
56 changes: 36 additions & 20 deletions contracts/core/Module.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ abstract contract Module is FactoryFriendly, Guardable {
bytes memory data,
Enum.Operation operation
) internal returns (bool success) {
/// Check if a transactioon guard is enabled.
if (guard != address(0)) {
IGuard(guard).checkTransaction(
address currentGuard = guard;
if (currentGuard != address(0)) {
IGuard(currentGuard).checkTransaction(
/// Transaction info used by module transactions.
to,
value,
Expand All @@ -63,15 +63,20 @@ abstract contract Module is FactoryFriendly, Guardable {
bytes("0x"),
msg.sender
);
}
success = IAvatar(target).execTransactionFromModule(
to,
value,
data,
operation
);
if (guard != address(0)) {
IGuard(guard).checkAfterExecution(bytes32("0x"), success);
success = IAvatar(target).execTransactionFromModule(
to,
value,
data,
operation
);
IGuard(currentGuard).checkAfterExecution(bytes32("0x"), success);
} else {
success = IAvatar(target).execTransactionFromModule(
to,
value,
data,
operation
);
}
return success;
}
Expand All @@ -88,9 +93,9 @@ abstract contract Module is FactoryFriendly, Guardable {
bytes memory data,
Enum.Operation operation
) internal returns (bool success, bytes memory returnData) {
/// Check if a transactioon guard is enabled.
if (guard != address(0)) {
IGuard(guard).checkTransaction(
address currentGuard = guard;
if (currentGuard != address(0)) {
IGuard(currentGuard).checkTransaction(
/// Transaction info used by module transactions.
to,
value,
Expand All @@ -105,11 +110,22 @@ abstract contract Module is FactoryFriendly, Guardable {
bytes("0x"),
msg.sender
);
}
(success, returnData) = IAvatar(target)
.execTransactionFromModuleReturnData(to, value, data, operation);
if (guard != address(0)) {
IGuard(guard).checkAfterExecution(bytes32("0x"), success);
(success, returnData) = IAvatar(target)
.execTransactionFromModuleReturnData(
to,
value,
data,
operation
);
IGuard(currentGuard).checkAfterExecution(bytes32("0x"), success);
} else {
(success, returnData) = IAvatar(target)
.execTransactionFromModuleReturnData(
to,
value,
data,
operation
);
}
return (success, returnData);
}
Expand Down
13 changes: 12 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ export default {
sources: "contracts",
},
solidity: {
compilers: [{ version: "0.8.6" }, { version: "0.6.12" }],
compilers: [
{
version: "0.8.6",
settings: {
optimizer: {
enabled: true,
runs: 1000,
},
},
},
{ version: "0.6.12" },
],
},
networks: {
mainnet: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
"dependencies": {
"@gnosis.pm/mock-contract": "^4.0.0",
"@gnosis.pm/safe-contracts": "1.3.0",
"@openzeppelin/contracts": "^4.3.2",
"@openzeppelin/contracts-upgradeable": "^4.2.0",
"@openzeppelin/contracts": "^4.8.1",
"@openzeppelin/contracts-upgradeable": "^4.8.1",
"ethers": "^5.7.1"
},
"peerDependencies": {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,15 @@
"@types/sinon-chai" "^3.2.3"
"@types/web3" "1.0.19"

"@openzeppelin/contracts-upgradeable@^4.2.0":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.0.tgz#26688982f46969018e3ed3199e72a07c8d114275"
integrity sha512-5GeFgqMiDlqGT8EdORadp1ntGF0qzWZLmEY7Wbp/yVhN7/B3NNzCxujuI77ktlyG81N3CUZP8cZe3ZAQ/cW10w==

"@openzeppelin/contracts@^4.3.2":
version "4.8.0"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.0.tgz#6854c37df205dd2c056bdfa1b853f5d732109109"
integrity sha512-AGuwhRRL+NaKx73WKRNzeCxOCOCxpaqF+kp8TJ89QzAipSwZy/NoflkWaL9bywXFRhIzXt8j38sfF7KBKCPWLw==
"@openzeppelin/contracts-upgradeable@^4.8.1":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts-upgradeable/-/contracts-upgradeable-4.8.1.tgz#363f7dd08f25f8f77e16d374350c3d6b43340a7a"
integrity sha512-1wTv+20lNiC0R07jyIAbHU7TNHKRwGiTGRfiNnA8jOWjKT98g5OgLpYWOi40Vgpk8SPLA9EvfJAbAeIyVn+7Bw==

"@openzeppelin/contracts@^4.8.1":
version "4.8.1"
resolved "https://registry.yarnpkg.com/@openzeppelin/contracts/-/contracts-4.8.1.tgz#709cfc4bbb3ca9f4460d60101f15dac6b7a2d5e4"
integrity sha512-xQ6eUZl+RDyb/FiZe1h+U7qr/f4p/SrTSQcTPH2bjur3C5DbuW/zFgCU/b1P/xcIaEqJep+9ju4xDRi3rmChdQ==

"@resolver-engine/core@^0.3.3":
version "0.3.3"
Expand Down

0 comments on commit 66d8f6f

Please sign in to comment.