提交 b72e2909 authored 作者: zhanglian's avatar zhanglian

根据链 id 获取 合约地址

上级 4a3ec0c5
差异被折叠。
......@@ -90,15 +90,54 @@ const tokenListDev = [{
const tokenListPro = [
{
name: 'TKM',
index: 1,
chainName: 'thk',
chainId: 70001,
url: '',
balance: '0',
type: 'main',
contractAddress: '',
},
{
name: 'TUSDT',
index: 2,
chainName: 'thk',
chainId: 70001,
url: 'https://pancakeswap.finance/images/tokens/0xe9e7cea3dedca5984780bafc599bd69add087d56.png',
balance: '0',
type: 'erc20',
contractAddress: '0x50F102b368968F1bf5B8Ce1354AF61FF3c6e89a1',
},
{
name: 'BTKM',
index: 1,
chainName: 'bsc',
chainId: 56,
url: '',
balance: '0',
type: 'erc20',
contractAddress: '0x0806c5b183F8a622fE62c7344B04e6e6A7C82c2e',
},
{
name: 'BUSDT',
index: 2,
chainName: 'bsc',
chainId: 56,
url: 'https://pancakeswap.finance/images/tokens/0xe9e7cea3dedca5984780bafc599bd69add087d56.png',
balance: '0',
type: 'erc20',
contractAddress: '0x337610d27c682e347c9cd60bd4b3b107c9d34ddd',
},
]
export function getTokenList(currentChainId){
currentChainId -= 0;
// if([60001, 97, 1337].includes(currentChainId)){
// return tokenListDev;
// }else{
// return tokenListPro;
// }
return tokenListDev;
console.log('---currentChainId', currentChainId);
if([60001, 97, 1337].includes(currentChainId)){
return tokenListDev;
}else if([70001, 56].includes(currentChainId)){
return tokenListPro;
}
}
\ No newline at end of file
......@@ -74,9 +74,9 @@ const { mapState: mapStateWallet } = createNamespacedHelpers('wallet');
const { mapState: mapStateNetwork } = createNamespacedHelpers('network');
const erc20Abi = require('../../abi/ERC20.json');
const bridgeAbi = require('../../abi/bridge.json');
const bridgeContractAddress = '0x35645227C22c47Fe26953F14C8210b8Eb347CCd2';
let bridge;
export default {
data() {
......@@ -171,18 +171,7 @@ export default {
}
console.log('----123', token);
this.changeSelect(0, token)
if (!this.walletConnected) {
return;
}
let overrides = {
gasLimit: 300000,
from: window.defaultAccount,
// gasLimit: 1000000,
value: '0x0'
}
bridge = new window.web3.eth.Contract(bridgeAbi, bridgeContractAddress, overrides);
},
refreshBalance() {
this.rbalance++
......@@ -288,27 +277,27 @@ export default {
let holdName = this.holdItem.coinData.name
let isTKM = holdName == 'TKM' || holdName == 'BTKM' || holdName == 'TKM3' || holdName == 'BTKM3'
let minNum = 0
if (isTKM && value < 1000) {
minNum = 1000
this.$dialog.alert({
title: this.$t('title'),
message: this.$t('placeholder3', { minNum }),
confirmButtonText: this.$t('confirm')
}).then(() => {
// on close
});
return;
} else if (!isTKM && value < 200) {
minNum = 200
this.$dialog.alert({
title: this.$t('title'),
message: this.$t('placeholder3', { minNum }),
confirmButtonText: this.$t('confirm')
}).then(() => {
// on close
});
return;
}
// if (isTKM && value < 1000) {
// minNum = 1000
// this.$dialog.alert({
// title: this.$t('title'),
// message: this.$t('placeholder3', { minNum }),
// confirmButtonText: this.$t('confirm')
// }).then(() => {
// // on close
// });
// return;
// } else if (!isTKM && value < 200) {
// minNum = 200
// this.$dialog.alert({
// title: this.$t('title'),
// message: this.$t('placeholder3', { minNum }),
// confirmButtonText: this.$t('confirm')
// }).then(() => {
// // on close
// });
// return;
// }
this.pageLoading = true;
try {
if (holdItem.coinData.type == 'main') {
......@@ -327,6 +316,7 @@ export default {
this.refreshBalance();
} catch (err) {
console.log('--err-transfer', err);
this.$notify({ type: 'warning', message: this.$t('failedTransfer') });
}
......@@ -340,14 +330,14 @@ export default {
let overrides = {
value,
}
await bridge.methods.depositNative(...params).send(overrides)
await window._bridge.methods.depositNative(...params).send(overrides)
},
async depositToken({ value, tokenAddress, address = window.defaultAccount, chain }) {
let token = '';
await this.approve({
value,
contractAddress: tokenAddress,
spender: bridgeContractAddress,
spender: window.bridgeContractAddress,
})
let params = [
tokenAddress,
......@@ -355,7 +345,7 @@ export default {
address,
chain
]
await bridge.methods.depositToken(...params).send();
await window._bridge.methods.depositToken(...params).send();
},
async approve({ value, contractAddress, owner = window.defaultAccount, spender }) {
console.log({ value, contractAddress, owner, spender });
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论