1
//Here I have created one struct with different parameters such as address , uint, bool ,uint 
//and in this array i have pushed some values in submitTransaction function and it is working as expected  
struct Transactions {
    address to;
    uint256 _value;
    // bytes data;
    bool isExecuted;
    uint256 numOfConfirmation;
}

Transactions[] public transactionArr;

function submitTransaction(uint256 _value,address _to) public onlyOwner returns(bool success){

    uint txIndex  = transactionArr.length;

    transactionArr.push(Transactions({
        _value:_value,
        to: _to,
        isExecuted:false,
        numOfConfirmation:0
        }));
    

    emit submitTransactions(_value, txIndex, _to);

    success = true;
    
}

Here is test function of this submitTransaction function where i'm trying to get the value of struct array

function testSubmitTransaction() public {

multiSigWalletObj.submitTransaction(1000,0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC);
    (,uint value,,) = multiSigWalletObj.transactionArr._value;
    assertEq(value, 1000);
    emit log_named_uint("The Value in submit Transaction is: ", value);
}

And getting this error

Compiler run failed
error[9582]: TypeError: Member "_value" not found or not visible after argument-dependent lookup in function (uint256) view external returns (address,uint256,bool,uint256).
  --> test/MultiSigWallet.t.sol:21:27:
   |
21 |         (,uint value,,) = multiSigWalletObj.transactionArr._value;
   |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 Answer 1

0

You are calling multiSigWalletObj.transactionArr as it were a data member, but it is a getter because transactionArr is an array in the contract.

You need to call with the array position multiSigWalletObj.transactionArr(0).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.