forked from blockscout/blockscout
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Certified smart contracts (blockscout#9910)
* Certified smart-contracts * Prioritize certified smart-contracts in the search * Refactoring: remove CustomContractsHelper * Return certified in the list and in the search * mix format * Fix tests * Process review comment
- Loading branch information
Showing
13 changed files
with
125 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
apps/explorer/lib/explorer/smart_contract/certified_smart_contract_cataloger.ex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defmodule Explorer.SmartContract.CertifiedSmartContractCataloger do | ||
@moduledoc """ | ||
Actualizes certified smart-contracts. | ||
""" | ||
|
||
use GenServer, restart: :transient | ||
|
||
alias Explorer.Chain.SmartContract | ||
|
||
def start_link(_) do | ||
GenServer.start_link(__MODULE__, :ok, name: __MODULE__) | ||
end | ||
|
||
@impl GenServer | ||
def init(args) do | ||
send(self(), :fetch_certified_smart_contracts) | ||
|
||
{:ok, args} | ||
end | ||
|
||
@impl GenServer | ||
def handle_info(:fetch_certified_smart_contracts, state) do | ||
certified_contracts_list = Application.get_env(:block_scout_web, :contract)[:certified_list] | ||
|
||
SmartContract.set_smart_contracts_certified_flag(certified_contracts_list) | ||
|
||
{:noreply, state} | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
apps/explorer/priv/repo/migrations/20240417141515_smart_contracts_add_certified_flag.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Explorer.Repo.Migrations.SmartContractsAddCertifiedFlag do | ||
use Ecto.Migration | ||
@disable_ddl_transaction true | ||
@disable_migration_lock true | ||
|
||
def change do | ||
alter table("smart_contracts") do | ||
add(:certified, :boolean, null: true) | ||
end | ||
|
||
create_if_not_exists(index(:smart_contracts, [:certified])) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters