Skip to content

Commit

Permalink
Set updated_at on token update even if there are no changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Qwerty5Uiop committed Mar 13, 2023
1 parent 8003244 commit 689733b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,7 @@
- [#7008](https://github.com/blockscout/blockscout/pull/7008) - Fetch image/video content from IPFS link
- [#7007](https://github.com/blockscout/blockscout/pull/7007) - Token instance fetcher fixes
- [#7009](https://github.com/blockscout/blockscout/pull/7009) - Fix updating coin balances with empty value
- [#7055](https://github.com/blockscout/blockscout/pull/7055) - Set updated_at on token update even if there are no changes

### Chore

Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/lib/explorer/chain.ex
Expand Up @@ -5082,7 +5082,7 @@ defmodule Explorer.Chain do
"""
@spec update_token(Token.t(), map()) :: {:ok, Token.t()} | {:error, Ecto.Changeset.t()}
def update_token(%Token{contract_address_hash: address_hash} = token, params \\ %{}) do
token_changeset = Token.changeset(token, params)
token_changeset = Token.changeset(token, Map.put(params, :updated_at, DateTime.utc_now()))
address_name_changeset = Address.Name.changeset(%Address.Name{}, Map.put(params, :address_hash, address_hash))

stale_error_field = :contract_address_hash
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/lib/explorer/chain/token.ex
Expand Up @@ -93,7 +93,7 @@ defmodule Explorer.Chain.Token do
end

@required_attrs ~w(contract_address_hash type)a
@optional_attrs ~w(cataloged decimals name symbol total_supply skip_metadata total_supply_updated_at_block)a
@optional_attrs ~w(cataloged decimals name symbol total_supply skip_metadata total_supply_updated_at_block updated_at)a

@doc false
def changeset(%Token{} = token, params \\ %{}) do
Expand Down

0 comments on commit 689733b

Please sign in to comment.