diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f773213b0..9a2ea350be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - [#1724](https://github.com/poanetwork/blockscout/pull/1724) - Remove internal tx and token balance fetching from realtime fetcher - [#1727](https://github.com/poanetwork/blockscout/pull/1727) - add logs pagination in rpc api - [#1740](https://github.com/poanetwork/blockscout/pull/1740) - fix empty block time + - [#1743](https://github.com/poanetwork/blockscout/pull/1743) - sort decompiled smart contracts in lexicographical order ### Chore diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_decompiled_contract/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_decompiled_contract/index.html.eex index 615dc4de69..59c74ed237 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_decompiled_contract/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_decompiled_contract/index.html.eex @@ -6,7 +6,7 @@ <%= render BlockScoutWeb.AddressView, "_tabs.html", assigns %> - <%= for {contract, _i} <- Enum.with_index(@address.decompiled_smart_contracts) do %> + <%= for contract <- sort_contracts_by_version(@address.decompiled_smart_contracts) do %>
#
\n # eveem.org 6 Feb 2019
\n # Decompiled source of 0x00Bd9e214FAb74d6fC21bf1aF34261765f57e875
\n #
\n # Let's make the world open source
\n #
\n #
\n # I failed with these:
\n # - unknowne77c646d(?)
\n # - transferFromWithData(address _from, address _to, uint256 _value, bytes _data)
\n # All the rest is below.
\n #
\n
\n
\n # Storage definitions and getters
\n
\n def storage:
\n allowance is uint256 => uint256 # mask(256, 0) at storage #2
\n stor4 is uint256 => uint8 # mask(8, 0) at storage #4
\n
\n def allowance(address _owner, address _spender) payable:
\n require (calldata.size - 4) >= 64
\n return allowance[sha3(((320 - 1) and (320 - 1) and _owner), 1), ((320 - 1) and _spender and (320 - 1))]
\n
\n
\n #
\n # Regular functions - see Tutorial for understanding quirks of the code
\n #
\n
\n
\n # folder failed in this function - may be terribly long, sorry
\n def unknownc47d033b(?) payable:
\n if (calldata.size - 4) < 32:
\n revert
\n else:
\n if not (320 - 1) or not cd[4]:
\n revert
\n else:
\n mem[0] = (320 - 1) and (320 - 1) and cd[4]
\n mem[32] = 4
\n mem[96] = bool(stor4[((320 - 1) and (320 - 1) and cd[4])])
\n return bool(stor4[((320 - 1) and (320 - 1) and cd[4])])
\n
\n def _fallback() payable: # default function
\n revert
\n
\n"
end
end
+
+ describe "sort_contracts_by_version/1" do
+ test "sorts contracts in lexicographical order" do
+ contract2 = insert(:decompiled_smart_contract, decompiler_version: "v2")
+ contract1 = insert(:decompiled_smart_contract, decompiler_version: "v1")
+ contract3 = insert(:decompiled_smart_contract, decompiler_version: "v3")
+
+ result = AddressDecompiledContractView.sort_contracts_by_version([contract2, contract1, contract3])
+
+ assert result == [contract3, contract2, contract1]
+ end
+ end
end