Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New RPC API endpoints #9068

Merged
merged 8 commits into from Jan 19, 2024
Merged

New RPC API endpoints #9068

merged 8 commits into from Jan 19, 2024

Conversation

nikitosing
Copy link
Member

@nikitosing nikitosing commented Dec 27, 2023

#8847
Closes #8868
Closes #7137

Changelog

  • Account > ERC721 - Token Transfer Events
  • Contract > Creator and creation tx hash
  • Contract > Verify Source Code
  • Contract > Verify Proxy Contract
  • Do not return twin contracts in getsourcecode RPC API endpoint

blockscout/docs#220

Checklist for your Pull Request (PR)

@nikitosing nikitosing force-pushed the np-api-parity branch 2 times, most recently from 7fd6f97 to 42fa997 Compare December 28, 2023 10:00
@nikitosing nikitosing changed the title Np api parity New RPC API endpoints Dec 28, 2023
@nikitosing nikitosing requested review from Qwerty5Uiop, sl1depengwyn, varasev and vbaranov and removed request for Qwerty5Uiop December 28, 2023 10:00
CHANGELOG.md Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/etherscan.ex Show resolved Hide resolved
apps/explorer/lib/explorer/etherscan.ex Show resolved Hide resolved
apps/explorer/lib/explorer/chain.ex Outdated Show resolved Hide resolved
apps/explorer/lib/explorer/chain.ex Outdated Show resolved Hide resolved
Copy link
Member

@vbaranov vbaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's handle the case when required parameters were not passed like here when calling /api?module=contract&action=verifysourcecode:

2024-01-10T12:51:22.949 application=api request_id=F6jzlaFuqpFiSm0AAAZC [error] Error while calling RPC action"** (Phoenix.ActionClauseError) no function clause matching in BlockScoutWeb.API.RPC.ContractController.verifysourcecode/2\n\nThe following arguments were given to BlockScoutWeb.API.RPC.ContractController.verifysourcecode/2:\n\n    # 1\n    %Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}, body_params: %{}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: \"localhost\", method: \"POST\", owner: #PID<0.1798.0>, params: %{\"action\" => \"verifysourcecode\", \"module\" => \"contract\"}, path_info: [], path_params: %{}, port: 4000, private: %{BlockScoutWeb.ApiRouter => {[\"api\"], %{Absinthe.Plug => [\"graphql\"], BlockScoutWeb.API.RPC.RPCTranslator => [], BlockScoutWeb.APIKeyV2Router => [\"v2\", \"key\"], BlockScoutWeb.SmartContractsApiV2Router => [\"v2\", \"smart-contracts\"], RPCTranslatorForwarder => []}}, BlockScoutWeb.Router => {[], %{Absinthe.Plug.GraphiQL => [\"graphiql\"], BlockScoutWeb.ApiRouter => [\"api\"], BlockScoutWeb.WebRouter => []}}, :before_send => [#Function<0.117693457/1 in BlockScoutWeb.Plug.Logger.call/2>, #Function<1.71982575/1 in Phoenix.LiveReloader.before_send_inject_reloader/3>, #Function<2.86362936/1 in BlockScoutWeb.Endpoint.call/2>], :phoenix_action => :verifysourcecode, :phoenix_controller => BlockScoutWeb.API.RPC.ContractController, :phoenix_endpoint => BlockScoutWeb.Endpoint, :phoenix_format => \"json\", :phoenix_layout => {BlockScoutWeb.LayoutView, :app}, :phoenix_router => BlockScoutWeb.ApiRouter, :phoenix_view => BlockScoutWeb.API.RPC.ContractView, :plug_session_fetch => #Function<1.84243074/1 in Plug.Session.fetch_session/1>}, query_params: %{\"action\" => \"verifysourcecode\", \"module\" => \"contract\"}, query_string: \"module=contract&action=verifysourcecode\", remote_ip: {127, 0, 0, 1}, req_cookies: %Plug.Conn.Unfetched{aspect: :cookies}, req_headers: [{\"accept\", \"*/*\"}, {\"accept-encoding\", \"gzip, deflate, br\"}, {\"cache-control\", \"no-cache\"}, {\"connection\", \"keep-alive\"}, {\"content-length\", \"0\"}, {\"host\", \"localhost:4000\"}, {\"postman-token\", \"7e6c1b7f-f860-4f14-82b6-b49bdaf7e880\"}, {\"user-agent\", \"PostmanRuntime/7.36.0\"}], request_path: \"/api\", resp_body: nil, resp_cookies: %{}, resp_headers: [{\"cache-control\", \"max-age=0, private, must-revalidate\"}, {\"x-request-id\", \"F6jzlaFuqpFiSm0AAAZC\"}, {\"access-control-allow-credentials\", \"true\"}, {\"access-control-allow-origin\", \"*\"}, {\"access-control-expose-headers\", \"\"}], scheme: :http, script_name: [\"api\"], secret_key_base: :..., state: :unset, status: nil}\n\n    # 2\n    %{\"action\" => \"verifysourcecode\", \"module\" => \"contract\"}\n\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/contract_controller.ex:146: BlockScoutWeb.API.RPC.ContractController.verifysourcecode(%Plug.Conn{adapter: {Plug.Cowboy.Conn, :...}, assigns: %{}, body_params: %{}, cookies: %Plug.Conn.Unfetched{aspect: :cookies}, halted: false, host: \"localhost\", method: \"POST\", owner: #PID<0.1798.0>, params: %{\"action\" => \"verifysourcecode\", \"module\" => \"contract\"}, path_info: [], path_params: %{}, port: 4000, private: %{BlockScoutWeb.ApiRouter => {[\"api\"], %{Absinthe.Plug => [\"graphql\"], BlockScoutWeb.API.RPC.RPCTranslator => [], BlockScoutWeb.APIKeyV2Router => [\"v2\", \"key\"], BlockScoutWeb.SmartContractsApiV2Router => [\"v2\", \"smart-contracts\"], RPCTranslatorForwarder => []}}, BlockScoutWeb.Router => {[], %{Absinthe.Plug.GraphiQL => [\"graphiql\"], BlockScoutWeb.ApiRouter => [\"api\"], BlockScoutWeb.WebRouter => []}}, :before_send => [#Function<0.117693457/1 in BlockScoutWeb.Plug.Logger.call/2>, #Function<1.71982575/1 in Phoenix.LiveReloader.before_send_inject_reloader/3>, #Function<2.86362936/1 in BlockScoutWeb.Endpoint.call/2>], :phoenix_action => :verifysourcecode, :phoenix_controller => BlockScoutWeb.API.RPC.ContractController, :phoenix_endpoint => BlockScoutWeb.Endpoint, :phoenix_format => \"json\", :phoenix_layout => {BlockScoutWeb.LayoutView, :app}, :phoenix_router => BlockScoutWeb.ApiRouter, :phoenix_view => BlockScoutWeb.API.RPC.ContractView, :plug_session_fetch => #Function<1.84243074/1 in Plug.Session.fetch_session/1>}, query_params: %{\"action\" => \"verifysourcecode\", \"module\" => \"contract\"}, query_string: \"module=contract&action=verifysourcecode\", remote_ip: {127, 0, 0, 1}, req_cookies: %Plug.Conn.Unfetched{aspect: :cookies}, req_headers: [{\"accept\", \"*/*\"}, {\"accept-encoding\", \"gzip, deflate, br\"}, {\"cache-control\", \"no-cache\"}, {\"connection\", \"keep-alive\"}, {\"content-length\", \"0\"}, {\"host\", \"localhost:4000\"}, {\"postman-token\", \"7e6c1b7f-f860-4f14-82b6-b49bdaf7e880\"}, {\"user-agent\", \"PostmanRuntime/7.36.0\"}], request_path: \"/api\", resp_body: nil, resp_cookies: %{}, resp_headers: [{\"cache-control\", \"max-age=0, private, must-revalidate\"}, {\"x-request-id\", \"F6jzlaFuqpFiSm0AAAZC\"}, {\"access-control-allow-credentials\", \"true\"}, {\"access-control-allow-origin\", \"*\"}, {\"access-control-expose-headers\", \"\"}], scheme: :http, script_name: [\"api\"], secret_key_base: :..., state: :unset, status: nil}, %{\"action\" => \"verifysourcecode\", \"module\" => \"contract\"})\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/contract_controller.ex:1: BlockScoutWeb.API.RPC.ContractController.action/2\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/contract_controller.ex:1: BlockScoutWeb.API.RPC.ContractController.phoenix_controller_pipeline/2\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/rpc_translator.ex:119: BlockScoutWeb.API.RPC.RPCTranslator.call_controller/3\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/rpc_translator.ex:37: BlockScoutWeb.API.RPC.RPCTranslator.call/2\n    (phoenix 1.5.14) lib/phoenix/router/route.ex:41: Phoenix.Router.Route.call/2\n    (phoenix 1.5.14) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2\n    (phoenix 1.5.14) lib/phoenix/router/route.ex:41: Phoenix.Router.Route.call/2\n    (phoenix 1.5.14) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2\n    (block_scout_web 6.0.0) lib/block_scout_web/endpoint.ex:1: BlockScoutWeb.Endpoint.plug_builder_call/2\n    (block_scout_web 6.0.0) /Users/v/blockscout/deps/plug/lib/plug/debugger.ex:136: BlockScoutWeb.Endpoint.\"call (overridable 3)\"/2\n    (block_scout_web 6.0.0) lib/block_scout_web/endpoint.ex:1: BlockScoutWeb.Endpoint.\"call (overridable 4)\"/2\n    (block_scout_web 6.0.0) /Users/v/blockscout/deps/spandex_phoenix/lib/spandex_phoenix.ex:151: BlockScoutWeb.Endpoint.call/2\n    (phoenix 1.5.14) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4\n    (cowboy 2.10.0) /Users/v/blockscout/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2\n    (cowboy 2.10.0) /Users/v/blockscout/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3\n    (cowboy 2.10.0) /Users/v/blockscout/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3\n    (stdlib 4.3.1.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3\n

@nikitosing
Copy link
Member Author

@vbaranov Thanks! Done in fcf6705

Copy link
Member

@vbaranov vbaranov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error in checkproxyverification endpoint
http://localhost:4000/api/v1?module=contract&action=checkproxyverification&guid=5267789f4b7b4efd7bcb235d045080b9798ad87c659e7792

2024-01-10T13:59:41.047 application=api request_id=F6j3T8tJAkuQ_aQAAPPD [error] Error while calling RPC action"** (Plug.Conn.WrapperError) ** (KeyError) key :status not found in: nil. If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/contract_controller.ex:264: BlockScoutWeb.API.RPC.ContractController.checkproxyverification/2\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/contract_controller.ex:1: BlockScoutWeb.API.RPC.ContractController.action/2\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/contract_controller.ex:1: BlockScoutWeb.API.RPC.ContractController.phoenix_controller_pipeline/2\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/rpc_translator.ex:119: BlockScoutWeb.API.RPC.RPCTranslator.call_controller/3\n    (block_scout_web 6.0.0) lib/block_scout_web/controllers/api/rpc/rpc_translator.ex:37: BlockScoutWeb.API.RPC.RPCTranslator.call/2\n    (phoenix 1.5.14) lib/phoenix/router/route.ex:41: Phoenix.Router.Route.call/2\n    (phoenix 1.5.14) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2\n    (phoenix 1.5.14) lib/phoenix/router/route.ex:41: Phoenix.Router.Route.call/2\n    (phoenix 1.5.14) lib/phoenix/router.ex:352: Phoenix.Router.__call__/2\n    (block_scout_web 6.0.0) lib/block_scout_web/endpoint.ex:1: BlockScoutWeb.Endpoint.plug_builder_call/2\n    (block_scout_web 6.0.0) /Users/v/blockscout/deps/plug/lib/plug/debugger.ex:136: BlockScoutWeb.Endpoint.\"call (overridable 3)\"/2\n    (block_scout_web 6.0.0) lib/block_scout_web/endpoint.ex:1: BlockScoutWeb.Endpoint.\"call (overridable 4)\"/2\n    (block_scout_web 6.0.0) /Users/v/blockscout/deps/spandex_phoenix/lib/spandex_phoenix.ex:151: BlockScoutWeb.Endpoint.call/2\n    (phoenix 1.5.14) lib/phoenix/endpoint/cowboy2_handler.ex:65: Phoenix.Endpoint.Cowboy2Handler.init/4\n    (cowboy 2.10.0) /Users/v/blockscout/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2\n    (cowboy 2.10.0) /Users/v/blockscout/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3\n    (cowboy 2.10.0) /Users/v/blockscout/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3\n    (stdlib 4.3.1.2) proc_lib.erl:240: :proc_lib.init_p_do_apply/3\n"

@nikitosing
Copy link
Member Author

@vbaranov nice catch! fixed in ff10166

@vbaranov vbaranov merged commit 7f0cdc8 into master Jan 19, 2024
41 checks passed
@vbaranov vbaranov deleted the np-api-parity branch January 19, 2024 14:49
DaMandal0rian pushed a commit to subspace/blockscout-backend that referenced this pull request Feb 22, 2024
* Done tokennfttx endpoint

* Add solidity-single-file verification option to verifysourcecode endpoint

* Fix tokentx bug

* Add verifyproxycontract and checkproxyverification endpoints

* Do not return twin contracts in getsourcecode RPC API endpoint

* Process review comments

* Update messages

* Reset GA cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RPC API Tokentx returning different results
3 participants