From 8a463773e34e8941e054b284ea65c3eaf96065f2 Mon Sep 17 00:00:00 2001 From: gaoyang Date: Thu, 25 Mar 2021 15:44:17 +0800 Subject: [PATCH] update dToken hanlder on dashboard --- web-dapp/src/abi/env.js | 8 ++++++++ web-dapp/src/admin.js | 21 ++++++++++++++++++++- web-dapp/src/utils.js | 8 ++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/web-dapp/src/abi/env.js b/web-dapp/src/abi/env.js index 926d66b..eb1c636 100755 --- a/web-dapp/src/abi/env.js +++ b/web-dapp/src/abi/env.js @@ -67,6 +67,10 @@ function env() { DAI: "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3", dDAI: "0x4E0B5BaFC52D09A8F18eA0b7a6A7dc23A1096f99", DTokenCommonData: "0xb8e898a9c3AfdAEbc8e74581273eEFc006fdE0c5", + Handler: { + '0xC46751E2494897eB34E2297bEB649672dBabF975': "Internal", + '0xdE399d88eA8331fE2F18306793893a46D142cc5f': "CreamHandler" + } }, }, DECIMALS: { @@ -160,6 +164,10 @@ function env() { DAI: "0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3", dDAI: "0x4E0B5BaFC52D09A8F18eA0b7a6A7dc23A1096f99", DTokenCommonData: "0xb8e898a9c3AfdAEbc8e74581273eEFc006fdE0c5", + Handler: { + '0xC46751E2494897eB34E2297bEB649672dBabF975': "Internal", + '0xdE399d88eA8331fE2F18306793893a46D142cc5f': "CreamHandler" + } }, }, DECIMALS: { diff --git a/web-dapp/src/admin.js b/web-dapp/src/admin.js index 67891b7..f68668f 100644 --- a/web-dapp/src/admin.js +++ b/web-dapp/src/admin.js @@ -5,6 +5,7 @@ import './style/model.scss'; import Web3 from 'web3'; import { get_nettype, + get_nettypeID, init_baseData_contract, format_bn, format_num_to_K, @@ -17,6 +18,9 @@ import env from './abi/env'; let token_abi_d = require('./abi/tokensABI_d.json'); let address_map = env.ADDRESS; +let token_list__main = Object.keys(env.DECIMALS.main); +let token_list__bsc = Object.keys(env.DECIMALS.bsc); + class Admin extends Component { constructor(props) { @@ -24,7 +28,8 @@ class Admin extends Component { this.state = { active_index: 0, - token_name: ['USDT', 'USDC', 'DAI', 'TUSD', 'PAX', 'USDx'], + // token_name: ['USDT', 'USDC', 'DAI', 'TUSD', 'PAX', 'USDx'], + token_name: [], show_rebalance: false, token_status: {} } @@ -36,6 +41,20 @@ class Admin extends Component { init_status = async () => { let nettype = await get_nettype(this.new_web3); + let nettypeID = await get_nettypeID(this.new_web3); + + if (nettypeID === 56) { + nettype = 'bsc' + this.setState({ + token_name: token_list__bsc + }) + } else { + this.setState({ + token_name: token_list__main + }) + } + + // console.log('nettype*****', nettypeID); for (let i = 0; i < this.state.token_name.length; i++) { // console.log(address_map[nettype][this.state.token_name[i]]); if (!address_map[nettype][this.state.token_name[i]]) { diff --git a/web-dapp/src/utils.js b/web-dapp/src/utils.js index 0524b8f..eacd274 100644 --- a/web-dapp/src/utils.js +++ b/web-dapp/src/utils.js @@ -77,6 +77,14 @@ export const get_nettype = (instance_web3) => { }) }) } +export const get_nettypeID = (instance_web3) => { + return new Promise((resolve, reject) => { + instance_web3.eth.getChainId().then(net_typeID => { + // console.log(net_type); + resolve(net_typeID); + }) + }) +} export const get_decimals = (contract) => { return new Promise((resolve, reject) => { contract.methods.decimals().call((err, res_decimals) => {