I have a struct in a library:
// lib
struct Data {
int256 count;
mapping(address => int256) indices;
mapping(int256 => address) items;
}
// Also append function in lib
function append(Data storage self, address addr)
internal
returns (bool) {
if (addr == ZERO_ADDRESS) {
return false;
}
int256 index = self.indices[addr] - 1;
if (index >= 0 && index < self.count) {
return false;
}
self.count++;
self.indices[addr] = self.count;
self.items[self.count] = addr;
return true;
}
And then another contract that uses this library struct:
// Contract.sol
using LibMap for LibMap.Data;
mapping(address => LibMap.Data) public addresses;
And then in a function I push to it
addresses[msg.sender].append(addr);
From the front end with web3 I can do contract.addresses(msg.sender)
where msg.sender is the address from earlier in the contract that was set and it will return a length/count of how many have been appended. But how would I rather read all the addresses that have been pushed instead of a length/count?
Would I need a function in the contract for this?
addresses[msg.sender].append(addr);
?msg.sender
from the front endappend
function somewhere?items
holds the addresses