A library is deployed separately and a contract is linked to it. All internal
library functions are copied to the contract using it. But what about public
functions?
If the library declares struct Storage
and public functions make changes to the storage, is it safe to assume no third party can call those functions and that they are accessible only for the contract using the library?
library Friends {
struct Storage {
address[] friendsList;
}
function addFriend(
Storage storage self,
address friend
) public { // <- can anyone but MyContract make changes?
self.push(friend);
}
}
contract MyContract {
using Friends for Friends.Storage;
Friends.Storage friendsStorage;
}