Add dip20 holder count and improve token show style
This commit is contained in:
parent
a6ddfcac24
commit
50b2d3c666
@ -1,5 +1,6 @@
|
||||
.token-logo
|
||||
max-width: 100%
|
||||
width: 4.20rem
|
||||
|
||||
.table-container
|
||||
background: #39272799
|
||||
@ -12,3 +13,6 @@ table.token-index
|
||||
.token-logo
|
||||
max-width: 4rem
|
||||
vertical-align: middle
|
||||
|
||||
.token-show
|
||||
font-size: 1rem
|
||||
|
||||
@ -26,11 +26,17 @@ class TokensController < ApplicationController
|
||||
# if call icrc1_metadata #icrc1
|
||||
metadata = `dfx canister --network ic call #{@token.canister_id} icrc1_metadata 2>&1`
|
||||
if metadata.scan(/no update method/).present?
|
||||
# TODO: Use getTokenInfo instead of getMetadata
|
||||
metadata = `dfx canister --network ic call #{@token.canister_id} getMetadata 2>&1`
|
||||
if metadata.scan(/no update method/).present?
|
||||
@token.standard = :unknown
|
||||
else
|
||||
@token.standard = :dip20
|
||||
|
||||
# TODO: Use getTokenInfo instead of getMetadata
|
||||
tokenInfo = `dfx canister --network ic call #{@token.canister_id} getTokenInfo 2>&1`
|
||||
@token.holder_number = tokenInfo.lines[2].split[2]
|
||||
|
||||
@token.transfer_fee = metadata.lines[2].split[2].to_i
|
||||
@token.decimals = metadata.lines[3].split[2]
|
||||
# @token.owner = metadata.lines[4].split[3]
|
||||
|
||||
@ -9,4 +9,13 @@ class Token < ActiveRecord::Base
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def get_holder_number
|
||||
if self.standard == "dip20"
|
||||
tokenInfo = `dfx canister --network ic call #{self.canister_id} getTokenInfo 2>&1`
|
||||
tokenInfo.lines[2].split[2]
|
||||
else
|
||||
"Get holder number coming soon."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,35 +1,42 @@
|
||||
.contain
|
||||
%h1
|
||||
= @token.name
|
||||
|
||||
- if policy(@token).edit?
|
||||
= link_to 'Edit', edit_token_path(@token)
|
||||
= link_to 'Delete', @token, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
- if policy(@token).edit?
|
||||
= link_to 'Edit', edit_token_path(@token)
|
||||
= link_to 'Delete', @token, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
|
||||
= link_to "Refresh Data", refresh_token_path(@token)
|
||||
= link_to "Refresh Data", refresh_token_path(@token)
|
||||
|
||||
%p
|
||||
%b Canister:
|
||||
= @token.canister_id
|
||||
%p
|
||||
%b Logo:
|
||||
- if @token.logo_url.present?
|
||||
-# %img{src: @token.logo_url}
|
||||
-# :escaped
|
||||
=raw "<img class='token-logo' src=#{@token.logo_url} />"
|
||||
%p
|
||||
%b Standard:
|
||||
= @token.standard
|
||||
%p
|
||||
%b Symbol:
|
||||
= @token.symbol
|
||||
%p
|
||||
%b Name:
|
||||
= @token.name
|
||||
%p
|
||||
%b Total supply:
|
||||
= @token.total_supply
|
||||
%p
|
||||
%b Decimals:
|
||||
= @token.decimals
|
||||
%p
|
||||
%b Transfer fee:
|
||||
= @token.transfer_fee_to_f
|
||||
.token-show
|
||||
%p
|
||||
%b Canister:
|
||||
= @token.canister_id
|
||||
%p
|
||||
%b Logo:
|
||||
- if @token.logo_url.present?
|
||||
-# %img{src: @token.logo_url}
|
||||
-# :escaped
|
||||
=raw "<img class='token-logo' src=#{@token.logo_url} />"
|
||||
%p
|
||||
%b Standard:
|
||||
= @token.standard
|
||||
%p
|
||||
%b Symbol:
|
||||
= @token.symbol
|
||||
%p
|
||||
%b Name:
|
||||
= @token.name
|
||||
%p
|
||||
%b Total supply:
|
||||
= @token.total_supply
|
||||
%p
|
||||
%b Decimals:
|
||||
= @token.decimals
|
||||
%p
|
||||
%b Transfer fee:
|
||||
= @token.transfer_fee_to_f
|
||||
%p
|
||||
%b Holders:
|
||||
= @token.holder_number
|
||||
|
||||
|
||||
5
db/migrate/20231208104330_add_holder_number_to_token.rb
Normal file
5
db/migrate/20231208104330_add_holder_number_to_token.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class AddHolderNumberToToken < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
add_column :tokens, :holder_number, :integer
|
||||
end
|
||||
end
|
||||
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2023_12_04_083004) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2023_12_08_104330) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
@ -250,6 +250,7 @@ ActiveRecord::Schema[7.1].define(version: 2023_12_04_083004) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "logo_url"
|
||||
t.integer "holder_number"
|
||||
t.index ["canister_id"], name: "index_tokens_on_canister_id", unique: true
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user