TypeError: Member "equal" not found or not visible after argument-dependent lookup in type(library Strings).
--> project:/contracts/CRUD.sol:35:17:
|
35 | if (Strings.equal(arr[i],searchFor)) {
| ^^^^^^^^^^^^^
sol
pragma solidity 0.8.7;
import "@openzeppelin/contracts/utils/Strings.sol";
contract CRUD {
struct User {
string account;
string password;
uint status;
uint createdAt;
uint updatedAt;
}
mapping (string => User) public users;
string[] public accounts;
function createUser(string memory _account, string memory _password, uint _status) public {
users[_account] = User(_account, _password, _status, block.timestamp, block.timestamp);
accounts.push(_account);
}
function updateUser(string memory _account, string memory _password, uint _status) public {
users[_account].password = _password;
users[_account].status = _status;
users[_account].updatedAt = block.timestamp;
}
function deleteUser(string memory _account) public {
delete users[_account];
delete accounts[indexOf(accounts,_account)];
}
function indexOf(string[] memory arr, string memory searchFor) private returns (uint256) {
for (uint256 i = 0; i < arr.length; i++) {
// if (arr[i] == searchFor) {
if (Strings.equal(arr[i],searchFor)) {
return i;
}
}
return 2^256 -1; // not found
}
}
🔢 Code to reproduce bug
truffle compile
remix compile
在 master 有此方法,但是實際上inport沒有
💻 Environment Truffle remix ide
📝 Details
sol
🔢 Code to reproduce bug truffle compile remix compile