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

根据链 id 获取 合约地址

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