bug fix: 上链请求错误
This commit is contained in:
parent
3aa761d3ef
commit
6389c426a7
@ -34,6 +34,7 @@ const mutations = {
|
||||
updateAddress(state, _address) {
|
||||
console.log('update address: ', _address);
|
||||
state.address = _address;
|
||||
state.connected = true;
|
||||
},
|
||||
updateChain(state, _chainId) {
|
||||
console.log('update chain: ', _chainId);
|
||||
|
@ -78,6 +78,11 @@ export class Wallet {
|
||||
} else if (this.walletName == 'connect') {
|
||||
this.provider = await connectWc();
|
||||
}
|
||||
let res = await this.provider.request({ method: 'eth_chainId' });
|
||||
if (res) {
|
||||
this.chainId = parseInt(res);
|
||||
store.commit('wallet/updateChain', this.chainId)
|
||||
}
|
||||
this.subscribeToEvents();
|
||||
}
|
||||
|
||||
@ -131,6 +136,10 @@ export class Wallet {
|
||||
|
||||
async changeChain(){
|
||||
const chainId = chainData.id
|
||||
debugger
|
||||
if (store.state.wallet.chainId === chainId) {
|
||||
return
|
||||
}
|
||||
const hexChainId = toHexChainId(chainId)
|
||||
return new Promise((resolve, reject) => {
|
||||
const onChainChange = (chainId) => {
|
||||
@ -251,7 +260,7 @@ export class Wallet {
|
||||
|
||||
async sendScription(address, dataStr){
|
||||
const data = Web3.utils.utf8ToHex(dataStr)
|
||||
const provider = new Web3(window.ethereum);
|
||||
const provider = new Web3(this.provider);
|
||||
let gasPrice = await provider.eth.getGasPrice()
|
||||
gasPrice = gasPrice * 2n
|
||||
// const gasPrice = 100000000n;
|
||||
@ -259,7 +268,7 @@ export class Wallet {
|
||||
// return
|
||||
let sendObj = {
|
||||
from: address,
|
||||
to: targetAddress,
|
||||
to: process.env.VUE_APP_SCRIPTION_ADDRESS,
|
||||
value: '0x0',
|
||||
data
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user