I have a struct defined in a library (to call it from different contracts):
library DataTypes { struct Test{ uint256 a; uint256 b; } when i want to initialize it or update in my contract :
import {DataTypes} from "./libraries/DataTypes.sol"; Contract A { mapping(uint => DataTypes.Test) public tests; function init(){ DataTypes.Test storage test = DataTypes.Test(1, 2); } } i get this error :
Type struct DataTypes.Test memory is not implicitly convertible to expected type struct DataTypes.Test storage pointer.
but when i define the struct in my Contract it works without any error .
Contract A { struct Test{ uint256 a; uint256 b; } mapping(uint => DataTypes.Test) public tests; function init(){ DataTypes.Test storage test = DataTypes.Test(1, 2); } } My question is : why am i getting this error ? and how can i solve this while keeping the struct in the library ?
anyone could help please ? PS: im using 0.8.12 compiler version .