diff --git a/packages/swapper/src/swappers/SunioSwapper/endpoints.ts b/packages/swapper/src/swappers/SunioSwapper/endpoints.ts index d88d8241aa4..08ad7f44be4 100644 --- a/packages/swapper/src/swappers/SunioSwapper/endpoints.ts +++ b/packages/swapper/src/swappers/SunioSwapper/endpoints.ts @@ -168,28 +168,17 @@ export const sunioApi: SwapperApi = { checkTradeStatus: async ({ txHash, assertGetTronChainAdapter }) => { try { const adapter = assertGetTronChainAdapter(tronChainId) - const rpcUrl = adapter.httpProvider.getRpcUrl() + const tx = await adapter.httpProvider.getTransaction({ txid: txHash }) - const response = await fetch(`${rpcUrl}/wallet/gettransactionbyid`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ value: txHash, visible: true }), - }) - - if (!response.ok) { - return createDefaultStatusResponse(txHash) - } - - const tx = await response.json() - - if (!tx || !tx.txID) { + if (!tx) { return createDefaultStatusResponse(txHash) } const contractRet = tx.ret?.[0]?.contractRet + // Only mark as confirmed if SUCCESS AND has confirmations (in a block) const status = - contractRet === 'SUCCESS' + contractRet === 'SUCCESS' && tx.confirmations > 0 ? TxStatus.Confirmed : contractRet === 'REVERT' ? TxStatus.Failed diff --git a/packages/unchained-client/src/tron/api.ts b/packages/unchained-client/src/tron/api.ts index 8f51b561b78..6c632a8aeb4 100644 --- a/packages/unchained-client/src/tron/api.ts +++ b/packages/unchained-client/src/tron/api.ts @@ -115,31 +115,49 @@ export class TronApi { async getTransaction(params: { txid: string }): Promise { await this.throttle() - const response = await fetch(`${this.rpcUrl}/wallet/gettransactionbyid`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ value: params.txid, visible: true }), - }) - - if (!response.ok) { + const [txResponse, infoResponse] = await Promise.all([ + fetch(`${this.rpcUrl}/wallet/gettransactionbyid`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ value: params.txid, visible: true }), + }), + fetch(`${this.rpcUrl}/wallet/gettransactioninfobyid`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ value: params.txid, visible: true }), + }), + ]) + + if (!txResponse.ok) { return null } - const tx = await response.json() + const tx = await txResponse.json() if (!tx || !tx.txID) { return null } + let blockNumber = 0 + let blockTimeStamp = 0 + let fee = '0' + + if (infoResponse.ok) { + const info = await infoResponse.json() + blockNumber = info.blockNumber || 0 + blockTimeStamp = info.blockTimeStamp || 0 + fee = info.fee ? String(info.fee) : '0' + } + return { ...tx, txid: tx.txID, blockHash: '', - blockHeight: 0, - timestamp: 0, - confirmations: 0, + blockHeight: blockNumber, + timestamp: blockTimeStamp, + confirmations: blockNumber > 0 ? 1 : 0, value: '0', - fee: '0', + fee, } } diff --git a/packages/unchained-client/src/tron/types.ts b/packages/unchained-client/src/tron/types.ts index 27cfe7e8ebc..36a63242dc0 100644 --- a/packages/unchained-client/src/tron/types.ts +++ b/packages/unchained-client/src/tron/types.ts @@ -26,6 +26,10 @@ export interface TronTx { raw_data_hex: string txID: string signature?: string[] + ret?: { + contractRet?: 'SUCCESS' | 'REVERT' | string + fee?: number + }[] } type TRC20Token = { diff --git a/src/pages/SplashScreen/SplashScreen.tsx b/src/pages/SplashScreen/SplashScreen.tsx index 2d1557fffee..1b0473cf862 100644 --- a/src/pages/SplashScreen/SplashScreen.tsx +++ b/src/pages/SplashScreen/SplashScreen.tsx @@ -1,7 +1,7 @@ import { Center, Circle, Spinner } from '@chakra-ui/react' import { isFirefox } from 'react-device-detect' -import Orbs from '@/assets/orbs.svg?url' +import Orbs from '@/assets/orbs.svg' import OrbsStatic from '@/assets/orbs-static.png' import { FoxIcon } from '@/components/Icons/FoxIcon' import { Page } from '@/components/Layout/Page'