diff --git a/src/wallet/BitgetWallet.js b/src/wallet/BitgetWallet.js index b2998e2..b31f014 100644 --- a/src/wallet/BitgetWallet.js +++ b/src/wallet/BitgetWallet.js @@ -4,6 +4,7 @@ import { apiPreRecharge } from "./../utils/request.js" import { switchEthereumChain, queryAllowance } from './utils.js' import { FirebaseUtil } from "@/utils/firebase.util"; +const USDT_EHTEREUM = '0xdac17f958d2ee523a2206206994597c13d831ec7' export class BitgetWallet{ constructor() { if (BitgetWallet.instance) { @@ -84,10 +85,19 @@ export class BitgetWallet{ let user = data.account_address if (calls.length > 1) { const contractAddress = calls[1].trans_req.to + // get calls[1].data last 32 bytes const amount = BigInt(parseInt(calls[0].trans_req.data.slice(-64), 16)) let allowance = await queryAllowance(provider, calls[0].trans_req.to, user, contractAddress) - if (allowance < amount) { + if (calls[0].trans_req.to.toLowerCase() == USDT_EHTEREUM && allowance != amount) { + if (allowance != BigInt(0)) { + // replace calls[0].trans_req.data last 32 bytes to 0 + let data = calls[0].trans_req.data.slice(0, -64) + '0'.repeat(64) + await this.sendTransaction(provider, {from: user, to: calls[0].trans_req.to, data}) + } + let hash = await this.sendTransaction(provider, {from: user, to: calls[0].trans_req.to, data: calls[0].trans_req.data}) + resutls.push(hash) + } else if (allowance < amount) { let hash = await this.sendTransaction(provider, {from: user, to: calls[0].trans_req.to, data: calls[0].trans_req.data}) resutls.push(hash) }