Skip to content

Commit

Permalink
fix(core): rename function name and return a boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
cpl121 committed Jan 16, 2025
1 parent ba6f55b commit 5b9f99a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
6 changes: 3 additions & 3 deletions apps/core/src/utils/transaction/getTransactionAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { IotaTransactionBlockResponse } from '@iota/iota-sdk/client';
import { TransactionAction } from '../../interfaces';
import { checkIfIsTimelockedStaking } from '../stake';
import { isMigrationTransaction, isSupplyIncreaseVestingCollectTransaction } from '..';
import { isMigrationTransaction, isUnlockTimelockedObjectTransaction } from '..';

export const getTransactionAction = (
transaction: IotaTransactionBlockResponse,
Expand All @@ -19,8 +19,8 @@ export const getTransactionAction = (
unstakeTypeTransaction,
} = checkIfIsTimelockedStaking(transaction?.events);

const { isMigration } = isMigrationTransaction(transaction.transaction);
const { isSupplyIncreaseVestingCollect } = isSupplyIncreaseVestingCollectTransaction(
const isMigration = isMigrationTransaction(transaction.transaction);
const isSupplyIncreaseVestingCollect = isUnlockTimelockedObjectTransaction(
transaction.transaction,
);

Expand Down
2 changes: 1 addition & 1 deletion apps/core/src/utils/transaction/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export * from './getObjectDisplayLookup';
export * from './createNftSendValidationSchema';
export * from './createUnlockTimelockedObjectsTransaction';
export * from './isMigrationTransaction';
export * from './isSupplyIncreaseVestingCollectTransaction';
export * from './isUnlockTimelockedObjectTransaction';
11 changes: 5 additions & 6 deletions apps/core/src/utils/transaction/isMigrationTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ import type {
} from '@iota/iota-sdk/client';
import { STARDUST_PACKAGE_ID } from '../../constants';

export function isMigrationTransaction(transaction: IotaTransactionBlockResponse['transaction']) {
export function isMigrationTransaction(
transaction: IotaTransactionBlockResponse['transaction'],
): boolean {
if (!transaction || transaction.data.transaction.kind !== 'ProgrammableTransaction')
return { isMigration: false };
return false;
const moveCallTxs = transaction.data.transaction.transactions.filter(isMoveCall);
const isMigration = moveCallTxs.some(
(tx) =>
tx.MoveCall.package === STARDUST_PACKAGE_ID &&
tx.MoveCall.function === 'extract_assets',
);

return {
isMigration,
};
return isMigration;
}

function isMoveCall(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ import type {
} from '@iota/iota-sdk/client';
import { TIMELOCK_MODULE } from '../..';

export function isSupplyIncreaseVestingCollectTransaction(
export function isUnlockTimelockedObjectTransaction(
transaction: IotaTransactionBlockResponse['transaction'],
) {
): boolean {
if (!transaction || transaction.data.transaction.kind !== 'ProgrammableTransaction')
return { isSupplyIncreaseVestingCollect: false };
return false;
const moveCallTxs = transaction.data.transaction.transactions
.filter(isMoveCall)
.filter((tx) => tx.MoveCall.module === TIMELOCK_MODULE);
const isSupplyIncreaseVestingCollect =
const isUnlockTimelockedObject =
moveCallTxs.length > 0 && moveCallTxs.every((tx) => tx.MoveCall.function === 'unlock');

return {
isSupplyIncreaseVestingCollect,
};
return isUnlockTimelockedObject;
}

function isMoveCall(
Expand Down

0 comments on commit 5b9f99a

Please sign in to comment.