Merge pull request #4294 from blockscout/np-contract-verification-fix

Аdded check in web if a contract already verified
pull/4295/head
Victor Baranov 3 years ago committed by GitHub
commit 9b8432789f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_controller.ex
  3. 5
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_via_flattened_code_controller.ex
  4. 5
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_verification_via_json_controller.ex

@ -9,6 +9,7 @@
- [#4067](https://github.com/blockscout/blockscout/pull/4067) - Display LP tokens USD value and custom metadata in tokens dropdown at address page - [#4067](https://github.com/blockscout/blockscout/pull/4067) - Display LP tokens USD value and custom metadata in tokens dropdown at address page
### Fixes ### Fixes
- [#4294](https://github.com/blockscout/blockscout/pull/4294) - User wont be able to open verification pages for verified smart-contract
- [#4240](https://github.com/blockscout/blockscout/pull/4240) - `[]` is accepted in write contract page - [#4240](https://github.com/blockscout/blockscout/pull/4240) - `[]` is accepted in write contract page
- [#4236](https://github.com/blockscout/blockscout/pull/4236), [#4242](https://github.com/blockscout/blockscout/pull/4242) - Fix typo, constructor instead of contructor - [#4236](https://github.com/blockscout/blockscout/pull/4236), [#4242](https://github.com/blockscout/blockscout/pull/4242) - Fix typo, constructor instead of contructor
- [#4167](https://github.com/blockscout/blockscout/pull/4167) - Deduplicate block numbers in acquire_blocks function - [#4167](https://github.com/blockscout/blockscout/pull/4167) - Deduplicate block numbers in acquire_blocks function

@ -10,6 +10,9 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
alias Explorer.ThirdPartyIntegrations.Sourcify alias Explorer.ThirdPartyIntegrations.Sourcify
def new(conn, %{"address_id" => address_hash_string}) do def new(conn, %{"address_id" => address_hash_string}) do
if Chain.smart_contract_verified?(address_hash_string) do
redirect(conn, to: address_path(conn, :show, address_hash_string))
else
changeset = changeset =
SmartContract.changeset( SmartContract.changeset(
%SmartContract{address_hash: address_hash_string}, %SmartContract{address_hash: address_hash_string},
@ -32,6 +35,7 @@ defmodule BlockScoutWeb.AddressContractVerificationController do
address_hash: address_hash_string address_hash: address_hash_string
) )
end end
end
def create( def create(
conn, conn,

@ -1,10 +1,14 @@
defmodule BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController do defmodule BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController do
use BlockScoutWeb, :controller use BlockScoutWeb, :controller
alias Explorer.Chain
alias Explorer.Chain.SmartContract alias Explorer.Chain.SmartContract
alias Explorer.SmartContract.{PublisherWorker, Solidity.CodeCompiler, Solidity.CompilerVersion} alias Explorer.SmartContract.{PublisherWorker, Solidity.CodeCompiler, Solidity.CompilerVersion}
def new(conn, %{"address_id" => address_hash_string}) do def new(conn, %{"address_id" => address_hash_string}) do
if Chain.smart_contract_verified?(address_hash_string) do
redirect(conn, to: address_path(conn, :show, address_hash_string))
else
changeset = changeset =
SmartContract.changeset( SmartContract.changeset(
%SmartContract{address_hash: address_hash_string}, %SmartContract{address_hash: address_hash_string},
@ -27,6 +31,7 @@ defmodule BlockScoutWeb.AddressContractVerificationViaFlattenedCodeController do
address_hash: address_hash_string address_hash: address_hash_string
) )
end end
end
def create( def create(
conn, conn,

@ -2,10 +2,14 @@ defmodule BlockScoutWeb.AddressContractVerificationViaJsonController do
use BlockScoutWeb, :controller use BlockScoutWeb, :controller
alias BlockScoutWeb.AddressContractVerificationController, as: VerificationController alias BlockScoutWeb.AddressContractVerificationController, as: VerificationController
alias Explorer.Chain
alias Explorer.Chain.SmartContract alias Explorer.Chain.SmartContract
alias Explorer.ThirdPartyIntegrations.Sourcify alias Explorer.ThirdPartyIntegrations.Sourcify
def new(conn, %{"address_id" => address_hash_string}) do def new(conn, %{"address_id" => address_hash_string}) do
if Chain.smart_contract_verified?(address_hash_string) do
redirect(conn, to: address_path(conn, :show, address_hash_string))
else
case Sourcify.check_by_address(address_hash_string) do case Sourcify.check_by_address(address_hash_string) do
{:ok, _verified_status} -> {:ok, _verified_status} ->
VerificationController.get_metadata_and_publish(address_hash_string, conn) VerificationController.get_metadata_and_publish(address_hash_string, conn)
@ -22,3 +26,4 @@ defmodule BlockScoutWeb.AddressContractVerificationViaJsonController do
end end
end end
end end
end

Loading…
Cancel
Save