1

Trying to implement the diamond upgrade following Nick Mudge implementation in aave. Been getting this error (struct member not found or not visible after argument dependent lookup in struct) importing the AppStorage struct. Any idea why?

LibAppStorage.sol

pragma solidity >=0.8.1;

struct AppStorage {
    uint96 applicationCount;
    mapping(uint96 => Application) applications;
    mapping(address => mapping(address => bool)) applicantGrant;
    mapping(uint96 => mapping(uint48 => MilestoneState)) applicationMilestones;
    mapping(uint96 => Workspace) workspaces;
    mapping(uint96 => mapping(address => bytes32)) memberRoles;
    }
library LibAppStorage{
function blabla.....
}

Application.sol

pragma solidity >=0.8.1;

import {AppStorage} from "../libraries/LibAppStorage.sol";

function submitApplication(
        address _grant
    ) external {
        require(!AppStorage.applicantGrant[msg.sender][_grant], "XXX");
......
        }

1 Answer 1

0

Please provide the full snippet code. You should use AppStorage pattern like the following code below:

LibAppStorage.sol

pragma solidity >=0.8.1;

struct AppStorage {
    uint96 applicationCount;
    mapping(uint96 => Application) applications;
    mapping(address => mapping(address => bool)) applicantGrant;
    mapping(uint96 => mapping(uint48 => MilestoneState)) applicationMilestones;
    mapping(uint96 => Workspace) workspaces;
    mapping(uint96 => mapping(address => bytes32)) memberRoles;
    }
library LibAppStorage{
    function appStorage() internal pure returns (AppStorage storage ds) {    
        assembly { ds.slot := 0 }
    }
}

Application.sol

pragma solidity >=0.8.1;

import {AppStorage} from "../libraries/LibAppStorage.sol";

contract Application {
    AppStorage internal s;
    function submitApplication(
            address _grant
        ) external {
            require(!s.applicantGrant[msg.sender][_grant], "XXX");
            ......
    }
}

AppStorage struct is always available at storage slot of 0. if you want to access to it create a new storage variable like this AppStorage internal s; .Or by calling LibAppStorage.appStorage() from LibAppStorage.sol

If it's useful please vote the answer up

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.