Skip to content

Commit

Permalink
feat: Locked tokens accessor
Browse files Browse the repository at this point in the history
Signed-off-by: Anirudh <[email protected]>
  • Loading branch information
anirudh2 committed Mar 13, 2023
1 parent f3841ec commit 1ac5fae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/domain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ stake(::Val{:indexer}, x) = x.stakedTokens |> only
"""
delegation(::Val{:indexer}, x)
The tokens delegated by the indexer in table `x`.
The tokens delegated to the indexer in table `x`.
```julia
julia> using AllocationOpt
Expand All @@ -142,3 +142,21 @@ julia> AllocationOpt.delegation(Val(:indexer), x)
```
"""
delegation(::Val{:indexer}, x) = x.delegatedTokens |> only

"""
locked(::Val{:indexer}, x)
The locked tokens of the indexer in table `x`.
```julia
julia> using AllocationOpt
julia> using TheGraphData
julia> x = flextable([
Dict(
"lockedTokens" => 10,
),
])
julia> AllocationOpt.locked(Val(:indexer), x)
```
"""
locked(::Val{:indexer}, x) = x.lockedTokens |> only
1 change: 1 addition & 0 deletions test/domain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
x = flextable([Dict("stakedTokens" => 10, "delegatedTokens" => 5, "lockedTokens" => 1)])
@test AllocationOpt.stake(Val(:indexer), x) == 10
@test AllocationOpt.delegation(Val(:indexer), x) == 5
@test AllocationOpt.locked(Val(:indexer), x) == 1
end

end
Expand Down

0 comments on commit 1ac5fae

Please sign in to comment.