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

FFI not handling overloaded methods #1306

Open
joshtharakan opened this issue May 17, 2023 · 1 comment
Open

FFI not handling overloaded methods #1306

joshtharakan opened this issue May 17, 2023 · 1 comment

Comments

@joshtharakan
Copy link

EVM based blockchain has the capability to overload methods with different signatures. While converting the ABI of those methods into FFI, I have found that overloaded methods are not properly converted and only the first reference is converted into FFI representation.

Steps to reproduce
Call the POST /contracts/interfaces/generate endpoint with the following payload:

{
  "description": "greeter contract",
  "input": {
      "abi": [
    {
      "inputs": [
        {
          "internalType": "contract IERC20",
          "name": "_token",
          "type": "address"
        }
      ],
      "name": "sendGreeting",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "string",
          "name": "_a",
          "type": "string"
        }
      ],
      "name": "sendGreeting",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    },
    {
      "inputs": [
        {
          "internalType": "contract IERC20",
          "name": "_token",
          "type": "address"
        },
        {
          "internalType": "uint256",
          "name": "_amount",
          "type": "uint256"
        }
      ],
      "name": "sendGreeting",
      "outputs": [],
      "stateMutability": "nonpayable",
      "type": "function"
    }
  ]
  },
  "name": "greeting-test",
  "namespace": "default",
  "version": "1.0.0"
}

Actual outcome

{
    "namespace": "default",
    "name": "greeting-test",
    "description": "greeter contract",
    "version": "1.0.0",
    "methods": [
        {
            "name": "sendGreeting",
            "pathname": "",
            "description": "",
            "params": [
                {
                    "name": "_token",
                    "schema": {
                        "type": "string",
                        "details": {
                            "type": "address",
                            "internalType": "contract IERC20"
                        },
                        "description": "A hex encoded set of bytes, with an optional '0x' prefix"
                    }
                },
                {
                    "name": "_amount",
                    "schema": {
                        "oneOf": [
                            {
                                "type": "string"
                            },
                            {
                                "type": "integer"
                            }
                        ],
                        "details": {
                            "type": "uint256",
                            "internalType": "uint256"
                        },
                        "description": "An integer. You are recommended to use a JSON string. A JSON number can be used for values up to the safe maximum."
                    }
                }
            ],
            "returns": [],
            "details": {
                "stateMutability": "nonpayable"
            }
        }
    ]
}

Here the two other signatures for the method sendGreeting is ignored.

@nguyer
Copy link
Contributor

nguyer commented May 17, 2023

Thanks for reporting this. I will look into it when I get some cycles. It should generate a unique pathname for each overload to give you a distinct endpoint for each one. Clearly the converter is not doing this as expected though, so thanks for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants