return array with all pool ids that controller owns

pull/37/head
Tim Pechersky 2022-02-10 05:07:07 +00:00
rodzic ec0ce83c24
commit b1bf65fb2a
1 zmienionych plików z 12 dodań i 5 usunięć

Wyświetl plik

@ -265,16 +265,23 @@ contract TerminusFacet is ERC1155WithTerminusStorage {
{
LibTerminus.TerminusStorage storage ts = LibTerminus.terminusStorage();
for (uint256 i = 0; i < ts.currentPoolID; i++) {
uint256 index = 0;
uint256[] memory poolIDs = new uint256[](ts.currentPoolID);
uint256 numControlledPools = 0;
for (uint256 i = 0; i < ts.currentPoolID; i++) {
address poolController = ts.poolController[i];
if (poolController == controler) {
poolIDs[index] = i;
numControlledPools++;
}
}
uint256[] memory controlledPools = new uint256[](numControlledPools);
for (uint256 i = 0; i < ts.currentPoolID; i++) {
address poolController = ts.poolController[i];
if (poolController == controler) {
controlledPools[index] = i;
index++;
}
index++;
return poolIDs[:index];
}
}
return controlledPools;
}
}