Add dip20 holder count and improve token show style
This commit is contained in:
parent
991de51e49
commit
64ebd1c509
@ -1,5 +1,6 @@
|
|||||||
.token-logo
|
.token-logo
|
||||||
max-width: 100%
|
max-width: 100%
|
||||||
|
width: 4.20rem
|
||||||
|
|
||||||
.table-container
|
.table-container
|
||||||
background: #39272799
|
background: #39272799
|
||||||
@ -12,3 +13,6 @@ table.token-index
|
|||||||
.token-logo
|
.token-logo
|
||||||
max-width: 4rem
|
max-width: 4rem
|
||||||
vertical-align: middle
|
vertical-align: middle
|
||||||
|
|
||||||
|
.token-show
|
||||||
|
font-size: 1rem
|
||||||
|
|||||||
@ -26,11 +26,17 @@ class TokensController < ApplicationController
|
|||||||
# if call icrc1_metadata #icrc1
|
# if call icrc1_metadata #icrc1
|
||||||
metadata = `dfx canister --network ic call #{@token.canister_id} icrc1_metadata 2>&1`
|
metadata = `dfx canister --network ic call #{@token.canister_id} icrc1_metadata 2>&1`
|
||||||
if metadata.scan(/no update method/).present?
|
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`
|
metadata = `dfx canister --network ic call #{@token.canister_id} getMetadata 2>&1`
|
||||||
if metadata.scan(/no update method/).present?
|
if metadata.scan(/no update method/).present?
|
||||||
@token.standard = :unknown
|
@token.standard = :unknown
|
||||||
else
|
else
|
||||||
@token.standard = :dip20
|
@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.transfer_fee = metadata.lines[2].split[2].to_i
|
||||||
@token.decimals = metadata.lines[3].split[2]
|
@token.decimals = metadata.lines[3].split[2]
|
||||||
# @token.owner = metadata.lines[4].split[3]
|
# @token.owner = metadata.lines[4].split[3]
|
||||||
|
|||||||
@ -9,4 +9,13 @@ class Token < ActiveRecord::Base
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
@ -1,35 +1,42 @@
|
|||||||
|
.contain
|
||||||
|
%h1
|
||||||
|
= @token.name
|
||||||
|
|
||||||
- if policy(@token).edit?
|
- if policy(@token).edit?
|
||||||
= link_to 'Edit', edit_token_path(@token)
|
= link_to 'Edit', edit_token_path(@token)
|
||||||
= link_to 'Delete', @token, method: :delete, data: { confirm: 'Are you sure?' }
|
= 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
|
.token-show
|
||||||
%b Canister:
|
%p
|
||||||
= @token.canister_id
|
%b Canister:
|
||||||
%p
|
= @token.canister_id
|
||||||
%b Logo:
|
%p
|
||||||
- if @token.logo_url.present?
|
%b Logo:
|
||||||
-# %img{src: @token.logo_url}
|
- if @token.logo_url.present?
|
||||||
-# :escaped
|
-# %img{src: @token.logo_url}
|
||||||
=raw "<img class='token-logo' src=#{@token.logo_url} />"
|
-# :escaped
|
||||||
%p
|
=raw "<img class='token-logo' src=#{@token.logo_url} />"
|
||||||
%b Standard:
|
%p
|
||||||
= @token.standard
|
%b Standard:
|
||||||
%p
|
= @token.standard
|
||||||
%b Symbol:
|
%p
|
||||||
= @token.symbol
|
%b Symbol:
|
||||||
%p
|
= @token.symbol
|
||||||
%b Name:
|
%p
|
||||||
= @token.name
|
%b Name:
|
||||||
%p
|
= @token.name
|
||||||
%b Total supply:
|
%p
|
||||||
= @token.total_supply
|
%b Total supply:
|
||||||
%p
|
= @token.total_supply
|
||||||
%b Decimals:
|
%p
|
||||||
= @token.decimals
|
%b Decimals:
|
||||||
%p
|
= @token.decimals
|
||||||
%b Transfer fee:
|
%p
|
||||||
= @token.transfer_fee_to_f
|
%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.
|
# 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
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
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 "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.string "logo_url"
|
t.string "logo_url"
|
||||||
|
t.integer "holder_number"
|
||||||
t.index ["canister_id"], name: "index_tokens_on_canister_id", unique: true
|
t.index ["canister_id"], name: "index_tokens_on_canister_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user