Skip to content

[Bug] sol macro can't create definitions for files which import types #602

Closed as not planned
@kayabaNerve

Description

@kayabaNerve

Component

sol! macro

What version of Alloy are you on?

0.7.0

Operating System

Linux

Describe the bug

I have the following:

import "./Sandbox.sol";

contract Router {
  // Nonce is incremented for each batch of transactions executed
  uint256 public nonce;

  // The current session
  uint256 public session;
  // Current public key's x-coordinate
  // This key must always have the parity defined within the Schnorr contract
  bytes32 public seraiKey;

  struct OutInstruction {
    address to;
    Call[] calls;

    uint256 value;
  }

  ...
}

where Sandbox.sol contains, at the top level,

struct Call {
  address to;
  uint256 value;
  bytes data;
}

Despite this being compiling Solidity (per solc), the sol macro fails with "unresolved custom type: Call". My invoation is as follows:

sol!("artifacts/Router.sol");

I would call this a feature-request for import resolution, except AFAICT, there's no possibly way to model this behavior through the current sol macro. I'm perfectly fine with needing to do,

sol!("artifacts/Sandbox.sol", "artifacts/Router.sol");

and tried exactly that (which wouldn't require import resolution, which sounds horrific). Because there's no way to model this behavior when using the file API AFAICT, I'd argue sol is incomplete regarding its intended behavior, making this a bug. Apologies if this should be a feature request, and please, feel free to mark it at one.

My workaround for now is using the JSON ABI, yet per the macro's documentation, this is less functional for some cases. It's only because I don't have such cases at this moment, I can personally accept this workaround.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions