From 32d75b4a7cdc0fe90fa02fc1cdc49bda487e680f Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:13:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9ethereum=20usdt=E7=9A=84?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=85=88=E6=94=B9?= =?UTF-8?q?=E4=B8=BA0=EF=BC=8C=20=E5=86=8D=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wallet/BitgetWallet.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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) }