Skip to content

Commit

Permalink
Fix more sentry errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tspenov committed Nov 20, 2024
1 parent cd73792 commit a0f006b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 26 deletions.
19 changes: 15 additions & 4 deletions lib/sanbase/accounts/eth_account.ex
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,27 @@ defmodule Sanbase.Accounts.EthAccount do
# Helpers

defp contract_data_map(contract) do
%{
total_supply: UniswapPair.total_supply(contract),
reserves: UniswapPair.reserves(contract) |> elem(UniswapPair.get_san_position(contract))
}
with total_supply when is_float(total_supply) <- UniswapPair.total_supply(contract),
{reserves, _} when is_float(reserves) <- UniswapPair.reserves(contract) do
%{
total_supply: total_supply,
reserves: reserves |> elem(UniswapPair.get_san_position(contract))
}
else
{:error, _} -> %{total_supply: 0.0, reserves: 0.0}
_ -> %{total_supply: 0.0, reserves: 0.0}
end
end

defp calculate_san_staked(address_staked_tokens, _data_map) when address_staked_tokens == 0.0 do
+0.0
end

defp calculate_san_staked(_address_staked_tokens, %{total_supply: total_supply})
when total_supply == 0.0 do
+0.0
end

defp calculate_san_staked(address_staked_tokens, data_map) do
# Convert the LP tokens to the actual value of SAN tokens
address_share = address_staked_tokens / data_map.total_supply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ defmodule SanbaseWeb.Graphql.Resolvers.ProjectListResolver do
end
end

def all_projects_by_function(_root, _args, _resolution) do
{:error, "Invalid arguments provided to all_projects_by_function"}
end

def all_projects_by_ticker(_root, %{ticker: ticker}, _resolution) do
projects = Project.List.projects_by_ticker(ticker) |> Enum.uniq_by(& &1.id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,23 @@ defmodule SanbaseWeb.SuggestEcosystemLabelsChangeLive do
socket

slug ->
project = Enum.find(socket.assigns.projects, &(&1.slug == slug))
stored_ecosystems = project.ecosystems

socket
|> assign(
selected_project: project,
stored_project_ecosystems: stored_ecosystems,
new_project_ecosystems: [],
removed_project_ecosystems: [],
ecosystems: order_ecosystems(socket.assigns.ecosystems, stored_ecosystems)
)
case Enum.find(socket.assigns.projects, &(&1.slug == slug)) do
nil ->
socket
|> put_flash(:error, "Project not found")

project ->
stored_ecosystems = project.ecosystems

socket
|> assign(
selected_project: project,
stored_project_ecosystems: stored_ecosystems,
new_project_ecosystems: [],
removed_project_ecosystems: [],
ecosystems: order_ecosystems(socket.assigns.ecosystems, stored_ecosystems)
)
end
end

{:noreply, socket}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,23 @@ defmodule SanbaseWeb.SuggestGithubOrganizationsLive do
socket

slug ->
project = Enum.find(socket.assigns.projects, &(&1.slug == slug))
stored_organizations = project.github_organizations |> Enum.map(& &1.organization)

socket
|> assign(
selected_project: project,
stored_organizations: stored_organizations,
seen_organizations: stored_organizations,
new_organizations: [],
removed_organizations: []
)
case Enum.find(socket.assigns.projects, &(&1.slug == slug)) do
nil ->
socket
|> put_flash(:error, "Project not found")

project ->
stored_organizations = project.github_organizations |> Enum.map(& &1.organization)

socket
|> assign(
selected_project: project,
stored_organizations: stored_organizations,
seen_organizations: stored_organizations,
new_organizations: [],
removed_organizations: []
)
end
end

{:noreply, socket}
Expand Down

0 comments on commit a0f006b

Please sign in to comment.