Code2pdf 670f24f96b78f
Code2pdf 670f24f96b78f
1
pragma solidity ^0.8.9;
contract MultiSigWallet {
address[] public signers; // Array of signers
mapping(address => bool) public isSigner; // Mapping to check if an address is a signer
uint256 public requiredApprovals; // Required approvals to execute a transaction
address public donationContract; // Address of the Donation contract
struct Transaction {
address to; // Address to send funds
uint256 amount; // Amount to send
bool executed; // Status of execution
uint256 approvalCount; // Number of approvals received
mapping(address => bool) approved; // Mapping of approvals
uint256 signerIndex; // Index of the signer who created the transaction
}
modifier onlySigner() {
require(isSigner[msg.sender], "Not a signer");
_;
}
modifier onlyDonationContract() {
require(
msg.sender == donationContract,
"Only Donations contract can call this function."
);
_;
}
constructor(
address[] memory _signers,
uint256 _requiredApprovals,
address _donationContract
) {
require(_signers.length > 0, "At least one signer required");
require(
_requiredApprovals > 0 && _requiredApprovals <= _signers.length,
"Invalid number of approvals"
);
// Transfer the funds from the donations account to the specified address
(bool success, ) = payable(transaction.to).call{ value: transaction.amount }(""); // Transfer the funds
require(success, "Transfer failed"); // Ensure the transfer was successful
}
to = new address[](transactionCount);
amounts = new uint256[](transactionCount);
executed = new bool[](transactionCount);
approvalCounts = new uint256[](transactionCount);
to = new address[](unexecutedCount);
amounts = new uint256[](unexecutedCount);
approvalCounts = new uint256[](unexecutedCount);
uint256 index = 0;
for (uint256 i = 0; i < transactions.length; i++) {
if (!transactions[i].executed) {
Transaction storage txn = transactions[i];
to[index] = txn.to;
amounts[index] = txn.amount;
approvalCounts[index] = txn.approvalCount;
index++;
}
}
}