Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fetch Relays from Registry #24

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions contracts/RelaySugar.vy
Original file line number Diff line number Diff line change
Expand Up @@ -47,28 +47,28 @@ interface IVotingEscrow:
def ownerToNFTokenIdList(_account: address, _index: uint256) -> uint256: view
def voted(_venft_id: uint256) -> bool: view

interface IRelayFactory:
def relays() -> DynArray[address, MAX_RELAYS]: view
interface IRelayRegistry:
def getAll() -> DynArray[address, MAX_RELAYS]: view

interface IRelay:
def name() -> String[100]: view
def tokenId() -> uint256: view
def mTokenId() -> uint256: view
def token() -> address: view
# Latest epoch rewards
def amountTokenEarned(_epoch_ts: uint256) -> uint256: view

# Vars
factory: public(IRelayFactory)
registry: public(IRelayRegistry)
voter: public(IVoter)
ve: public(IVotingEscrow)
token: public(address)

@external
def __init__(_factory: address, _voter: address):
def __init__(_registry: address, _voter: address):
"""
@dev Set up our external factory contract
@dev Set up our external registry and voter contracts
"""
self.factory = IRelayFactory(_factory)
self.registry = IRelayRegistry(_registry)
self.voter = IVoter(_voter)
self.ve = IVotingEscrow(self.voter.ve())
self.token = self.ve.token()
Expand All @@ -90,7 +90,7 @@ def _relays(_account: address) -> DynArray[Relay, MAX_RELAYS]:
@return Array of Relay structs
"""
relays: DynArray[Relay, MAX_RELAYS] = empty(DynArray[Relay, MAX_RELAYS])
addresses: DynArray[address, MAX_RELAYS] = self.factory.relays()
addresses: DynArray[address, MAX_RELAYS] = self.registry.getAll()

for index in range(0, MAX_RELAYS):
if index == len(addresses):
Expand All @@ -106,12 +106,13 @@ def _relays(_account: address) -> DynArray[Relay, MAX_RELAYS]:
def _byAddress(_relay: address, _account: address) -> Relay:
"""
@notice Returns Relay data based on address, with optional account arg
@param _id The Relay address to lookup
@param _relay The Relay address to lookup
@param _account The account address to lookup deposits
@return Relay struct
"""

relay: IRelay = IRelay(_relay)
managed_id: uint256 = relay.tokenId()
managed_id: uint256 = relay.mTokenId()

account_venft_ids: DynArray[uint256, MAX_RESULTS] = empty(DynArray[uint256, MAX_RESULTS])

Expand Down
Loading