From 0bbf4cc526dc501031a75f55de98db92a0a6e033 Mon Sep 17 00:00:00 2001 From: POA <33550681+poa@users.noreply.github.com> Date: Fri, 19 Mar 2021 09:58:12 +0300 Subject: [PATCH] Fix stake_snapshotting.ex --- .dialyzer-ignore | 2 +- .../lib/explorer/staking/stake_snapshotting.ex | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index e9787e235d..0e081fd2f4 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -25,4 +25,4 @@ lib/explorer/exchange_rates/source.ex:113 lib/explorer/smart_contract/verifier.ex:89 lib/block_scout_web/templates/address_contract/index.html.eex:118 lib/explorer/staking/stake_snapshotting.ex:15: Function do_snapshotting/7 has no local return -lib/explorer/staking/stake_snapshotting.ex:214 +lib/explorer/staking/stake_snapshotting.ex:216 diff --git a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex index d4548a0925..e803620e87 100644 --- a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex +++ b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex @@ -46,6 +46,8 @@ defmodule Explorer.Staking.StakeSnapshotting do |> Enum.zip(pool_staking_addresses) |> Map.new() + abi = abi_clarify_signatures(abi, new_signatures) + # get snapshotted amounts and active delegator list for the pool for each # pending validator by their pool id. # use `cached_pool_staking_responses` when possible @@ -229,6 +231,16 @@ defmodule Explorer.Staking.StakeSnapshotting do Publisher.broadcast(:stake_snapshotting_finished) end + defp abi_clarify_signatures(abi, new_signatures) do + if new_signatures do + abi + else + Jason.decode!( + ~s([{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"stakeAmountTotal","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"stakeAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"poolDelegators","outputs":[{"name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"validatorShare","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"name":"delegatorShare","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]) + ) + end + end + defp address_bytes_to_string(hash), do: "0x" <> Base.encode16(hash, case: :lower) defp snapshotted_pool_amounts_requests(pool_id, pool_staking_address, block_number, new_signatures) do