0

I made an effort to cut out all the irrelevant parts of the code and get a minimal version still able to reproduce the error, these are the 3 smart contracts involved:

// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import './ClientBase.sol';
import './ClientETH.sol';
import '@openzeppelin/contracts/proxy/Clones.sol';
import '@openzeppelin/contracts/access/Ownable.sol';

contract ClientFactory is Ownable  {
    address immutable public cbImplementation; //ClientBase implementation contract's address
    address immutable public ceImplementation; //ClientETH implementation contract's address    

    constructor(address _cbImplementation, address  _ceImplementation)  {

        cbImplementation = _cbImplementation;
        ceImplementation = _ceImplementation;

    }

 function createClientBase(string[2] calldata uuids, uint[2] calldata target_info, uint[2] calldata vote_costraints,uint [2] calldata evaluation_info)
 external onlyOwner() returns (address) {
        address clone = Clones.clone(cbImplementation);
        address[] memory addresses= new address[](3);
        addresses[0]= msg.sender;
        addresses[1]= msg.sender;
        addresses[2]= msg.sender;
        ClientBase(clone).initialize(addresses, uuids, target_info, vote_costraints, evaluation_info);
        return clone;
    }

        function createClientETH(string[2] calldata uuids, uint[2] calldata target_info, uint[2] calldata vote_costraints,uint [2] calldata evaluation_info ,uint256 _reward,address receiver_addr)
         external onlyOwner() returns (address) {
        address payable clone = payable(Clones.clone(ceImplementation));
        address[] memory addresses= new address[](4);
        addresses[0]= msg.sender;
        addresses[1]= msg.sender;
        addresses[2]= msg.sender;
        addresses[3]= receiver_addr ;
        ClientETH(clone).initialize(addresses, uuids, target_info, vote_costraints, evaluation_info, _reward);
        return clone;
    }
}
pragma solidity >=0.8.0 <0.9.0;

import '@openzeppelin/contracts/proxy/utils/Initializable.sol';

contract ClientBase is Initializable{

    address payable  deployer;
    address public oracle_sc_address;
    address public reputation_SC_address;

    string public uuid_receiver;
    string public uuid_task;

    uint  public target_cat;
    uint  public target_score;
    uint  public max_cat; 
    uint  public max_cat_per_vote;
    uint  public num_experts;
    uint  public max_revisions;

    function initialize (address[] calldata addresses, string[2] calldata uuids, uint[2] calldata target_info, uint[2] calldata vote_costraints,uint [2] calldata evaluation_info)
    public initializer
    {

        max_cat=vote_costraints[0];
        max_cat_per_vote=vote_costraints[1];
        deployer=payable(addresses[0]);
        oracle_sc_address = addresses[1];
        reputation_SC_address=addresses[2]; 

        uuid_receiver=uuids[0];
        uuid_task=uuids[1];

        target_cat=target_info[0];
        target_score=target_info[1];

        num_experts=evaluation_info[0];
        max_revisions=evaluation_info[1];

    }

}
pragma solidity >=0.8.0 <0.9.0;

import './ClientBase.sol';
//SPDX-License-Identifier: UNLICENSED
contract ClientETH is  ClientBase{

    address  payable public receiver_addr;
    uint256  public reward;

    function initialize (address[] calldata addresses, string[2] calldata uuids, uint[2] calldata target_info, uint[2] calldata vote_costraints,uint [2] calldata evaluation_info ,uint256 _reward)
    external
    {
        super.initialize(addresses,uuids,target_info,vote_costraints,evaluation_info);
            receiver_addr=payable(addresses[3]);
            reward=_reward;
    }
}

The method createClientETH works perfectly, but the method createClientBase gives me

decoded input   { "string[2] uuids": [ "14fd1ace-ca15-490e-9a45-8c381a144416", "14fd1ace-ca15-490e-9a45-8c381a144416" ], "uint256[2] target_info": [ "9", "80" ], "uint256[2] vote_costraints": [ "16", "4" ], "uint256[2] evaluation_info": [ "3", "4" ] } 

decoded output  { "error": "Failed to decode output: null: value out of range (argument=\"value\", value=20, code=INVALID_ARGUMENT, version=bytes/5.1.0)" } 

using tenderly I noticed that the array address on the line ClientBase(clone).initialize(addresses, uuids, target_info, vote_costraints, evaluation_info); for some reason arrives empty, I see no difference between the code in createClientBase and createClientToken but only the last one works, could you help me solve this? thank you so much

0

in the end changing the following did the trick: in ClientBase, from

function initialize (address[] calldata addresses, string[2] calldata uuids, uint[2] calldata target_info, uint[2] calldata vote_costraints,uint [2] calldata evaluation_info)
    public initializer
    {

to

function initialize (address[3] memory addresses, string[2] calldata uuids, uint[2] calldata target_info, uint[2] calldata vote_costraints,uint [2] calldata evaluation_info)
    public initializer

and when I call initialize on clientBase I had to change from this

ClientBase(clone).initialize(addresses, uuids, target_info, vote_costraints, evaluation_info);

to this

ClientBase(clone).initialize([msg.sender,msg.sender,msg.sender], uuids, target_info, vote_costraints, evaluation_info);

still not sure why the previous version didn't work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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