From 272ab00d42d7bbc35157bb3b2077c12de4bb9816 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 10:22:21 +0200 Subject: [PATCH 1/9] Create virtual event emitter funcs in MultiSigGeneric --- contracts/multisigs/MultiSigGeneric.sol | 92 ++++++++++++++++++++----- 1 file changed, 74 insertions(+), 18 deletions(-) diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index 476788b16..19e126d73 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -110,13 +110,7 @@ contract MultiSigGeneric is approvalsRequired = _approvalsRequired; requireExecution = _requireExecution; transactionExpiry = _transactionExpiry; - emit InitializedMultiSig( - address(this), - owners, - approvalsRequired, - requireExecution, - transactionExpiry - ); + emitInitializedMultiSig(owners, approvalsRequired, requireExecution, transactionExpiry); } /// @dev Allows to add new owners. Transaction has to be sent by wallet. @@ -130,7 +124,7 @@ contract MultiSigGeneric is // set the owner address to false in mapping isOwner[owners[o]] = true; } - emit OwnersAdded(address(this), owners); + emitOwnersAdded(owners); } /// @dev Allows to remove owners. Transaction has to be sent by wallet. @@ -148,7 +142,7 @@ contract MultiSigGeneric is // set the owner address to false in mapping isOwner[owners[o]] = false; } - emit OwnersRemoved(address(this), owners); + emitOwnersRemoved(owners); // adjust the approval threshold downward if we've removed more members than can meet the currently // set threshold level. (ex. Prevent 10 owners total needing 15 approvals to execute txs) if (approvalsRequired > activeOwnersCount) changeApprovalsRequirement(activeOwnersCount); @@ -163,7 +157,7 @@ contract MultiSigGeneric is ) public virtual override onlyWallet ownerExists(currOwner) ownerDoesNotExist(newOwner) { isOwner[currOwner] = false; isOwner[newOwner] = true; - emit OwnerReplaced(address(this), currOwner, newOwner); + emitOwnerReplaced(currOwner, newOwner); } /// @dev Allows to change the number of required confirmations. Transaction has to be sent by wallet. @@ -178,21 +172,21 @@ contract MultiSigGeneric is validApprovalsRequirement(activeOwnersCount, _approvalsRequired) { approvalsRequired = _approvalsRequired; - emit ApprovalsRequiredChanged(address(this), _approvalsRequired); + emitApprovalsRequiredChanged(_approvalsRequired); } /// @dev Allows to change whether explicit execution step is needed once the required number of confirmations is met. Transaction has to be sent by wallet. /// @param _requireExecution Is an explicit execution step is needed function changeRequireExecution(bool _requireExecution) public virtual override onlyWallet { requireExecution = _requireExecution; - emit RequireExecutionChanged(address(this), _requireExecution); + emitRequireExecutionChanged(_requireExecution); } /// @dev Allows to change the expiry time for transactions. /// @param _transactionExpiry time that a newly created transaction is valid for function changeTransactionExpiry(uint256 _transactionExpiry) public virtual override onlyWallet { transactionExpiry = _transactionExpiry; - emit ExpiryChanged(address(this), _transactionExpiry); + emitExpiryChanged(_transactionExpiry); } /// @dev Allows an owner to submit and confirm a transaction. @@ -227,7 +221,7 @@ contract MultiSigGeneric is { confirmations[transactionId].confirmationsByOwner[msg.sender] = true; confirmations[transactionId].count += 1; - emit TransactionConfirmed(address(this), msg.sender, transactionId); + emitTransactionConfirmed(msg.sender, transactionId); // if execution is required, do not auto execute if (!requireExecution) { executeTransaction(transactionId); @@ -250,7 +244,7 @@ contract MultiSigGeneric is { confirmations[transactionId].confirmationsByOwner[msg.sender] = false; confirmations[transactionId].count -= 1; - emit TransactionConfirmationRevoked(address(this), msg.sender, transactionId); + emitTransactionConfirmationRevoked(msg.sender, transactionId); } /// @dev Allows current owners to revoke a confirmation for a non-executed transaction from a removed/non-current owner. @@ -272,7 +266,7 @@ contract MultiSigGeneric is require(!isOwner[formerOwner], "Attempting to revert confirmation of a current owner"); confirmations[transactionId].confirmationsByOwner[formerOwner] = false; confirmations[transactionId].count -= 1; - emit TransactionConfirmationRevoked(address(this), formerOwner, transactionId); + emitTransactionConfirmationRevoked(formerOwner, transactionId); } /// @dev Allows anyone to execute a confirmed transaction. @@ -290,7 +284,7 @@ contract MultiSigGeneric is MultiSigStorage.Transaction storage txn = transactions[transactionId]; txn.executed = true; Utils._execute(txn.destination, txn.value, txn.data); - emit TransactionExecuted(address(this), transactionId); + emitTransactionExecuted(transactionId); } /// @dev Returns the confirmation status of a transaction. @@ -348,6 +342,68 @@ contract MultiSigGeneric is metadata: metadata }); transactionCount += 1; - emit TransactionSubmitted(address(this), msg.sender, transactionId, metadata); + emitTransactionSubmitted(msg.sender, transactionId, metadata); + } + + function emitInitializedMultiSig( + address[] memory owners, + uint256 _approvalsRequired, + bool _requireExecution, + uint256 _transactionExpiry + ) public virtual { + emit InitializedMultiSig( + address(this), + owners, + _approvalsRequired, + _requireExecution, + _transactionExpiry + ); + } + + function emitOwnersAdded(address[] memory owners) public virtual { + emit OwnersAdded(address(this), owners); + } + + function emitOwnersRemoved(address[] memory owners) public virtual { + emit OwnersRemoved(address(this), owners); + } + + function emitOwnerReplaced(address currOwner, address newOwner) public virtual { + emit OwnerReplaced(address(this), currOwner, newOwner); + } + + function emitApprovalsRequiredChanged(uint256 _approvalsRequired) public virtual { + emit ApprovalsRequiredChanged(address(this), _approvalsRequired); + } + + function emitRequireExecutionChanged(bool _requireExecution) public virtual { + emit RequireExecutionChanged(address(this), _requireExecution); + } + + function emitExpiryChanged(uint256 _transactionExpiry) public virtual { + emit ExpiryChanged(address(this), _transactionExpiry); + } + + function emitTransactionSubmitted( + address sender, + uint256 transactionId, + bytes memory metadata + ) public virtual { + emit TransactionSubmitted(address(this), sender, transactionId, metadata); + } + + function emitTransactionConfirmed(address sender, uint256 transactionId) public virtual { + emit TransactionConfirmed(address(this), sender, transactionId); + } + + function emitTransactionConfirmationRevoked( + address sender, + uint256 transactionId + ) public virtual { + emit TransactionConfirmationRevoked(address(this), sender, transactionId); + } + + function emitTransactionExecuted(uint256 transactionId) public virtual { + emit TransactionExecuted(address(this), transactionId); } } From 524bd23dc47f32c83846dc4aa852b8a4c1724d75 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 10:30:44 +0200 Subject: [PATCH 2/9] Override emit funcs in EndowmentMultiSig --- .../endowment-multisig/EndowmentMultiSig.sol | 69 +++++-------------- .../EndowmentMultiSigEmitter.sol | 19 ----- .../interfaces/IEndowmentMultiSigEmitter.sol | 6 -- 3 files changed, 19 insertions(+), 75 deletions(-) diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol index f1254e479..5b5cfacbb 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol @@ -44,15 +44,13 @@ contract EndowmentMultiSig is MultiSigGeneric { /// @dev Allows to add new owners. Transaction has to be sent by wallet. /// @param owners Addresses of new owners. - function addOwners(address[] memory owners) public override { - super.addOwners(owners); + function emitOwnersAdded(address[] memory owners) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownersAddedEndowment(ENDOWMENT_ID, owners); } /// @dev Allows to remove owners. Transaction has to be sent by wallet. /// @param owners Addresses of removed owners. - function removeOwners(address[] memory owners) public override { - super.removeOwners(owners); + function emitOwnersRemoved(address[] memory owners) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownersRemovedEndowment(ENDOWMENT_ID, owners); } @@ -62,8 +60,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @param currOwner the owner to be replaced * @param newOwner the new owner to add */ - function replaceOwner(address currOwner, address newOwner) public override { - super.replaceOwner(currOwner, newOwner); + function emitOwnerReplaced(address currOwner, address newOwner) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownerReplacedEndowment( ENDOWMENT_ID, currOwner, @@ -76,8 +73,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the requirementChangeEndowment event * @param _approvalsRequired the new required number of signatures */ - function changeApprovalsRequirement(uint256 _approvalsRequired) public override { - super.changeApprovalsRequirement(_approvalsRequired); + function emitApprovalsRequiredChanged(uint256 _approvalsRequired) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).approvalsRequirementChangedEndowment( ENDOWMENT_ID, _approvalsRequired @@ -89,8 +85,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the transactionExpiryChangeEndowment event * @param _transactionExpiry the new validity for newly created transactions */ - function changeTransactionExpiry(uint256 _transactionExpiry) public override { - super.changeTransactionExpiry(_transactionExpiry); + function emitExpiryChanged(uint256 _transactionExpiry) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).expiryChangedEndowment( ENDOWMENT_ID, _transactionExpiry @@ -102,29 +97,21 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the requirementChangeEndowment event * @param _requireExecution Explicit execution step is needed */ - function changeRequireExecution(bool _requireExecution) public override { - super.changeRequireExecution(_requireExecution); + function emitRequireExecutionChanged(bool _requireExecution) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).requireExecutionChangedEndowment( ENDOWMENT_ID, _requireExecution ); } - /// @dev Allows an owner to submit and confirm a transaction. - /// @param destination Transaction target address. - /// @param value Transaction ether value. - /// @param data Transaction data payload. - /// @return transactionId transaction ID. - function submitTransaction( - address destination, - uint256 value, - bytes memory data, + function emitTransactionSubmitted( + address sender, + uint256 transactionId, bytes memory metadata - ) public virtual override returns (uint256 transactionId) { - transactionId = super.submitTransaction(destination, value, data, metadata); + ) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionSubmittedEndowment( ENDOWMENT_ID, - msg.sender, + sender, transactionId, metadata ); @@ -135,11 +122,10 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the confirmEndowment event * @param transactionId the transaction id */ - function confirmTransaction(uint256 transactionId) public override { - super.confirmTransaction(transactionId); + function emitTransactionConfirmed(address sender, uint256 transactionId) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmedEndowment( ENDOWMENT_ID, - msg.sender, + sender, transactionId ); } @@ -149,29 +135,13 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the revokeEndowment event * @param transactionId the transaction id */ - function revokeConfirmation(uint256 transactionId) public override { - super.revokeConfirmation(transactionId); - IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmationRevokedEndowment( - ENDOWMENT_ID, - msg.sender, - transactionId - ); - } - - /** - * @notice overrides the generic multisig revokeConfirmationOfFormerOwner function - * @dev emits the revokeEndowment event - * @param transactionId the transaction id - * @param formerOwner Address of the non-current owner, whos confirmation is being revoked - */ - function revokeConfirmationOfFormerOwner( - uint256 transactionId, - address formerOwner + function emitTransactionConfirmationRevoked( + address sender, + uint256 transactionId ) public override { - super.revokeConfirmationOfFormerOwner(transactionId, formerOwner); - IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmationOfFormerOwnerRevokedEndowment( + IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmationRevokedEndowment( ENDOWMENT_ID, - formerOwner, + sender, transactionId ); } @@ -181,8 +151,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the executeEndowment event, overrides underlying execute function * @param transactionId the transaction id */ - function executeTransaction(uint256 transactionId) public override { - super.executeTransaction(transactionId); + function emitTransactionExecuted(uint256 transactionId) public override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionExecutedEndowment( ENDOWMENT_ID, transactionId diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSigEmitter.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSigEmitter.sol index 4a443442f..393d6d0a9 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSigEmitter.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSigEmitter.sol @@ -29,11 +29,6 @@ contract EndowmentMultiSigEmitter is IEndowmentMultiSigEmitter, Initializable { ); event TransactionConfirmed(uint256 endowmentId, address owner, uint256 transactionId); event TransactionConfirmationRevoked(uint256 endowmentId, address owner, uint256 transactionId); - event TransactionConfirmationOfFormerOwnerRevoked( - uint256 endowmentId, - address formerOwner, - uint256 transactionId - ); event TransactionExecuted(uint256 endowmentId, uint256 transactionId); event OwnersAdded(uint256 endowmentId, address[] owners); event OwnersRemoved(uint256 endowmentId, address[] owners); @@ -132,20 +127,6 @@ contract EndowmentMultiSigEmitter is IEndowmentMultiSigEmitter, Initializable { emit TransactionConfirmationRevoked(endowmentId, owner, transactionId); } - /** - * @notice emits the ConfirmationOfFormerOwnerRevoked event - * @param endowmentId the endowment id - * @param formerOwner the former owner being revoked - * @param transactionId the transaction id - */ - function transactionConfirmationOfFormerOwnerRevokedEndowment( - uint256 endowmentId, - address formerOwner, - uint256 transactionId - ) public isEmitter { - emit TransactionConfirmationOfFormerOwnerRevoked(endowmentId, formerOwner, transactionId); - } - /** * @notice emits the TransactionExecuted event * @param endowmentId the endowment id diff --git a/contracts/normalized_endowment/endowment-multisig/interfaces/IEndowmentMultiSigEmitter.sol b/contracts/normalized_endowment/endowment-multisig/interfaces/IEndowmentMultiSigEmitter.sol index ea599c7fb..99782d70f 100644 --- a/contracts/normalized_endowment/endowment-multisig/interfaces/IEndowmentMultiSigEmitter.sol +++ b/contracts/normalized_endowment/endowment-multisig/interfaces/IEndowmentMultiSigEmitter.sol @@ -14,12 +14,6 @@ interface IEndowmentMultiSigEmitter { uint256 transactionId ) external; - function transactionConfirmationOfFormerOwnerRevokedEndowment( - uint256 endowmentId, - address formerOwner, - uint256 transactionId - ) external; - function transactionSubmittedEndowment( uint256 endowmentId, address owner, From 5395e2f2b5c47c4b917f72359c96e2a2c48fcfee Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 10:37:12 +0200 Subject: [PATCH 3/9] Make MultiSigGeneric.initialize internal --- contracts/multisigs/APTeamMultiSig.sol | 11 ++++++++++- contracts/multisigs/CharityApplications.sol | 5 ----- contracts/multisigs/MultiSigGeneric.sol | 2 +- contracts/multisigs/scripts/deployAPTeamMultiSig.ts | 2 +- .../endowment-multisig/EndowmentMultiSig.sol | 5 ----- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/contracts/multisigs/APTeamMultiSig.sol b/contracts/multisigs/APTeamMultiSig.sol index 9d36fae48..903952cac 100644 --- a/contracts/multisigs/APTeamMultiSig.sol +++ b/contracts/multisigs/APTeamMultiSig.sol @@ -2,4 +2,13 @@ pragma solidity ^0.8.16; import {MultiSigGeneric} from "./MultiSigGeneric.sol"; -contract APTeamMultiSig is MultiSigGeneric {} +contract APTeamMultiSig is MultiSigGeneric { + function initializeAPTeam( + address[] memory owners, + uint256 _approvalsRequired, + bool _requireExecution, + uint256 _transactionExpiry + ) public initializer { + super.initialize(owners, _approvalsRequired, _requireExecution, _transactionExpiry); + } +} diff --git a/contracts/multisigs/CharityApplications.sol b/contracts/multisigs/CharityApplications.sol index f4055b38f..4001bc306 100644 --- a/contracts/multisigs/CharityApplications.sol +++ b/contracts/multisigs/CharityApplications.sol @@ -62,11 +62,6 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp _; } - // @dev overrides the generic multisig initializer and restricted function - function initialize(address[] memory, uint256, bool, uint256) public override initializer { - revert("Not Implemented"); - } - /** * @notice Initialize the charity applications contract * where anyone can submit applications to open a charity endowment on AP for review and approval diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index 19e126d73..e375c7a58 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -98,7 +98,7 @@ contract MultiSigGeneric is uint256 _approvalsRequired, bool _requireExecution, uint256 _transactionExpiry - ) public virtual initializer validApprovalsRequirement(owners.length, _approvalsRequired) { + ) internal initializer validApprovalsRequirement(owners.length, _approvalsRequired) { require(owners.length > 0, "Must pass at least one owner address"); for (uint256 i = 0; i < owners.length; i++) { require(!isOwner[owners[i]] && owners[i] != address(0)); diff --git a/contracts/multisigs/scripts/deployAPTeamMultiSig.ts b/contracts/multisigs/scripts/deployAPTeamMultiSig.ts index 03e4b1d0d..d7837325e 100644 --- a/contracts/multisigs/scripts/deployAPTeamMultiSig.ts +++ b/contracts/multisigs/scripts/deployAPTeamMultiSig.ts @@ -27,7 +27,7 @@ export async function deployAPTeamMultiSig( // deploy proxy logger.out("Deploying proxy..."); - const apTeamMultiSigData = apTeamMultiSig.interface.encodeFunctionData("initialize", [ + const apTeamMultiSigData = apTeamMultiSig.interface.encodeFunctionData("initializeAPTeam", [ apTeamMultisigOwners.map((x) => x.address), config.AP_TEAM_MULTISIG_DATA.threshold, config.AP_TEAM_MULTISIG_DATA.requireExecution, diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol index 5b5cfacbb..37adf26dc 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol @@ -13,11 +13,6 @@ contract EndowmentMultiSig is MultiSigGeneric { uint256 public ENDOWMENT_ID; address public EMITTER_ADDRESS; - // @dev overrides the generic multisig initializer and restricted function - function initialize(address[] memory, uint256, bool, uint256) public override initializer { - revert("Not Implemented"); - } - /** * @notice initialize the multisig with the endowment id and the endowment multisig emitter address * @dev special initialize function for endowment multisig From f3219cb6200ad5837ce65e229564bbe941f655d2 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 10:49:59 +0200 Subject: [PATCH 4/9] Use Validator in MSs --- contract-address.json | 78 +++++++++---------- contracts/multisigs/CharityApplications.sol | 14 ++-- contracts/multisigs/MultiSigGeneric.sol | 13 ++-- .../endowment-multisig/EndowmentMultiSig.sol | 8 +- 4 files changed, 58 insertions(+), 55 deletions(-) diff --git a/contract-address.json b/contract-address.json index 8c10ad53e..a4189bc76 100644 --- a/contract-address.json +++ b/contract-address.json @@ -154,30 +154,30 @@ }, "31337": { "accounts": { - "diamond": "0x16fb8e3ab0AF1da9c6e6a589DD025E6558F496Bc", + "diamond": "0x73eccD6288e117cAcA738BDAD4FEC51312166C1A", "facets": { - "accountsDeployContract": "0xC4A743126DCcA4DF85B8f75B6eD113bb69dD65A1", - "accountsDepositWithdrawEndowments": "0xA303374bda3A6Ce7550514E6681228Ca12020BBA", - "accountsDonationMatch": "0xB6B18cae509Fcf3542FF6975C2Da06CAAc9773c5", - "accountsAllowance": "0x7F6D5d1bDFB4b281374285510A845cb140d4367b", - "accountsCreateEndowment": "0x455A2aC2F917956c0f2664992C1DDd9Cd6562976", - "accountsDaoEndowments": "0x4060eF0D5a7F0633c5927F7E05041dd7Fcd95f42", - "accountsQueryEndowments": "0xA9526DFDd289b2C2ADa83E07c6dd293AA2C5fEe9", - "accountsStrategy": "0x32Ed2BD67238Be274E127096F42f0a4061aC0Bff", - "accountsSwapRouter": "0x4dcA4bFA0bAa0C8ce741b92B255D967599d994f0", - "accountsUpdate": "0xD7a385546a6a2355C6a1DfAdf33b55c43e2C19B0", - "accountsUpdateEndowments": "0xfAB9d4FA5c03Aa5EaccE715d02E6db648cEE91a3", - "accountsUpdateEndowmentSettingsController": "0x715214AeEf7D4C78b9c329cc4D7375cC08670843", - "accountsUpdateStatusEndowments": "0x15E1268353F6F19D9de2722bD60eC1081b45D3a6", - "diamondCutFacet": "0x8e1f69CfFd8DaD657bF18B91D75BcD26CD6F43AC", - "diamondInitFacet": "0x904df20E7d5A1D577c3763FC7bF35EFa51Df94da", - "diamondLoupeFacet": "0x9cD5998cd48385cb69AE7AaDdFaC83A5DA185FaA", - "ownershipFacet": "0x43dFD957bB91b568176E976A8d4e8ab4E94aeBfD" + "accountsDeployContract": "0xe6b98F104c1BEf218F3893ADab4160Dc73Eb8367", + "accountsDepositWithdrawEndowments": "0x1e2F4432bFeF9E9Ad39DA6d272F4aFf33629c770", + "accountsDonationMatch": "0x5C7c905B505f0Cf40Ab6600d05e677F717916F6B", + "accountsAllowance": "0x446e7636a5Fa9af46c3718719e465B547248bF62", + "accountsCreateEndowment": "0x505d59ffFd312983Cc0eD114d7F117B91520d742", + "accountsDaoEndowments": "0x0D4ff719551E23185Aeb16FFbF2ABEbB90635942", + "accountsQueryEndowments": "0xfbAb4aa40C202E4e80390171E82379824f7372dd", + "accountsStrategy": "0xcEC91d876E8f003110D43381359b1bAd124e7F2b", + "accountsSwapRouter": "0xed17543171C1459714cdC6519b58fFcC29A3C3c9", + "accountsUpdate": "0x85C5Dd61585773423e378146D4bEC6f8D149E248", + "accountsUpdateEndowments": "0x677df0cb865368207999F2862Ece576dC56D8dF6", + "accountsUpdateEndowmentSettingsController": "0x0Cf17D5DcDA9cF25889cEc9ae5610B0FB9725F65", + "accountsUpdateStatusEndowments": "0xAfe1b5bdEbD4ae65AF2024738bf0735fbb65d44b", + "diamondCutFacet": "0x2dE080e97B0caE9825375D31f5D0eD5751fDf16D", + "diamondInitFacet": "0x381445710b5e73d34aF196c53A3D5cDa58EDBf7A", + "diamondLoupeFacet": "0x2fc631e4B3018258759C52AF169200213e84ABab", + "ownershipFacet": "0x63cf2Cd54fE91e3545D1379abf5bfd194545259d" } }, "axelar": { - "gasService": "0x2Eb2BBAAF8D16E8BA07BD40D141a7E25C6dD9945", - "gateway": "0x4ee108458a4D97dAa2f8eF90A73942AC7B3a9209" + "gasService": "0x8464135c8F25Da09e49BC8782676a84730C318bC", + "gateway": "0x71C95911E9a5D330f4D621842EC243EE1343292e" }, "donationMatch": { "emitter": "", @@ -192,8 +192,8 @@ "proxy": "" }, "gasFwd": { - "factory": "0xf342D22125Eddc24c6c3D716E048388D1415C20d", - "implementation": "0x07dEF209701605580893ecd7C3cE2340f5b16875" + "factory": "0xF818A7C2AFC45cF4B9DDC48933C9A1edD624e46f", + "implementation": "0xC76A71C4492c11bbaDC841342C4Cb470b5d12193" }, "giftcards": { "implementation": "", @@ -254,34 +254,34 @@ "implementation": "" }, "indexFund": { - "implementation": "0x59c7E6B2c565Ff92B762523BD6B778CE66dC0302", - "proxy": "0x9A676e781A523b5d0C0e43731313A708CB607508" + "implementation": "0xe0B39353F69b54e945364ffcdDD7901697Ca0166", + "proxy": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" }, "multiSig": { "charityApplications": { - "implementation": "0x9687796759CAbecC1674A4Aaf23889fC9EC2FCA2", - "proxy": "0xD63c1597435d2E16d7f216A12A3dA65B3bF12241" + "implementation": "0x8613A4029EaA95dA61AE65380aC2e7366451bF2b", + "proxy": "0x20Fbd46DeEd5EEDEB6e5c87eeB31924e9CA312ad" }, "apTeam": { - "implementation": "0x5C15f56Ee55531f011c6025B205c1750EA469f75", - "proxy": "0xb3e2d928Da7c16d53a8d6DaA14314159fa262754" + "implementation": "0x05Aa229Aec102f78CE0E852A812a388F076Aa555", + "proxy": "0x0b48aF34f4c854F5ae1A3D587da471FeA45bAD52" }, "endowment": { "emitter": { - "implementation": "0x6b07B7A11cF992B436DE5d3bf28F50eBA606649b", - "proxy": "0x05275a4799cd1B07D81319390fC62Bc7BDbDf269" + "implementation": "0x130A46b6E41DB6E1e18fb9c759F223c459190e90", + "proxy": "0x55cb3b67D9E65F0Cf4eABCAC84564a1bE6E3b06A" }, - "factory": "0x086bCD73D03A5e1163A9224Fa09dC5cF70d73094", - "implementation": "0x1F570bf89d86a2C43B9b8d0867267719FC58173D" + "factory": "0xAd5d57aD9bB17d34Debb88566ab2F5dB879Cc46F", + "implementation": "0xE5BD5bDC03371fB239956dbbF40bD185D6c2ea28" } }, "registrar": { - "implementation": "0xADcb9331bfB37dC1b0db12d73c5aFeC3a6c99ce5", - "proxy": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1" + "implementation": "0x0f5D1ef48f12b6f691401bfe88c2037c690a6afe", + "proxy": "0x5FbDB2315678afecb367f032d93F642f64180aa3" }, "router": { - "implementation": "0x6039565f9ff755754E9C52B6DFE4aB7bA6dB2957", - "proxy": "0x8896Dce0E60a706244553ADA1aAc5CDCc40a0428" + "implementation": "0x90118d110B07ABB82Ba8980D1c5cC96EeA810d2C", + "proxy": "0xcA03Dc4665A8C3603cb4Fd5Ce71Af9649dC00d44" }, "subDao": { "emitter": { @@ -296,9 +296,9 @@ "dai": "", "halo": "", "reserveToken": "", - "seedAsset": "0x1C3f3A797B80315faD4DB7D1a58f3AA934118e03", - "usdc": "0xb8348E945900083A270D9244614d09F9c4937d75", - "wmatic": "0x1D1aEE6D5dC35F3c15E2D11083D0e59C026b64c4" + "seedAsset": "0x948B3c65b89DF0B4894ABE91E6D02FE579834F8F", + "usdc": "0xbCF26943C0197d2eE0E5D05c716Be60cc2761508", + "wmatic": "0xC6bA8C3233eCF65B761049ef63466945c362EdD2" }, "uniswap": { "factory": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", diff --git a/contracts/multisigs/CharityApplications.sol b/contracts/multisigs/CharityApplications.sol index 4001bc306..a1f0ad62a 100644 --- a/contracts/multisigs/CharityApplications.sol +++ b/contracts/multisigs/CharityApplications.sol @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; + +import {Validator} from "../core/validator.sol"; import "./CharityApplicationsStorage.sol"; import {ICharityApplications} from "./interfaces/ICharityApplications.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -23,7 +25,7 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp */ modifier proposalExists(uint256 proposalId) { - require(proposals[proposalId].proposer != address(0), "Proposal dne"); + require(Validator.addressChecker(proposals[proposalId].proposer), "Proposal dne"); _; } @@ -88,7 +90,8 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp address _seedAsset, uint256 _seedAmount ) public override initializer { - super.initialize(owners, _approvalsRequired, _requireExecution, _transactionExpiry); + require(Validator.addressChecker(_accountsContract), "Invalid Accounts contract"); + require(Validator.addressChecker(_seedAsset), "Invalid seed asset"); // set Applications Multisig storage items proposalCount = 1; config.accountsContract = _accountsContract; @@ -96,6 +99,7 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp config.gasAmount = _gasAmount; config.seedAsset = _seedAsset; config.seedAmount = _seedAmount; + super.initialize(owners, _approvalsRequired, _requireExecution, _transactionExpiry); } /** @@ -210,7 +214,7 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp if (config.gasAmount > 0) { // get the first member of the new endowment address payable signer = payable(proposals[proposalId].application.members[0]); - require(signer != address(0), "Endowment Member not set"); + require(Validator.addressChecker(signer), "Endowment Member not set"); // check matic balance on this contract if (address(this).balance >= config.gasAmount) { @@ -270,8 +274,8 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp address seedAsset, uint256 seedAmount ) public override ownerExists(msg.sender) { - require(seedAsset != address(0), "Seed Asset is not a valid address"); - require(accountsContract != address(0), "Accounts Contract is not a valid address"); + require(Validator.addressChecker(seedAsset), "Seed Asset is not a valid address"); + require(Validator.addressChecker(accountsContract), "Accounts Contract is not a valid address"); require( seedSplitToLiquid >= 0 && seedSplitToLiquid <= 100, "Seed split to liquid must be between 0 & 100" diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index e375c7a58..49ee15dae 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; +import {Validator} from "../core/validator.sol"; import "./storage.sol"; import {IMultiSigGeneric} from "./interfaces/IMultiSigGeneric.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -34,7 +35,7 @@ contract MultiSigGeneric is } modifier transactionExists(uint256 transactionId) { - require(transactions[transactionId].destination != address(0), "Transaction dne"); + require(Validator.addressChecker(transactions[transactionId].destination), "Transaction dne"); _; } @@ -69,11 +70,6 @@ contract MultiSigGeneric is _; } - modifier notNull(address addr) { - require(addr != address(0), "Address cannot be a zero address"); - _; - } - modifier validApprovalsRequirement(uint256 _ownerCount, uint256 _approvalsRequired) { require(_approvalsRequired <= _ownerCount && _approvalsRequired != 0); _; @@ -101,7 +97,7 @@ contract MultiSigGeneric is ) internal initializer validApprovalsRequirement(owners.length, _approvalsRequired) { require(owners.length > 0, "Must pass at least one owner address"); for (uint256 i = 0; i < owners.length; i++) { - require(!isOwner[owners[i]] && owners[i] != address(0)); + require(!isOwner[owners[i]] && Validator.addressChecker(owners[i])); isOwner[owners[i]] = true; } activeOwnersCount = owners.length; @@ -331,7 +327,8 @@ contract MultiSigGeneric is uint256 value, bytes memory data, bytes memory metadata - ) internal virtual override notNull(destination) returns (uint256 transactionId) { + ) internal virtual override returns (uint256 transactionId) { + require(Validator.addressChecker(destination), "Invalid destination address"); transactionId = transactionCount; transactions[transactionId] = MultiSigStorage.Transaction({ destination: destination, diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol index 37adf26dc..ee410a986 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol @@ -1,9 +1,11 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; + +import {Validator} from "../../core/validator.sol"; +import {Utils} from "../../lib/utils.sol"; import {MultiSigGeneric} from "../../multisigs/MultiSigGeneric.sol"; -import {IEndowmentMultiSigEmitter} from "./interfaces/IEndowmentMultiSigEmitter.sol"; import {MultiSigStorage} from "../../multisigs/storage.sol"; -import {Utils} from "../../lib/utils.sol"; +import {IEndowmentMultiSigEmitter} from "./interfaces/IEndowmentMultiSigEmitter.sol"; /** * @notice the endowment multisig contract @@ -31,7 +33,7 @@ contract EndowmentMultiSig is MultiSigGeneric { bool _requireExecution, uint256 _transactionExpiry ) public initializer { - require(_emitter != address(0), "Invalid Address"); + require(Validator.addressChecker(_emitter), "Invalid Address"); ENDOWMENT_ID = _endowmentId; EMITTER_ADDRESS = _emitter; super.initialize(_owners, _required, _requireExecution, _transactionExpiry); From 7eedfbeca6b8368d0983f473a81004b9f9f7f3ec Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 11:01:24 +0200 Subject: [PATCH 5/9] Make emit funcs internal --- contracts/multisigs/MultiSigGeneric.sol | 22 +++++++++---------- .../endowment-multisig/EndowmentMultiSig.sol | 20 ++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index 49ee15dae..2f6cf0c0f 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -347,7 +347,7 @@ contract MultiSigGeneric is uint256 _approvalsRequired, bool _requireExecution, uint256 _transactionExpiry - ) public virtual { + ) internal virtual { emit InitializedMultiSig( address(this), owners, @@ -357,27 +357,27 @@ contract MultiSigGeneric is ); } - function emitOwnersAdded(address[] memory owners) public virtual { + function emitOwnersAdded(address[] memory owners) internal virtual { emit OwnersAdded(address(this), owners); } - function emitOwnersRemoved(address[] memory owners) public virtual { + function emitOwnersRemoved(address[] memory owners) internal virtual { emit OwnersRemoved(address(this), owners); } - function emitOwnerReplaced(address currOwner, address newOwner) public virtual { + function emitOwnerReplaced(address currOwner, address newOwner) internal virtual { emit OwnerReplaced(address(this), currOwner, newOwner); } - function emitApprovalsRequiredChanged(uint256 _approvalsRequired) public virtual { + function emitApprovalsRequiredChanged(uint256 _approvalsRequired) internal virtual { emit ApprovalsRequiredChanged(address(this), _approvalsRequired); } - function emitRequireExecutionChanged(bool _requireExecution) public virtual { + function emitRequireExecutionChanged(bool _requireExecution) internal virtual { emit RequireExecutionChanged(address(this), _requireExecution); } - function emitExpiryChanged(uint256 _transactionExpiry) public virtual { + function emitExpiryChanged(uint256 _transactionExpiry) internal virtual { emit ExpiryChanged(address(this), _transactionExpiry); } @@ -385,22 +385,22 @@ contract MultiSigGeneric is address sender, uint256 transactionId, bytes memory metadata - ) public virtual { + ) internal virtual { emit TransactionSubmitted(address(this), sender, transactionId, metadata); } - function emitTransactionConfirmed(address sender, uint256 transactionId) public virtual { + function emitTransactionConfirmed(address sender, uint256 transactionId) internal virtual { emit TransactionConfirmed(address(this), sender, transactionId); } function emitTransactionConfirmationRevoked( address sender, uint256 transactionId - ) public virtual { + ) internal virtual { emit TransactionConfirmationRevoked(address(this), sender, transactionId); } - function emitTransactionExecuted(uint256 transactionId) public virtual { + function emitTransactionExecuted(uint256 transactionId) internal virtual { emit TransactionExecuted(address(this), transactionId); } } diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol index ee410a986..ac39b9fbc 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol @@ -41,13 +41,13 @@ contract EndowmentMultiSig is MultiSigGeneric { /// @dev Allows to add new owners. Transaction has to be sent by wallet. /// @param owners Addresses of new owners. - function emitOwnersAdded(address[] memory owners) public override { + function emitOwnersAdded(address[] memory owners) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownersAddedEndowment(ENDOWMENT_ID, owners); } /// @dev Allows to remove owners. Transaction has to be sent by wallet. /// @param owners Addresses of removed owners. - function emitOwnersRemoved(address[] memory owners) public override { + function emitOwnersRemoved(address[] memory owners) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownersRemovedEndowment(ENDOWMENT_ID, owners); } @@ -57,7 +57,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @param currOwner the owner to be replaced * @param newOwner the new owner to add */ - function emitOwnerReplaced(address currOwner, address newOwner) public override { + function emitOwnerReplaced(address currOwner, address newOwner) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownerReplacedEndowment( ENDOWMENT_ID, currOwner, @@ -70,7 +70,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the requirementChangeEndowment event * @param _approvalsRequired the new required number of signatures */ - function emitApprovalsRequiredChanged(uint256 _approvalsRequired) public override { + function emitApprovalsRequiredChanged(uint256 _approvalsRequired) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).approvalsRequirementChangedEndowment( ENDOWMENT_ID, _approvalsRequired @@ -82,7 +82,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the transactionExpiryChangeEndowment event * @param _transactionExpiry the new validity for newly created transactions */ - function emitExpiryChanged(uint256 _transactionExpiry) public override { + function emitExpiryChanged(uint256 _transactionExpiry) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).expiryChangedEndowment( ENDOWMENT_ID, _transactionExpiry @@ -94,7 +94,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the requirementChangeEndowment event * @param _requireExecution Explicit execution step is needed */ - function emitRequireExecutionChanged(bool _requireExecution) public override { + function emitRequireExecutionChanged(bool _requireExecution) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).requireExecutionChangedEndowment( ENDOWMENT_ID, _requireExecution @@ -105,7 +105,7 @@ contract EndowmentMultiSig is MultiSigGeneric { address sender, uint256 transactionId, bytes memory metadata - ) public override { + ) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionSubmittedEndowment( ENDOWMENT_ID, sender, @@ -119,7 +119,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the confirmEndowment event * @param transactionId the transaction id */ - function emitTransactionConfirmed(address sender, uint256 transactionId) public override { + function emitTransactionConfirmed(address sender, uint256 transactionId) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmedEndowment( ENDOWMENT_ID, sender, @@ -135,7 +135,7 @@ contract EndowmentMultiSig is MultiSigGeneric { function emitTransactionConfirmationRevoked( address sender, uint256 transactionId - ) public override { + ) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmationRevokedEndowment( ENDOWMENT_ID, sender, @@ -148,7 +148,7 @@ contract EndowmentMultiSig is MultiSigGeneric { * @dev emits the executeEndowment event, overrides underlying execute function * @param transactionId the transaction id */ - function emitTransactionExecuted(uint256 transactionId) public override { + function emitTransactionExecuted(uint256 transactionId) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionExecutedEndowment( ENDOWMENT_ID, transactionId From 69b819c277f9e5b3f744edc90f5d175d91155010 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 11:02:17 +0200 Subject: [PATCH 6/9] Move MultiSigGeneric down to internal funcs section --- contracts/multisigs/MultiSigGeneric.sol | 49 +++++++++++++------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index 2f6cf0c0f..cb21c377f 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -84,30 +84,6 @@ contract MultiSigGeneric is /* * Public functions */ - /// @dev Contract constructor sets initial owners and required number of confirmations. - /// @param owners List of initial owners. - /// @param _approvalsRequired Number of required confirmations. - /// @param _requireExecution setting for if an explicit execution call is required - /// @param _transactionExpiry Proposal expiry time in seconds - function initialize( - address[] memory owners, - uint256 _approvalsRequired, - bool _requireExecution, - uint256 _transactionExpiry - ) internal initializer validApprovalsRequirement(owners.length, _approvalsRequired) { - require(owners.length > 0, "Must pass at least one owner address"); - for (uint256 i = 0; i < owners.length; i++) { - require(!isOwner[owners[i]] && Validator.addressChecker(owners[i])); - isOwner[owners[i]] = true; - } - activeOwnersCount = owners.length; - - // set storage variables - approvalsRequired = _approvalsRequired; - requireExecution = _requireExecution; - transactionExpiry = _transactionExpiry; - emitInitializedMultiSig(owners, approvalsRequired, requireExecution, transactionExpiry); - } /// @dev Allows to add new owners. Transaction has to be sent by wallet. /// @param owners Addresses of new owners. @@ -316,6 +292,31 @@ contract MultiSigGeneric is /* * Internal functions */ + /// @dev Contract constructor sets initial owners and required number of confirmations. + /// @param owners List of initial owners. + /// @param _approvalsRequired Number of required confirmations. + /// @param _requireExecution setting for if an explicit execution call is required + /// @param _transactionExpiry Proposal expiry time in seconds + function initialize( + address[] memory owners, + uint256 _approvalsRequired, + bool _requireExecution, + uint256 _transactionExpiry + ) internal initializer validApprovalsRequirement(owners.length, _approvalsRequired) { + require(owners.length > 0, "Must pass at least one owner address"); + for (uint256 i = 0; i < owners.length; i++) { + require(!isOwner[owners[i]] && Validator.addressChecker(owners[i])); + isOwner[owners[i]] = true; + } + activeOwnersCount = owners.length; + + // set storage variables + approvalsRequired = _approvalsRequired; + requireExecution = _requireExecution; + transactionExpiry = _transactionExpiry; + emitInitializedMultiSig(owners, approvalsRequired, requireExecution, transactionExpiry); + } + /// @dev Adds a new transaction to the transaction mapping, if transaction does not exist yet. /// @param destination Transaction target address. /// @param value Transaction ether value. From bd7e890655b4d6a52796758a960b49c352554c15 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 11:04:18 +0200 Subject: [PATCH 7/9] Revert contract-address.json --- contract-address.json | 78 +++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/contract-address.json b/contract-address.json index a4189bc76..8c10ad53e 100644 --- a/contract-address.json +++ b/contract-address.json @@ -154,30 +154,30 @@ }, "31337": { "accounts": { - "diamond": "0x73eccD6288e117cAcA738BDAD4FEC51312166C1A", + "diamond": "0x16fb8e3ab0AF1da9c6e6a589DD025E6558F496Bc", "facets": { - "accountsDeployContract": "0xe6b98F104c1BEf218F3893ADab4160Dc73Eb8367", - "accountsDepositWithdrawEndowments": "0x1e2F4432bFeF9E9Ad39DA6d272F4aFf33629c770", - "accountsDonationMatch": "0x5C7c905B505f0Cf40Ab6600d05e677F717916F6B", - "accountsAllowance": "0x446e7636a5Fa9af46c3718719e465B547248bF62", - "accountsCreateEndowment": "0x505d59ffFd312983Cc0eD114d7F117B91520d742", - "accountsDaoEndowments": "0x0D4ff719551E23185Aeb16FFbF2ABEbB90635942", - "accountsQueryEndowments": "0xfbAb4aa40C202E4e80390171E82379824f7372dd", - "accountsStrategy": "0xcEC91d876E8f003110D43381359b1bAd124e7F2b", - "accountsSwapRouter": "0xed17543171C1459714cdC6519b58fFcC29A3C3c9", - "accountsUpdate": "0x85C5Dd61585773423e378146D4bEC6f8D149E248", - "accountsUpdateEndowments": "0x677df0cb865368207999F2862Ece576dC56D8dF6", - "accountsUpdateEndowmentSettingsController": "0x0Cf17D5DcDA9cF25889cEc9ae5610B0FB9725F65", - "accountsUpdateStatusEndowments": "0xAfe1b5bdEbD4ae65AF2024738bf0735fbb65d44b", - "diamondCutFacet": "0x2dE080e97B0caE9825375D31f5D0eD5751fDf16D", - "diamondInitFacet": "0x381445710b5e73d34aF196c53A3D5cDa58EDBf7A", - "diamondLoupeFacet": "0x2fc631e4B3018258759C52AF169200213e84ABab", - "ownershipFacet": "0x63cf2Cd54fE91e3545D1379abf5bfd194545259d" + "accountsDeployContract": "0xC4A743126DCcA4DF85B8f75B6eD113bb69dD65A1", + "accountsDepositWithdrawEndowments": "0xA303374bda3A6Ce7550514E6681228Ca12020BBA", + "accountsDonationMatch": "0xB6B18cae509Fcf3542FF6975C2Da06CAAc9773c5", + "accountsAllowance": "0x7F6D5d1bDFB4b281374285510A845cb140d4367b", + "accountsCreateEndowment": "0x455A2aC2F917956c0f2664992C1DDd9Cd6562976", + "accountsDaoEndowments": "0x4060eF0D5a7F0633c5927F7E05041dd7Fcd95f42", + "accountsQueryEndowments": "0xA9526DFDd289b2C2ADa83E07c6dd293AA2C5fEe9", + "accountsStrategy": "0x32Ed2BD67238Be274E127096F42f0a4061aC0Bff", + "accountsSwapRouter": "0x4dcA4bFA0bAa0C8ce741b92B255D967599d994f0", + "accountsUpdate": "0xD7a385546a6a2355C6a1DfAdf33b55c43e2C19B0", + "accountsUpdateEndowments": "0xfAB9d4FA5c03Aa5EaccE715d02E6db648cEE91a3", + "accountsUpdateEndowmentSettingsController": "0x715214AeEf7D4C78b9c329cc4D7375cC08670843", + "accountsUpdateStatusEndowments": "0x15E1268353F6F19D9de2722bD60eC1081b45D3a6", + "diamondCutFacet": "0x8e1f69CfFd8DaD657bF18B91D75BcD26CD6F43AC", + "diamondInitFacet": "0x904df20E7d5A1D577c3763FC7bF35EFa51Df94da", + "diamondLoupeFacet": "0x9cD5998cd48385cb69AE7AaDdFaC83A5DA185FaA", + "ownershipFacet": "0x43dFD957bB91b568176E976A8d4e8ab4E94aeBfD" } }, "axelar": { - "gasService": "0x8464135c8F25Da09e49BC8782676a84730C318bC", - "gateway": "0x71C95911E9a5D330f4D621842EC243EE1343292e" + "gasService": "0x2Eb2BBAAF8D16E8BA07BD40D141a7E25C6dD9945", + "gateway": "0x4ee108458a4D97dAa2f8eF90A73942AC7B3a9209" }, "donationMatch": { "emitter": "", @@ -192,8 +192,8 @@ "proxy": "" }, "gasFwd": { - "factory": "0xF818A7C2AFC45cF4B9DDC48933C9A1edD624e46f", - "implementation": "0xC76A71C4492c11bbaDC841342C4Cb470b5d12193" + "factory": "0xf342D22125Eddc24c6c3D716E048388D1415C20d", + "implementation": "0x07dEF209701605580893ecd7C3cE2340f5b16875" }, "giftcards": { "implementation": "", @@ -254,34 +254,34 @@ "implementation": "" }, "indexFund": { - "implementation": "0xe0B39353F69b54e945364ffcdDD7901697Ca0166", - "proxy": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0" + "implementation": "0x59c7E6B2c565Ff92B762523BD6B778CE66dC0302", + "proxy": "0x9A676e781A523b5d0C0e43731313A708CB607508" }, "multiSig": { "charityApplications": { - "implementation": "0x8613A4029EaA95dA61AE65380aC2e7366451bF2b", - "proxy": "0x20Fbd46DeEd5EEDEB6e5c87eeB31924e9CA312ad" + "implementation": "0x9687796759CAbecC1674A4Aaf23889fC9EC2FCA2", + "proxy": "0xD63c1597435d2E16d7f216A12A3dA65B3bF12241" }, "apTeam": { - "implementation": "0x05Aa229Aec102f78CE0E852A812a388F076Aa555", - "proxy": "0x0b48aF34f4c854F5ae1A3D587da471FeA45bAD52" + "implementation": "0x5C15f56Ee55531f011c6025B205c1750EA469f75", + "proxy": "0xb3e2d928Da7c16d53a8d6DaA14314159fa262754" }, "endowment": { "emitter": { - "implementation": "0x130A46b6E41DB6E1e18fb9c759F223c459190e90", - "proxy": "0x55cb3b67D9E65F0Cf4eABCAC84564a1bE6E3b06A" + "implementation": "0x6b07B7A11cF992B436DE5d3bf28F50eBA606649b", + "proxy": "0x05275a4799cd1B07D81319390fC62Bc7BDbDf269" }, - "factory": "0xAd5d57aD9bB17d34Debb88566ab2F5dB879Cc46F", - "implementation": "0xE5BD5bDC03371fB239956dbbF40bD185D6c2ea28" + "factory": "0x086bCD73D03A5e1163A9224Fa09dC5cF70d73094", + "implementation": "0x1F570bf89d86a2C43B9b8d0867267719FC58173D" } }, "registrar": { - "implementation": "0x0f5D1ef48f12b6f691401bfe88c2037c690a6afe", - "proxy": "0x5FbDB2315678afecb367f032d93F642f64180aa3" + "implementation": "0xADcb9331bfB37dC1b0db12d73c5aFeC3a6c99ce5", + "proxy": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1" }, "router": { - "implementation": "0x90118d110B07ABB82Ba8980D1c5cC96EeA810d2C", - "proxy": "0xcA03Dc4665A8C3603cb4Fd5Ce71Af9649dC00d44" + "implementation": "0x6039565f9ff755754E9C52B6DFE4aB7bA6dB2957", + "proxy": "0x8896Dce0E60a706244553ADA1aAc5CDCc40a0428" }, "subDao": { "emitter": { @@ -296,9 +296,9 @@ "dai": "", "halo": "", "reserveToken": "", - "seedAsset": "0x948B3c65b89DF0B4894ABE91E6D02FE579834F8F", - "usdc": "0xbCF26943C0197d2eE0E5D05c716Be60cc2761508", - "wmatic": "0xC6bA8C3233eCF65B761049ef63466945c362EdD2" + "seedAsset": "0x1C3f3A797B80315faD4DB7D1a58f3AA934118e03", + "usdc": "0xb8348E945900083A270D9244614d09F9c4937d75", + "wmatic": "0x1D1aEE6D5dC35F3c15E2D11083D0e59C026b64c4" }, "uniswap": { "factory": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8", From 6bbcc6eb70e22d3486a012433bb56d8b456675b1 Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 11:05:33 +0200 Subject: [PATCH 8/9] Revert "Use Validator in MSs" This reverts commit b44a58e068e9125f5e19a2a68e53c12c51e9a867. --- contracts/multisigs/CharityApplications.sol | 14 +++++--------- contracts/multisigs/MultiSigGeneric.sol | 13 ++++++++----- .../endowment-multisig/EndowmentMultiSig.sol | 8 +++----- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/contracts/multisigs/CharityApplications.sol b/contracts/multisigs/CharityApplications.sol index a1f0ad62a..4001bc306 100644 --- a/contracts/multisigs/CharityApplications.sol +++ b/contracts/multisigs/CharityApplications.sol @@ -1,7 +1,5 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; - -import {Validator} from "../core/validator.sol"; import "./CharityApplicationsStorage.sol"; import {ICharityApplications} from "./interfaces/ICharityApplications.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; @@ -25,7 +23,7 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp */ modifier proposalExists(uint256 proposalId) { - require(Validator.addressChecker(proposals[proposalId].proposer), "Proposal dne"); + require(proposals[proposalId].proposer != address(0), "Proposal dne"); _; } @@ -90,8 +88,7 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp address _seedAsset, uint256 _seedAmount ) public override initializer { - require(Validator.addressChecker(_accountsContract), "Invalid Accounts contract"); - require(Validator.addressChecker(_seedAsset), "Invalid seed asset"); + super.initialize(owners, _approvalsRequired, _requireExecution, _transactionExpiry); // set Applications Multisig storage items proposalCount = 1; config.accountsContract = _accountsContract; @@ -99,7 +96,6 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp config.gasAmount = _gasAmount; config.seedAsset = _seedAsset; config.seedAmount = _seedAmount; - super.initialize(owners, _approvalsRequired, _requireExecution, _transactionExpiry); } /** @@ -214,7 +210,7 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp if (config.gasAmount > 0) { // get the first member of the new endowment address payable signer = payable(proposals[proposalId].application.members[0]); - require(Validator.addressChecker(signer), "Endowment Member not set"); + require(signer != address(0), "Endowment Member not set"); // check matic balance on this contract if (address(this).balance >= config.gasAmount) { @@ -274,8 +270,8 @@ contract CharityApplications is MultiSigGeneric, StorageApplications, ICharityAp address seedAsset, uint256 seedAmount ) public override ownerExists(msg.sender) { - require(Validator.addressChecker(seedAsset), "Seed Asset is not a valid address"); - require(Validator.addressChecker(accountsContract), "Accounts Contract is not a valid address"); + require(seedAsset != address(0), "Seed Asset is not a valid address"); + require(accountsContract != address(0), "Accounts Contract is not a valid address"); require( seedSplitToLiquid >= 0 && seedSplitToLiquid <= 100, "Seed split to liquid must be between 0 & 100" diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index cb21c377f..7aef9c6f5 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; -import {Validator} from "../core/validator.sol"; import "./storage.sol"; import {IMultiSigGeneric} from "./interfaces/IMultiSigGeneric.sol"; import "@openzeppelin/contracts/utils/introspection/ERC165.sol"; @@ -35,7 +34,7 @@ contract MultiSigGeneric is } modifier transactionExists(uint256 transactionId) { - require(Validator.addressChecker(transactions[transactionId].destination), "Transaction dne"); + require(transactions[transactionId].destination != address(0), "Transaction dne"); _; } @@ -70,6 +69,11 @@ contract MultiSigGeneric is _; } + modifier notNull(address addr) { + require(addr != address(0), "Address cannot be a zero address"); + _; + } + modifier validApprovalsRequirement(uint256 _ownerCount, uint256 _approvalsRequired) { require(_approvalsRequired <= _ownerCount && _approvalsRequired != 0); _; @@ -305,7 +309,7 @@ contract MultiSigGeneric is ) internal initializer validApprovalsRequirement(owners.length, _approvalsRequired) { require(owners.length > 0, "Must pass at least one owner address"); for (uint256 i = 0; i < owners.length; i++) { - require(!isOwner[owners[i]] && Validator.addressChecker(owners[i])); + require(!isOwner[owners[i]] && owners[i] != address(0)); isOwner[owners[i]] = true; } activeOwnersCount = owners.length; @@ -328,8 +332,7 @@ contract MultiSigGeneric is uint256 value, bytes memory data, bytes memory metadata - ) internal virtual override returns (uint256 transactionId) { - require(Validator.addressChecker(destination), "Invalid destination address"); + ) internal virtual override notNull(destination) returns (uint256 transactionId) { transactionId = transactionCount; transactions[transactionId] = MultiSigStorage.Transaction({ destination: destination, diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol index ac39b9fbc..23e03c246 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol @@ -1,11 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.16; - -import {Validator} from "../../core/validator.sol"; -import {Utils} from "../../lib/utils.sol"; import {MultiSigGeneric} from "../../multisigs/MultiSigGeneric.sol"; -import {MultiSigStorage} from "../../multisigs/storage.sol"; import {IEndowmentMultiSigEmitter} from "./interfaces/IEndowmentMultiSigEmitter.sol"; +import {MultiSigStorage} from "../../multisigs/storage.sol"; +import {Utils} from "../../lib/utils.sol"; /** * @notice the endowment multisig contract @@ -33,7 +31,7 @@ contract EndowmentMultiSig is MultiSigGeneric { bool _requireExecution, uint256 _transactionExpiry ) public initializer { - require(Validator.addressChecker(_emitter), "Invalid Address"); + require(_emitter != address(0), "Invalid Address"); ENDOWMENT_ID = _endowmentId; EMITTER_ADDRESS = _emitter; super.initialize(_owners, _required, _requireExecution, _transactionExpiry); From a0a5dd14ea6f5efa7db60f804409c037eb5d7b8e Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 1 Aug 2023 11:19:40 +0200 Subject: [PATCH 9/9] Add comments --- contracts/multisigs/MultiSigGeneric.sol | 30 ++++++++ .../endowment-multisig/EndowmentMultiSig.sol | 75 ++++++++----------- 2 files changed, 60 insertions(+), 45 deletions(-) diff --git a/contracts/multisigs/MultiSigGeneric.sol b/contracts/multisigs/MultiSigGeneric.sol index 7aef9c6f5..d38c6d019 100644 --- a/contracts/multisigs/MultiSigGeneric.sol +++ b/contracts/multisigs/MultiSigGeneric.sol @@ -346,6 +346,11 @@ contract MultiSigGeneric is emitTransactionSubmitted(msg.sender, transactionId, metadata); } + /// @dev Emits an event post-initialization. + /// @param owners List of initial owners. + /// @param _approvalsRequired Number of required confirmations. + /// @param _requireExecution setting for if an explicit execution call is required. + /// @param _transactionExpiry Proposal expiry time in seconds. function emitInitializedMultiSig( address[] memory owners, uint256 _approvalsRequired, @@ -361,30 +366,47 @@ contract MultiSigGeneric is ); } + /// @dev Emits an event when owners are added. + /// @param owners Addresses of new owners. function emitOwnersAdded(address[] memory owners) internal virtual { emit OwnersAdded(address(this), owners); } + /// @dev Emits an event when owners are removed. + /// @param owners Addresses of new owners. function emitOwnersRemoved(address[] memory owners) internal virtual { emit OwnersRemoved(address(this), owners); } + /// @dev Emits an event when owners are replaced. + /// @param currOwner Address of current owner to be replaced. + /// @param newOwner Address of new owner. function emitOwnerReplaced(address currOwner, address newOwner) internal virtual { emit OwnerReplaced(address(this), currOwner, newOwner); } + /// @dev Emits an event when the number of required confirmations is updated. + /// @param _approvalsRequired Number of required confirmations. function emitApprovalsRequiredChanged(uint256 _approvalsRequired) internal virtual { emit ApprovalsRequiredChanged(address(this), _approvalsRequired); } + /// @dev Emits an event when there's an update to the flag indicating whether explicit execution step is needed. + /// @param _requireExecution Is an explicit execution step is needed. function emitRequireExecutionChanged(bool _requireExecution) internal virtual { emit RequireExecutionChanged(address(this), _requireExecution); } + /// @dev Emits an event when expiry time for transactions is updated. + /// @param _transactionExpiry time that a newly created transaction is valid for. function emitExpiryChanged(uint256 _transactionExpiry) internal virtual { emit ExpiryChanged(address(this), _transactionExpiry); } + /// @dev Emits an event when a transaction is submitted. + /// @param sender Sender of the Transaction. + /// @param transactionId Transaction ID. + /// @param metadata Encoded transaction metadata, can contain dynamic content. function emitTransactionSubmitted( address sender, uint256 transactionId, @@ -393,10 +415,16 @@ contract MultiSigGeneric is emit TransactionSubmitted(address(this), sender, transactionId, metadata); } + /// @dev Emits an event when a transaction is confirmed. + /// @param sender Sender of the Transaction. + /// @param transactionId Transaction ID. function emitTransactionConfirmed(address sender, uint256 transactionId) internal virtual { emit TransactionConfirmed(address(this), sender, transactionId); } + /// @dev Emits an event when a transaction confirmation is revoked. + /// @param sender Sender of the Transaction. + /// @param transactionId Transaction ID. function emitTransactionConfirmationRevoked( address sender, uint256 transactionId @@ -404,6 +432,8 @@ contract MultiSigGeneric is emit TransactionConfirmationRevoked(address(this), sender, transactionId); } + /// @dev Emits an event when a transaction is executed. + /// @param transactionId Transaction ID. function emitTransactionExecuted(uint256 transactionId) internal virtual { emit TransactionExecuted(address(this), transactionId); } diff --git a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol index 23e03c246..a33c3d0b6 100644 --- a/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol +++ b/contracts/normalized_endowment/endowment-multisig/EndowmentMultiSig.sol @@ -37,24 +37,21 @@ contract EndowmentMultiSig is MultiSigGeneric { super.initialize(_owners, _required, _requireExecution, _transactionExpiry); } - /// @dev Allows to add new owners. Transaction has to be sent by wallet. + /// @dev Emits an event when owners are added. /// @param owners Addresses of new owners. function emitOwnersAdded(address[] memory owners) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownersAddedEndowment(ENDOWMENT_ID, owners); } - /// @dev Allows to remove owners. Transaction has to be sent by wallet. - /// @param owners Addresses of removed owners. + /// @dev Emits an event when owners are removed. + /// @param owners Addresses of new owners. function emitOwnersRemoved(address[] memory owners) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownersRemovedEndowment(ENDOWMENT_ID, owners); } - /** - * @notice overrides the generic multisig replaceOwner function - * @dev emits the removeOwnerEndowment and addOwnerEndowment events - * @param currOwner the owner to be replaced - * @param newOwner the new owner to add - */ + /// @dev Emits an event when owners are replaced. + /// @param currOwner Address of current owner to be replaced. + /// @param newOwner Address of new owner. function emitOwnerReplaced(address currOwner, address newOwner) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).ownerReplacedEndowment( ENDOWMENT_ID, @@ -63,11 +60,8 @@ contract EndowmentMultiSig is MultiSigGeneric { ); } - /** - * @notice overrides the generic multisig changeRequirement function - * @dev emits the requirementChangeEndowment event - * @param _approvalsRequired the new required number of signatures - */ + /// @dev Emits an event when the number of required confirmations is updated. + /// @param _approvalsRequired Number of required confirmations. function emitApprovalsRequiredChanged(uint256 _approvalsRequired) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).approvalsRequirementChangedEndowment( ENDOWMENT_ID, @@ -75,30 +69,28 @@ contract EndowmentMultiSig is MultiSigGeneric { ); } - /** - * @notice overrides the generic multisig changeTransactionExpiry function - * @dev emits the transactionExpiryChangeEndowment event - * @param _transactionExpiry the new validity for newly created transactions - */ - function emitExpiryChanged(uint256 _transactionExpiry) internal override { - IEndowmentMultiSigEmitter(EMITTER_ADDRESS).expiryChangedEndowment( + /// @dev Emits an event when there's an update to the flag indicating whether explicit execution step is needed. + /// @param _requireExecution Is an explicit execution step is needed. + function emitRequireExecutionChanged(bool _requireExecution) internal override { + IEndowmentMultiSigEmitter(EMITTER_ADDRESS).requireExecutionChangedEndowment( ENDOWMENT_ID, - _transactionExpiry + _requireExecution ); } - /** - * @notice overrides the generic multisig changeRequireExecution function - * @dev emits the requirementChangeEndowment event - * @param _requireExecution Explicit execution step is needed - */ - function emitRequireExecutionChanged(bool _requireExecution) internal override { - IEndowmentMultiSigEmitter(EMITTER_ADDRESS).requireExecutionChangedEndowment( + /// @dev Emits an event when expiry time for transactions is updated. + /// @param _transactionExpiry time that a newly created transaction is valid for. + function emitExpiryChanged(uint256 _transactionExpiry) internal override { + IEndowmentMultiSigEmitter(EMITTER_ADDRESS).expiryChangedEndowment( ENDOWMENT_ID, - _requireExecution + _transactionExpiry ); } + /// @dev Emits an event when a transaction is submitted. + /// @param sender Sender of the Transaction. + /// @param transactionId Transaction ID. + /// @param metadata Encoded transaction metadata, can contain dynamic content. function emitTransactionSubmitted( address sender, uint256 transactionId, @@ -112,11 +104,9 @@ contract EndowmentMultiSig is MultiSigGeneric { ); } - /** - * @notice overrides the generic multisig confirmTransaction function - * @dev emits the confirmEndowment event - * @param transactionId the transaction id - */ + /// @dev Emits an event when a transaction is confirmed. + /// @param sender Sender of the Transaction. + /// @param transactionId Transaction ID. function emitTransactionConfirmed(address sender, uint256 transactionId) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionConfirmedEndowment( ENDOWMENT_ID, @@ -125,11 +115,9 @@ contract EndowmentMultiSig is MultiSigGeneric { ); } - /** - * @notice overrides the generic multisig revokeConfirmation function - * @dev emits the revokeEndowment event - * @param transactionId the transaction id - */ + /// @dev Emits an event when a transaction confirmation is revoked. + /// @param sender Sender of the Transaction. + /// @param transactionId Transaction ID. function emitTransactionConfirmationRevoked( address sender, uint256 transactionId @@ -141,11 +129,8 @@ contract EndowmentMultiSig is MultiSigGeneric { ); } - /** - * @notice function called when a proposal has to be explicity executed - * @dev emits the executeEndowment event, overrides underlying execute function - * @param transactionId the transaction id - */ + /// @dev Emits an event when a transaction is executed. + /// @param transactionId Transaction ID. function emitTransactionExecuted(uint256 transactionId) internal override { IEndowmentMultiSigEmitter(EMITTER_ADDRESS).transactionExecutedEndowment( ENDOWMENT_ID,