token_id needs to be able to hold 14251919818366649780

Seen in https://circleci.com/gh/poanetwork/blockscout/21320, so assume
token_id can be EVM native 256-bit, which would be 2^256 or ~ 10^78.
pull/547/head
Luke Imhoff 6 years ago
parent c9bf6ed23d
commit 355fbcf9c7
  1. 2
      apps/explorer/lib/explorer/chain/token_transfer.ex
  2. 3
      apps/explorer/priv/repo/migrations/20180606135150_create_token_transfers.exs

@ -67,7 +67,7 @@ defmodule Explorer.Chain.TokenTransfer do
schema "token_transfers" do
field(:amount, :decimal)
field(:log_index, :integer)
field(:token_id, :integer)
field(:token_id, :decimal)
belongs_to(:from_address, Address, foreign_key: :from_address_hash, references: :hash, type: Hash.Address)
belongs_to(:to_address, Address, foreign_key: :to_address_hash, references: :hash, type: Hash.Address)

@ -15,7 +15,8 @@ defmodule Explorer.Repo.Migrations.CreateTokenTransfers do
# Some token transfers do not have a fungible value like ERC721 transfers
add(:amount, :decimal, null: true)
# ERC-721 tokens have IDs
add(:token_id, :integer, null: true)
# 10^x = 2^256, x ~ 77.064, so 78 decimal digits will store the full 256-bits of a native EVM type
add(:token_id, :numeric, precision: 78, scale: 0, null: true)
add(:token_contract_address_hash, references(:addresses, column: :hash, type: :bytea), null: false)
timestamps()

Loading…
Cancel
Save