hello everyone!!
i was working on this project and I was trying to make an array of type address for approvers inside struct transaction request but i’m unable to push anything in this array .
my code is:-
pragma solidity 0.7.5;
pragma abicoder v2;
contract Wallet{
address[3] private owners;
uint private majority;
uint public balance;
enum Status {Pending,confirmed,Rejected}
//events
event amountDeposited(uint amount,address indexed depositedBy);
constructor(address owner1,address owner2,address owner3,uint limit){
owners[0]=owner1;
owners[1]=owner2;
owners[2]=owner3;
majority=limit;
}
struct Transaction{
uint txnID;
address creator;
address recipient;
uint amount;
address[] approvers;
uint approvals ;
Status status;
}
Transaction[] transactionPool;
mapping(uint=>Transaction) lookUp;
function deposit() public payable {
balance+=msg.value;
emit amountDeposited(msg.value,msg.sender);
}
function transactionRequest(address _recipient,uint _amount) public returns(Transaction memory){
//require onlyOwner
Transaction memory newTransaction;
newTransaction.txnID=transactionPool.length;
newTransaction.creator=msg.sender;
newTransaction.recipient=_recipient;
newTransaction.amount=_amount;
newTransaction.approvals=1;
newTransaction.status=Status.Pending;
newTransaction.approvers.push(msg.sender);
transactionPool.push(newTransaction);
lookUp[transactionPool.length-1]=newTransaction;
return newTransaction;
}
function ConfirmTransaction(uint _txnID) public view {
//require owner
//owner != creator for txnid
Transaction memory txn=lookUp[_txnID];
txn.approvals+=1;
}
}