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] ToSol prints constructor for interfaces (invalid) #555

Closed
fubhy opened this issue Mar 7, 2024 · 4 comments · Fixed by foundry-rs/foundry#7341 or #558
Closed

[Bug] ToSol prints constructor for interfaces (invalid) #555

fubhy opened this issue Mar 7, 2024 · 4 comments · Fixed by foundry-rs/foundry#7341 or #558
Labels
bug Something isn't working

Comments

@fubhy
Copy link

fubhy commented Mar 7, 2024

Component

json-abi

What version of Alloy are you on?

No response

Operating System

macOS (Apple Silicon)

Describe the bug

Currently, when running cast interface, the output includes the constructor signature of the source contract.

@fubhy fubhy added the bug Something isn't working label Mar 7, 2024
@mattsse
Copy link
Member

mattsse commented Mar 7, 2024

could you please provide an example

@fubhy
Copy link
Author

fubhy commented Mar 7, 2024

could you please provide an example

Sure (btw., not sure if this would've better been filed in the foundry repo). Anyways, for instance running cast interface with the following abi:

[
  {
    "type": "constructor",
    "inputs": [
      {
        "name": "_integrationManager",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "_addressListRegistry",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "_aTokenListId",
        "type": "uint256",
        "internalType": "uint256"
      },
      {
        "name": "_pool",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "_referralCode",
        "type": "uint16",
        "internalType": "uint16"
      }
    ],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "getIntegrationManager",
    "inputs": [],
    "outputs": [
      {
        "name": "integrationManager_",
        "type": "address",
        "internalType": "address"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "lend",
    "inputs": [
      {
        "name": "_vaultProxy",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "",
        "type": "bytes",
        "internalType": "bytes"
      },
      {
        "name": "_assetData",
        "type": "bytes",
        "internalType": "bytes"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  },
  {
    "type": "function",
    "name": "parseAssetsForAction",
    "inputs": [
      {
        "name": "",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "_selector",
        "type": "bytes4",
        "internalType": "bytes4"
      },
      {
        "name": "_actionData",
        "type": "bytes",
        "internalType": "bytes"
      }
    ],
    "outputs": [
      {
        "name": "spendAssetsHandleType_",
        "type": "uint8",
        "internalType": "enum IIntegrationManager.SpendAssetsHandleType"
      },
      {
        "name": "spendAssets_",
        "type": "address[]",
        "internalType": "address[]"
      },
      {
        "name": "spendAssetAmounts_",
        "type": "uint256[]",
        "internalType": "uint256[]"
      },
      {
        "name": "incomingAssets_",
        "type": "address[]",
        "internalType": "address[]"
      },
      {
        "name": "minIncomingAssetAmounts_",
        "type": "uint256[]",
        "internalType": "uint256[]"
      }
    ],
    "stateMutability": "view"
  },
  {
    "type": "function",
    "name": "redeem",
    "inputs": [
      {
        "name": "_vaultProxy",
        "type": "address",
        "internalType": "address"
      },
      {
        "name": "",
        "type": "bytes",
        "internalType": "bytes"
      },
      {
        "name": "_assetData",
        "type": "bytes",
        "internalType": "bytes"
      }
    ],
    "outputs": [],
    "stateMutability": "nonpayable"
  }
]

... will produce this output:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.4;

interface Interface {
    event BorrowedAssetAdded(address indexed asset);
    event BorrowedAssetRemoved(address indexed asset);
    event CollateralAssetAdded(address indexed asset);
    event CollateralAssetRemoved(address indexed asset);

    constructor(address _aaveDataProvider, address _aaveLendingPoolAddressProvider, address _aaveIncentivesController);

    function assetIsBorrowed(address _asset) external view returns (bool isBorrowed_);
    function assetIsCollateral(address _asset) external view returns (bool isCollateral_);
    function getDebtAssets() external returns (address[] memory assets_, uint256[] memory amounts_);
    function getDebtTokenForBorrowedAsset(address _borrowedAsset) external view returns (address debtToken_);
    function getManagedAssets() external returns (address[] memory assets_, uint256[] memory amounts_);
    function init(bytes memory) external;
    function receiveCallFromVault(bytes memory _actionData) external;
}

The constructor should not be generated for the interface output.

@DaniPopes
Copy link
Member

DaniPopes commented Mar 7, 2024

This is intended, we use it to pass it onto sol! internally. This should be documented in to_sol, maybe we should also provide a way to disable it when not desired, e.g. cast when you always want valid solidity

@fubhy
Copy link
Author

fubhy commented Mar 7, 2024

This is intended, we use it to pass it onto sol! internally. This should be documented in to_sol, maybe we should also provide a way to disable it when not desired, e.g. cast when you always want valid solidity

Yeah, I wasn't sure if it's better to filter it out in cast interface or add an option for that here. But I see you guys did both now :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants