Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockscout/apps/explorer/lib/encrypt.ex

117 lines
3.0 KiB

defmodule Mix.Tasks.Encrypt do
@moduledoc "The encrypt mix task: `mix help encrypt`"
use Mix.Task
2 years ago
alias Ecto.Changeset
alias Explorer.Account.{
CustomABI,
Identity,
PublicTagsRequest,
TagAddress,
TagTransaction,
WatchlistAddress,
WatchlistNotification
}
2 years ago
alias Explorer.Repo.Account
alias Mix.Task
@shortdoc "Encrypt"
def run(_) do
2 years ago
Task.run("app.start")
2 years ago
Identity
|> Account.all()
|> Enum.each(fn element ->
element
2 years ago
|> Changeset.change(%{
encrypted_uid: element.uid,
encrypted_email: element.email,
encrypted_name: element.name,
encrypted_nickname: element.nickname,
encrypted_avatar: element.avatar,
2 years ago
uid_hash: element.uid
})
2 years ago
|> Account.update!()
end)
2 years ago
TagAddress
|> Account.all()
|> Enum.each(fn element ->
element
2 years ago
|> Changeset.change(%{
encrypted_name: element.name,
encrypted_address_hash: element.address_hash,
2 years ago
address_hash_hash: element.address_hash |> to_string() |> String.downcase()
})
2 years ago
|> Account.update!()
end)
2 years ago
TagTransaction
|> Account.all()
|> Enum.each(fn element ->
element
2 years ago
|> Changeset.change(%{
encrypted_name: element.name,
encrypted_tx_hash: element.tx_hash,
2 years ago
tx_hash_hash: element.tx_hash |> to_string() |> String.downcase()
})
2 years ago
|> Account.update!()
end)
2 years ago
CustomABI
|> Account.all()
|> Enum.each(fn element ->
element
2 years ago
|> Changeset.change(%{
encrypted_name: element.name,
encrypted_address_hash: element.address_hash,
2 years ago
address_hash_hash: element.address_hash |> to_string() |> String.downcase()
})
2 years ago
|> Account.update!()
end)
2 years ago
WatchlistAddress
|> Account.all()
|> Enum.each(fn element ->
element
2 years ago
|> Changeset.change(%{
encrypted_name: element.name,
encrypted_address_hash: element.address_hash,
2 years ago
address_hash_hash: element.address_hash |> to_string() |> String.downcase()
})
2 years ago
|> Account.update!()
end)
2 years ago
WatchlistNotification
|> Account.all()
|> Enum.each(fn element ->
element
2 years ago
|> Changeset.change(%{
encrypted_name: element.name,
encrypted_from_address_hash: element.from_address_hash,
encrypted_to_address_hash: element.to_address_hash,
encrypted_transaction_hash: element.transaction_hash,
encrypted_subject: element.subject,
2 years ago
from_address_hash_hash: element.from_address_hash |> to_string() |> String.downcase(),
to_address_hash_hash: element.to_address_hash |> to_string() |> String.downcase(),
transaction_hash_hash: element.transaction_hash |> to_string() |> String.downcase(),
subject_hash: element.subject
})
2 years ago
|> Account.update!()
end)
PublicTagsRequest
|> Account.all()
|> Enum.each(fn element ->
element
|> Changeset.change(%{
encrypted_full_name: element.full_name,
encrypted_email: element.email
})
|> Account.update!()
end)
end
end