I have two libraries: A
and B
as well as contract C
using them.
Library B
, in one of its functions, needs to call a couple of functions defined for A.Storage
.
The code below compiles, tests are passing, but I have no idea how should I interpret storage
modifier when passing library as a parameter: A.Storage storage a
. Is this setup safe? Am I referencing the memory of contract C
and not creating a copy of A.Storage
?
From what I tested, passing A.Storage memory a
does not work, the compiler complains:
TypeError: Member "someFuncDefinedForA" is not available in struct A.Storage memory outside of storage.
library A {
struct Storage { ... }
}
library B {
using A for A.Storage;
struct Storage { ... }
function myFunc(
Storage storage self,
A.Storage storage a // <-- ?
) public {
// (...)
a.someFuncDefinedForA();
}
}
contract C {
using A for A.Storage;
using B for B.Storage;
A.Storage internal a;
B.Storage internal b;
function doIt() public {
b.myFunc(a);
}
}
0.5.17
,A
andB
define different structs;myFunc
is public and surprisingly solc does not complain aboutABIEncoderV2
. Maybe because it's just a library function accessed via DELEGATECALL?