I have 3 libraries, one exposes struct
and 2 others expose method with same signature/return type (first one provides default method implementation and second - extended and customized one). When trying to compile it I got error TypeError: Member "transfer" not unique after argument-dependent lookup in struct TypesLib.MyToken storage ref
.
Is it possible to override function from one library in another? usings
order change doesn't affects anything in my case.
Here is examples:
TypesLib.sol:
library TypesLib {
struct TokenStorage {
.....
}
}
DefaultLib.sol
import "./TypesLib.sol"
library DefaultLib {
function transfer(TypesLib.TokenStorage storage self, address to, uint256 amount) public returns (bool) {
... default implementation ...
}
}
CustomizedLib.sol
import "./TypesLib.sol"
library CustomLib {
function transfer(TypesLib.TokenStorage storage self, address to, uint256 amount) public returns (bool) {
... custom implementation ...
}
}
Contract.sol
import "./TypesLib.sol"
import "./DefaultLib.sol"
import "./CustomizedLib.sol"
library CustomLib {
using DefaultLib for TypesLib.TokenStorage;
using CustomizedLib for TypesLib.TokenStorage;
TypesLib.TokenStorage token;
function transfer(address to, uint256 amount) public returns (bool success) {
return token.transfer(to, amount)
}