# Custom structs

If any of your facet methods utilise custom structs either as input or output, then you will need to tell Gemforge how to import these structs in the generated diamond proxy interface code.

For example, if you had the following facet file:

// file: src/MyFacet.sol

struct GameParams {
  uint maxPlayers;
}

contract MyFacet {
  function createGame(GameParams memory params);
}

Then the proxy interface file generated by Gemforge would contain this method signature.

However, the file wouldn't compile since the struct isn't imported by it:

// file: src/generated/IDiamondProxy.sol

interface IDiamondProxy {
  function createGame(GameParams memory params);  // will FAIL to compile!
}

To fix this, we recommend that you define a file containing all of your custom structs - e.g Structs.sol - and then import that into your facet code. For example:

// file: src/Structs.sol
struct GameParams {
  uint maxPlayers;
}

// file: src/MyFacet.sol
import "Structs.sol";

contract MyFacet {
  function createGame(GameParams memory params);
}

Now you would modify the config as follows:

// file: gemforge.config.cjs
module.exports = {
  ...
  generator: {
    // proxy interface options
    proxyInterface: {
      // imports to include in the generated IDiamondProxy interface
      imports: [
        "src/Structs.sol"
      ],
    },
  },
  ...
}

The Structs.sol file would then be imported by the generated proxy interface via the correct relative folder path, and the interface code itself would now compile:

// file: src/generated/IDiamondProxy.sol

import "../Structs.sol";

interface IDiamondProxy {
  function createGame(GameParams memory params); // will successfully compile!
}

For a working example of the above, check out the demo project.