Skip to content

Commit

Permalink
update dToken hanlder on dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrobot2003 committed Mar 25, 2021
1 parent 356addc commit 8a46377
Showing 3 changed files with 36 additions and 1 deletion.
8 changes: 8 additions & 0 deletions web-dapp/src/abi/env.js
Original file line number Diff line number Diff line change
@@ -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: {
21 changes: 20 additions & 1 deletion web-dapp/src/admin.js
Original file line number Diff line number Diff line change
@@ -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,14 +18,18 @@ 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) {
super(props);

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]]) {
8 changes: 8 additions & 0 deletions web-dapp/src/utils.js
Original file line number Diff line number Diff line change
@@ -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) => {

0 comments on commit 8a46377

Please sign in to comment.