Convert outputs to string in smart_contract_view.ex (#9529)

* Convert integers and bools to string in smart_contract_view.ex

* Changelog

* Fix tests

* Fix test to support new numbers format

---------

Co-authored-by: Fedor Ivanov <ivnfedor@gmail.com>
pull/9588/merge
nikitosing 8 months ago committed by GitHub
parent 0a54cd7b6e
commit 646c8492b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/lib/block_scout_web/views/api/v2/smart_contract_view.ex
  3. 26
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/smart_contract_controller_test.exs

@ -23,6 +23,7 @@
- [#9563](https://github.com/blockscout/blockscout/pull/9563) - Fix timestamp handler for unfinalized zkEVM batches
- [#9560](https://github.com/blockscout/blockscout/pull/9560) - Fix fetch pending transaction for hyperledger besu client
- [#9555](https://github.com/blockscout/blockscout/pull/9555) - Fix EIP-1967 beacon proxy pattern detection
- [#9529](https://github.com/blockscout/blockscout/pull/9529) - Fix `MAX_SAFE_INTEGER` frontend bug
- [#9518](https://github.com/blockscout/blockscout/pull/9518), [#9628](https://github.com/blockscout/blockscout/pull/9628) - Fix MultipleResultsError in `smart_contract_creation_tx_bytecode/1`
- [#9514](https://github.com/blockscout/blockscout/pull/9514) - Fix missing `0x` prefix for `blockNumber`, `logIndex`, `transactionIndex` and remove `transactionLogIndex` in `eth_getLogs` response.
- [#9512](https://github.com/blockscout/blockscout/pull/9512) - Docker-compose 2.24.6 compatibility

@ -355,6 +355,6 @@ defmodule BlockScoutWeb.API.V2.SmartContractView do
end
def render_json(value, _type) do
value
to_string(value)
end
end

@ -1126,13 +1126,13 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"tuple[bytes32,uint256,bytes32,uint256,address,address,uint256,bool,tuple[address,bytes32[],bytes][]]",
"value" => [
"0xfe6a43fa23a0269092cbf97cb908e1d5a49a18fd6942baf2467fb5b221e39ab2",
1000,
"1000",
"0xfe6a43fa23a0269092cbf97cb908e1d5a49a18fd6942baf2467fb5b221e39ab2",
10,
"10",
"0xbb36c792b9b45aaf8b848a1392b0d6559202729e",
"0xbb36c792b9b45aaf8b848a1392b0d6559202729e",
123_123,
true,
"123123",
"true",
[
[
"0xbb36c792b9b45aaf8b848a1392b0d6559202729e",
@ -1220,7 +1220,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"outputs" => [
%{
"type" => "uint256",
"value" => 2_900_102_562_052_921_000_000
"value" => "2900102562052921000000"
}
],
"name" => "test",
@ -1535,7 +1535,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
assert %{
"is_error" => false,
"result" => %{"names" => ["bool"], "output" => [%{"type" => "bool", "value" => true}]}
"result" => %{"names" => ["bool"], "output" => [%{"type" => "bool", "value" => "true"}]}
} == response
end
@ -1636,13 +1636,13 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"tuple[bytes32,uint256,bytes32,uint256,address,address,uint256,bool,tuple[address,bytes32[],bytes][]]",
"value" => [
"0xfe6a43fa23a0269092cbf97cb908e1d5a49a18fd6942baf2467fb5b221e39ab2",
1000,
"1000",
"0xfe6a43fa23a0269092cbf97cb908e1d5a49a18fd6942baf2467fb5b221e39ab2",
10,
"10",
"0xbb36c792b9b45aaf8b848a1392b0d6559202729e",
"0xbb36c792b9b45aaf8b848a1392b0d6559202729e",
123_123,
true,
"123123",
"true",
[
[
"0xbb36c792b9b45aaf8b848a1392b0d6559202729e",
@ -2145,7 +2145,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
assert %{
"is_error" => false,
"result" => %{"names" => ["bool"], "output" => [%{"type" => "bool", "value" => true}]}
"result" => %{"names" => ["bool"], "output" => [%{"type" => "bool", "value" => "true"}]}
} == response
end
@ -2225,7 +2225,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"result" => %{
"names" => ["amounts"],
"output" => [
%{"type" => "uint256[]", "value" => [1_000_000_000_000_000_000_000, 15_520_773_838_563_941]}
%{"type" => "uint256[]", "value" => ["1000000000000000000000", "15520773838563941"]}
]
}
} == response
@ -2423,7 +2423,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
assert %{
"is_error" => false,
"result" => %{"names" => ["bool"], "output" => [%{"type" => "bool", "value" => true}]}
"result" => %{"names" => ["bool"], "output" => [%{"type" => "bool", "value" => "true"}]}
} == response
end

Loading…
Cancel
Save