Skip to content

Commit

Permalink
add method for getting directory entries
Browse files Browse the repository at this point in the history
  • Loading branch information
JCSanPedro committed Aug 8, 2024
1 parent fae0dfb commit 7ea2442
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 57 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/build_ganache.yml

This file was deleted.

18 changes: 18 additions & 0 deletions contracts/Directory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,22 @@ contract Directory is IDirectory, Initializable, Ownable2StepUpgradeable, ERC165
function getDirectoryStake(uint256 cycleId, uint256 periodId, address node) external view returns (uint256) {
return directories[cycleId][periodId].stakes[node];
}

function getEntries(uint256 cycleId, uint256 periodId) external view returns (address[] memory, uint256[] memory) {
uint256 entryLength = directories[cycleId][periodId].entries.length;

address[] memory nodes = new address[](entryLength);
uint256[] memory boundaries = new uint256[](entryLength);

DirectoryEntry memory entry;
DirectoryEntry[] memory entries = directories[cycleId][periodId].entries;

for (uint256 i; i < entryLength; ++i) {
entry = entries[i];
nodes[i] = entry.stakee;
boundaries[i] = entry.boundary;
}

return (nodes, boundaries);
}
}
2 changes: 2 additions & 0 deletions contracts/IDirectory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,6 @@ interface IDirectory {
function joinNextDirectory() external;

function getDirectoryStake(uint256 cycleId, uint256 periodId, address node) external view returns (uint256);

function getEntries(uint256 cycleId, uint256 periodId) external view returns (address [] memory, uint256[] memory);
}
28 changes: 14 additions & 14 deletions deployments/localhost_deployment_phase_two.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"deployer": "0x835dF5fE77D479695a616F79A3FC3a25310eb7c6",
"syloToken": "0x078b8556dd887c3D3F2a722c0D8A78438436574d",
"syloStakingManager": "0x1Bc9d124292d4F750bcFa4214FA1164Ff37C5E8A",
"seekerStatsOracle": "0x10e262CB5D9716b3dD4Ff90071196a318f3Dbf84",
"seekerStakingManager": "0xE0664697B4B1FdAC46BcBD93203Bb2E59063113E",
"seekers": "0x3b5bE4ca4659624EE469F8ff030c2A0ac6B1AFc3",
"stakingOrchestrator": "0x1528F2314C7fd2A3040CEAb64290beA48Ad1Eaa7",
"protocolTimeManager": "0x4d95Fa05bef673a001C1Cb0F274292d40ea462c0",
"registries": "0xBF6a0cA6B2C08f0C2e1E7F24878FAA57Bb12770B",
"authorizedAccounts": "0xBe68cCb878731C6B1F47201bD640A029969397f2",
"ticketing": "0x18aA5Fc2E8f8DB4299239D2FCDd8527bbc0b0c28",
"deposits": "0x6a96C7Dc983358BD7CAcF2d62EA873B58F8622Bd",
"rewardsManager": "0x19519f099F07593a268b5296d9DFdAAb40CAa4F9",
"directory": "0x7070f1e0f7c04b8f979eB98B38Ff3Ee66AcA9d6a",
"futurepassRegistrar": "0xC66445AaC140A740c377E2ca23A9344a92e9e97f"
"syloToken": "0xc4db8fD3209c98290AB32693F5155c596B97Eabe",
"syloStakingManager": "0x075EEeD1215982b78A2e05cD2213b5f53A718a9A",
"seekerStatsOracle": "0xFB87c433852Bb2917B37b0471DFA5B369e75083A",
"seekerStakingManager": "0x65A9be6e97eD2F417250A819e93BCb359b1140d0",
"seekers": "0x49C537a88016186Ef41713239799Fc975F9e9aFA",
"stakingOrchestrator": "0x7bFCE7796fdE3Ba0F2052959d506bdA480518edA",
"protocolTimeManager": "0xa4dE4FEA5e961e5C130013CfE207f7C08148A73C",
"registries": "0x4aa109E0DB0223ed2d9085679F450EfDf188CFf6",
"authorizedAccounts": "0x943E7031A7Ed0FC236173f05a3084104b81Aa480",
"ticketing": "0xBfF3a098eA52630351F8eE4C8DdfeA485869d543",
"deposits": "0x07602c326dbD7Cd2E9124d0714e95bA1839446b1",
"rewardsManager": "0xca7efb9aA54e70F7a8e7efb878A48BaefA34F4AC",
"directory": "0x7E7C762176eaa1662d372399265760d4600CCf28",
"futurepassRegistrar": "0x7DBf77bb534997892e5Bcfbdc79Dd82E71C35245"
}
2 changes: 1 addition & 1 deletion docker/localhost-with-protocol/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ COPY docker/localhost-with-protocol/deploy_contracts.sh .
RUN chmod +x deploy_contracts.sh
RUN bash deploy_contracts.sh

ENTRYPOINT ["anvil", "--state", "state.json"]
ENTRYPOINT ["anvil", "--host", "0.0.0.0", "--state", "state.json"]
2 changes: 1 addition & 1 deletion docker/localhost-with-protocol/deploy_contracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ echo "starting local node"
anvil \
--state state.json \
--mnemonic "enroll regret dial tray life phrase saddle term friend figure meat add puppy explain soup" \
--block-time 1 \
--block-time 4 \
&>/dev/null &

anvil_pid=`echo $!`
Expand Down
2 changes: 0 additions & 2 deletions scripts/init_local_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export async function main() {

const contracts = Contracts.connectContracts(contractAddresses, provider);

console.log('deposits address', await contracts.deposits.getAddress());

const deployer = new ethers.Wallet(nodesConfig.deployerPK, provider);

const latestBlock = await provider.getBlock('latest');
Expand Down
23 changes: 23 additions & 0 deletions test/Directory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,29 @@ describe('Directory', () => {
);
});

it('can get directory entries', async () => {
await timeManagerUtil.startProtocol();

for (let i = 0; i < 5; i++) {
await stakingOrchestator.syloStakeAdded(
await accounts[i].getAddress(),
ethers.ZeroAddress,
100,
);

await directory.connect(accounts[i]).joinNextDirectory();
}

const entries = await directory.getEntries(1, 1);

for (let i = 0; i < 5; i++) {
expect(entries[0][i]).to.equal(await accounts[i].getAddress());
expect(entries[1][i]).to.equal(100 + 100 * i);
}

console.log(entries);
});

it('directory supports correct interfaces', async () => {
const abi = [
'function scan(uint128 point) external returns (address)',
Expand Down

0 comments on commit 7ea2442

Please sign in to comment.