Skip to content

Commit

Permalink
chore: fix sui�enfen decode error (#6337)
Browse files Browse the repository at this point in the history
Co-authored-by: morizon <[email protected]>
  • Loading branch information
ByteZhang1024 and sidmorizon authored Dec 19, 2024
1 parent b535180 commit 9976b56
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
23 changes: 14 additions & 9 deletions packages/kit-bg/src/vaults/impls/bfc/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function analyzeTransactionType(tx: TransactionBlock) {
return EBfcTransactionType.Unknown;
}

interface ITransferDetail {
export interface ITransferDetail {
from: string;
to: string;
amount: string;
Expand Down
24 changes: 15 additions & 9 deletions packages/kit-bg/src/vaults/impls/sui/Vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ function analyzeTransactionType(tx: Transaction) {
return ESuiTransactionType.Unknown;
}

interface ITransferDetail {
export interface ITransferDetail {
from: string;
to: string;
amount: string;
Expand Down

0 comments on commit 9976b56

Please sign in to comment.