增加waitForTransaction结果的判断
This commit is contained in:
parent
0672798d64
commit
65bc26ed3f
@ -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