How to call memory variables in a Proxy?

Hello,

I have a proxy that delegates calls to an implementation contract. The implementation contract contains the following function:

  // Retrieve the array that contains the entire number of Items set for the contract
  function getUpdatedItems()
    public
    returns (uint256[] memory, ItemsLibrary.Item[] memory)
  {
    idCounter.reset();
    for (uint256 i = 0; i < itemsCount; i++) {
      if (idToItem[i].itemState != ItemsLibrary.ItemState.deleted) {
        idCounter.increment();
      }
    }
    uint256 indexesNumber = idCounter.current();
    uint256[] memory _itemsIndexesArray = new uint256[](indexesNumber);
    ItemLibrary.Items[] memory _items = new ItemsLibrary.Item[](
      indexesNumber
    );
    uint8 k;
    for (uint8 j = 0; j < itemCount; j++) {
      if (idToItem[j].itemState != ItemLibrary.ItemState.deleted) {
        _items[k].var1 = idToItem[j].var1;
        _items[k].var2 = idToItem[j].var2;
        _itemIndexesArray[k] = j;
        k++;
      }
    }
    return (_itemIndexesArray, _items);
  }

Im calling the function through the proxy but it returns nothing so my assumption is that the delegatecall is not able to retrieve the memory values as they are wiped off, is that the case?, so how would I retrieved the memory values return by the implementation contract function?

:computer: Environment

Remix

Hello @nicolas.guasca

What proxy are you using?

DelegateCall does return the data (just like all other calls) and the OZ proxies all forward this data, making it transparent.

Can you tell us more about what you are trying to do (details of the call), what you expect, and what you get?

I am using ERC1967 Proxy @Amxx. See here

-The details of my call:

If I deploy an implementation and call the above function within the same implementation contract I get both memory arrays. However, if I deploy the code as a proxy and call the above function the transaction goes through but it doesn't store the memory arrays. The console shows that the input is the same 0x.. on both scenarios.

I notice though that on the first scenario the "decoded input" is "{}" while on the latter is "-" so I don't understand where is the proxy taking the memory variable to, how is it decoding (or not decoding) the input or simply why is it unable to build the function.

-I expect to get the same output I am getting when I deploy the implementation and call the function directly.

-I get a successful transaction on my proxy contract but with an empty value for both uint256[] memory and ItemsLibrary.Item[] memory variables.

What do you think I might be missing? Thanks for the guidance!