diff --git a/packages/kit-bg/src/vaults/impls/bfc/Vault.ts b/packages/kit-bg/src/vaults/impls/bfc/Vault.ts index ad510441f25..556ba2ee599 100644 --- a/packages/kit-bg/src/vaults/impls/bfc/Vault.ts +++ b/packages/kit-bg/src/vaults/impls/bfc/Vault.ts @@ -41,6 +41,7 @@ import { OneKeyBfcClient } from './sdkBfc/ClientBfc'; import transactionUtils, { EBfcTransactionType } from './sdkBfc/transactions'; import { waitPendingTransaction } from './sdkBfc/utils'; +import type { ITransferDetail } from './sdkBfc/transactions'; import type { IDBWalletType } from '../../../dbs/local/types'; import type { KeyringBase } from '../../base/KeyringBase'; import type { @@ -196,15 +197,19 @@ export default class Vault extends VaultBase { }); actions.push(action); } else { - // use dry-run result to create action - const client = await this.getClient(); - const buildTx = await tx.build({ client }); - const dryRunResult = await client.dryRunTransactionBlock({ - transactionBlock: buildTx, - }); - const transfers = transactionUtils.parseTransferDetails({ - balanceChanges: dryRunResult.balanceChanges, - }); + let transfers: ITransferDetail[]; + try { + // use dry-run result to create action + const client = await this.getClient(); + const dryRunResult = await client.dryRunTransactionBlock({ + transactionBlock: await tx.build({ client }), + }); + transfers = transactionUtils.parseTransferDetails({ + balanceChanges: dryRunResult.balanceChanges, + }); + } catch (error) { + transfers = []; + } if (transfers.length > 0) { const action = await this.buildTxTransferAssetAction({ from: transfers[0].from, diff --git a/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts b/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts index 0d895a06919..eb36051df97 100644 --- a/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts +++ b/packages/kit-bg/src/vaults/impls/bfc/sdkBfc/transactions.ts @@ -169,7 +169,7 @@ function analyzeTransactionType(tx: TransactionBlock) { return EBfcTransactionType.Unknown; } -interface ITransferDetail { +export interface ITransferDetail { from: string; to: string; amount: string; diff --git a/packages/kit-bg/src/vaults/impls/sui/Vault.ts b/packages/kit-bg/src/vaults/impls/sui/Vault.ts index 4ad64f93075..d78e1738885 100644 --- a/packages/kit-bg/src/vaults/impls/sui/Vault.ts +++ b/packages/kit-bg/src/vaults/impls/sui/Vault.ts @@ -46,6 +46,7 @@ import { OneKeySuiTransport } from './sdkSui/SuiTransport'; import transactionUtils, { ESuiTransactionType } from './sdkSui/transactions'; import { waitPendingTransaction } from './sdkSui/utils'; +import type { ITransferDetail } from './sdkSui/transactions'; import type { IDBWalletType } from '../../../dbs/local/types'; import type { KeyringBase } from '../../base/KeyringBase'; import type { @@ -201,15 +202,20 @@ export default class Vault extends VaultBase { }); actions.push(action); } else { - // use dry-run result to create action - const client = await this.getClient(); - const buildTx = await tx.build({ client }); - const dryRunResult = await client.dryRunTransactionBlock({ - transactionBlock: buildTx, - }); - const transfers = transactionUtils.parseTransferDetails({ - balanceChanges: dryRunResult.balanceChanges, - }); + let transfers: ITransferDetail[]; + try { + // use dry-run result to create action + const client = await this.getClient(); + const dryRunResult = await client.dryRunTransactionBlock({ + transactionBlock: await tx.build({ client }), + }); + transfers = transactionUtils.parseTransferDetails({ + balanceChanges: dryRunResult.balanceChanges, + }); + } catch (error) { + transfers = []; + } + if (transfers.length > 0) { const action = await this.buildTxTransferAssetAction({ from: transfers[0].from, diff --git a/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts b/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts index 7b77f7d9803..7b799b580d3 100644 --- a/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts +++ b/packages/kit-bg/src/vaults/impls/sui/sdkSui/transactions.ts @@ -153,7 +153,7 @@ function analyzeTransactionType(tx: Transaction) { return ESuiTransactionType.Unknown; } -interface ITransferDetail { +export interface ITransferDetail { from: string; to: string; amount: string;