4

I am trying to import interface in it's contract and overriding function. But 1 mapping is giving error.

Error:

Overriding public state variable return types differ.

Interface:

interface IPassCurrencies {
    function currencyMapping(uint128 currencyIndex)
        external
        view
        returns (PLibrary.CurrencyInfo memory);

}

Contract:

contract Currencies is Ownable, ReentrancyGuard, IPassCurrencies {
    mapping(uint128 => PLibrary.CurrencyInfo)
        public
        override currencyMapping; // Error Here
        ....
}

Any idea where I am wrong?

0

1 Answer 1

3

You need to decouple your struct, try something like this:

function currencyMapping(uint128 currencyIndex)
        external
        view
        returns (address addr, uint8 decimals);

Assuming you struct is as follow:

struct CurrencyInfo {
  address addr,
  uint8 decimals
}
2
  • But won't that affect the point of returning a struct, because now I will be getting multiple values in return rather than the struct object I am expecting? Oct 19, 2022 at 5:42
  • I agree, i've no idea why solidity currently throw on the syntax you provided :目 It seems more like a bug. But at least for now that is what you need to make the compiler silent. Oct 23, 2022 at 5:24

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