Skip to content

Commit 22e0bc2

Browse files
committed
add in MetaMask switch network
1 parent ec6afd5 commit 22e0bc2

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/assets/locales/en.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ swap:
541541
rejectMetamask: Approval in MetaMask is rejected
542542
requestFromSwap: Requesting from swap service
543543
retry: Retry
544-
selectNetworkToSwap: 'Please select {network} on MetaMask to swap'
544+
selectNetworkToSwap: 'Please switch to {network} on MetaMask to swap'
545545
sendMsgFail: Unable to send message to swap service
546546
sendRequest: Send Request
547547
sendingMsg: Sending message to MetaMask

src/assets/locales/es.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ swap:
533533
rejectMetamask: Approval in MetaMask is rejected
534534
requestFromSwap: Requesting from swap service
535535
retry: Retry
536-
selectNetworkToSwap: 'Please select {network} on MetaMask to swap'
536+
selectNetworkToSwap: 'Please switch to {network} on MetaMask to swap'
537537
sendMsgFail: Unable to send message to swap service
538538
sendRequest: Send Request
539539
sendingMsg: Sending message to MetaMask

src/modules/services/submodule/mainnetSwap/submodule2/bsc/views/ViewServicesMainnetSwapBSCToSirius.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ export default {
613613
isMetamaskConnected.value = ethereum.isConnected()?true:false;
614614
}
615615
616-
function verifyChain(chainId, updateTokenBol = false){
616+
async function verifyChain(chainId, updateTokenBol = false){
617617
currentNetwork.value = chainId;
618618
if(bscChainId === parseInt(chainId)){
619619
err.value = '';
@@ -622,6 +622,10 @@ export default {
622622
}
623623
}else{
624624
err.value = t('swap.selectNetworkToSwap',{network: bscNetworkName});
625+
await ethereum.request({
626+
method: 'wallet_switchEthereumChain',
627+
params: [{ chainId: '0x38' }]
628+
});
625629
}
626630
}
627631

src/modules/services/submodule/mainnetSwap/submodule2/bsc/views/ViewServicesMainnetSwapCheckBSCToSirius.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,16 @@ export default {
456456
isMetamaskConnected.value = ethereum.isConnected()?true:false;
457457
}
458458
459-
function verifyChain(chainId){
459+
async function verifyChain(chainId){
460460
currentNetwork.value = chainId;
461461
if(bscChainId === parseInt(chainId)){
462462
err.value = '';
463463
}else{
464464
err.value = t('swap.selectNetworkToSwap',{network: bscNetworkName});
465+
await ethereum.request({
466+
method: 'wallet_switchEthereumChain',
467+
params: [{ chainId: '0x38' }]
468+
});
465469
}
466470
}
467471
const recheckMetamask = () =>{

src/modules/services/submodule/mainnetSwap/submodule2/bsc/views/ViewServicesMainnetSwapCheckSiriusToBSC.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,16 @@ export default {
298298
}
299299
isMetamaskConnected.value = ethereum.isConnected()?true:false;
300300
}
301-
function verifyChain(chainId){
301+
async function verifyChain(chainId){
302302
currentNetwork.value = chainId;
303303
if(bscChainId === parseInt(chainId)){
304304
err.value = '';
305305
}else{
306-
err.value = t('swap.selectNetworkToSwap',{network: bscNetworkName}) ;
306+
err.value = t('swap.selectNetworkToSwap',{network: bscNetworkName});
307+
await ethereum.request({
308+
method: 'wallet_switchEthereumChain',
309+
params: [{ chainId: '0x38' }]
310+
});
307311
}
308312
}
309313
const connectMetamask = () => {

0 commit comments

Comments
 (0)