Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Interface in Struct in Library has wrong ABI Type #15470

Closed
adraffy opened this issue Oct 1, 2024 · 2 comments
Closed

bug: Interface in Struct in Library has wrong ABI Type #15470

adraffy opened this issue Oct 1, 2024 · 2 comments
Labels

Comments

@adraffy
Copy link

adraffy commented Oct 1, 2024

Description

Interfaces in structs in libraries compile to the wrong type. The scope of the issue may be larger than illustrated but the following is a simple example.

Environment

  • Compiler version: 0.8.23+

Steps to Reproduce

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
interface I {
  function f() external pure returns (uint256);
}
struct S {
  I i;
}
library L {
  function g(S memory s) external pure returns (uint256) {
    return s.i.f();
  }
}
contract C {
  function h() external pure returns (uint256) {
    S memory s;
    return L.g(s);
  }
}

ABI of L

{
  "inputs": [
    {
      "components": [
        {
          "internalType": "contract I",
          "name": "i",
          "type": "I" // <-- should be "address"
        }
      ],
      "internalType": "struct S",
      "name": "s",
      "type": "tuple"
    }
  ],
  "name": "g",
  "outputs": [
    {
      "internalType": "uint256",
      "name": "",
      "type": "uint256"
    }
  ],
  "stateMutability": "pure",
  "type": "function"
}
@ekpyron
Copy link
Member

ekpyron commented Oct 1, 2024

This is the correct type in the library ABI. Libraries (unfortunately) don't use the same ABI as contracts - primarily since they support more types not expressible in the ABI like passing storage pointers to recursive structs. See https://docs.soliditylang.org/en/latest/contracts.html#library-selectors

@adraffy
Copy link
Author

adraffy commented Oct 1, 2024

interesting, thanks!

@adraffy adraffy closed this as completed Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants