Merge branch 'new-CounterFire' of http://git.kingsome.cn/huangjinming/CounterFireGames into new-CounterFire
This commit is contained in:
commit
b1d6322a07
@ -209,6 +209,8 @@ export class BlockChain {
|
|||||||
async logout() {
|
async logout() {
|
||||||
if (this.store.walletType != 3 && this.passportProvider) {
|
if (this.store.walletType != 3 && this.passportProvider) {
|
||||||
new PassportWallet().logout();
|
new PassportWallet().logout();
|
||||||
|
} else if (this.store.walletType == 3 && this.eoaWallet) {
|
||||||
|
await this.eoaWallet.logout();
|
||||||
}
|
}
|
||||||
this.store.reset();
|
this.store.reset();
|
||||||
this.store.$persist();
|
this.store.$persist();
|
||||||
@ -239,16 +241,20 @@ export class BlockChain {
|
|||||||
console.log(`current chain: ${chainId}, want: ${targetChainId}`)
|
console.log(`current chain: ${chainId}, want: ${targetChainId}`)
|
||||||
chainId = await switchEthereumChain(provider.provider, targetChainId);
|
chainId = await switchEthereumChain(provider.provider, targetChainId);
|
||||||
}
|
}
|
||||||
|
let eoaAddress;
|
||||||
if (this.store.walletType == 3) {
|
if (this.store.walletType == 3) {
|
||||||
const { provider, accounts } = await this.eoaWallet.web3Provider();
|
const { provider, accounts } = await this.eoaWallet.web3Provider();
|
||||||
this.eoaProvider = provider;
|
this.eoaProvider = provider;
|
||||||
|
eoaAddress = accounts[0];
|
||||||
} else {
|
} else {
|
||||||
const { provider, accounts } = await this.wallet.web3Provider();
|
const { provider, accounts } = await this.wallet.web3Provider();
|
||||||
this.web3Provider = provider;
|
this.web3Provider = provider;
|
||||||
this.eoaProvider = provider;
|
this.eoaProvider = provider;
|
||||||
|
eoaAddress = accounts[0];
|
||||||
|
}
|
||||||
|
if (this.store.eoaAddress !== eoaAddress) {
|
||||||
|
throw new Error('eoa address changed')
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkPassportLogin() {
|
async checkPassportLogin() {
|
||||||
|
@ -29,14 +29,20 @@ export class Locker {
|
|||||||
const addressApproval = await nftContract.getApproved(tokenId)
|
const addressApproval = await nftContract.getApproved(tokenId)
|
||||||
if ((addressApproval || "").toLowerCase() != lockAddress.toLowerCase()) {
|
if ((addressApproval || "").toLowerCase() != lockAddress.toLowerCase()) {
|
||||||
const resApproval = await nftContract.approve(lockAddress, tokenId);
|
const resApproval = await nftContract.approve(lockAddress, tokenId);
|
||||||
await provider.waitForTransaction(resApproval.hash)
|
const res = await provider.waitForTransaction(resApproval.hash)
|
||||||
|
if (res.status == 0) {
|
||||||
|
throw new Error('approval failed')
|
||||||
|
}
|
||||||
console.debug('approve', resApproval.hash)
|
console.debug('approve', resApproval.hash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const contract = new ethers.Contract(lockAddress, lockAbi, provider.getSigner())
|
const contract = new ethers.Contract(lockAddress, lockAbi, provider.getSigner())
|
||||||
const res = await contract.lock(nft, address, tokenIds)
|
const res = await contract.lock(nft, address, tokenIds)
|
||||||
await provider.waitForTransaction(res.hash)
|
const resConfirm = await provider.waitForTransaction(res.hash)
|
||||||
|
if (resConfirm.status == 0) {
|
||||||
|
throw new Error('lock failed')
|
||||||
|
}
|
||||||
return res.hash
|
return res.hash
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +72,10 @@ export class Locker {
|
|||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
console.log(txHash)
|
console.log(txHash)
|
||||||
await provider.waitForTransaction(txHash)
|
const res = await provider.waitForTransaction(txHash)
|
||||||
|
if (res.status == 0) {
|
||||||
|
throw new Error('transaction failed')
|
||||||
|
}
|
||||||
return txHash
|
return txHash
|
||||||
}
|
}
|
||||||
async execUnlock(provider, chainId, nft, tokenIds) {
|
async execUnlock(provider, chainId, nft, tokenIds) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user