Skip to content

Commit

Permalink
feat: add timelock stake and unstake and use transaciton instead of send
Browse files Browse the repository at this point in the history
  • Loading branch information
evavirseda committed Dec 27, 2024
1 parent aa6ff76 commit d97e7ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions apps/core/src/interfaces/transactions.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export enum TransactionAction {
Transaction = 'Transaction',
Staked = 'Staked',
Unstaked = 'Unstaked',
TimelockedStaked = 'TimelockedStaked',
TimelockedUnstaked = 'TimelockedUnstaked',
Rewards = 'Rewards',
PersonalMessage = 'PersonalMessage',
}
Expand Down
13 changes: 10 additions & 3 deletions apps/core/src/utils/transaction/getTransactionAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ export const getTransactionAction = (
const unstakeTypeTransaction = transaction?.events?.find(
({ type }) => type === UNSTAKING_REQUEST_EVENT,
);

const isTimelockedStaking = stakeTypeTransaction?.transactionModule === 'timelocked_staking';
const isTimelockedUnstaking =
unstakeTypeTransaction?.transactionModule === 'timelocked_staking';

if (stakeTypeTransaction) {
return TransactionAction.Staked;
return isTimelockedStaking ? TransactionAction.TimelockedStaked : TransactionAction.Staked;
} else if (unstakeTypeTransaction) {
return TransactionAction.Unstaked;
return isTimelockedUnstaking
? TransactionAction.TimelockedUnstaked
: TransactionAction.Unstaked;
} else {
const isSender = transaction.transaction?.data.sender === currentAddress;
return isSender ? TransactionAction.Send : TransactionAction.Receive;
return isSender ? TransactionAction.Transaction : TransactionAction.Receive;
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const icons = {
Failed: <Info className={ICON_COLORS.error} />,
Loading: <LoadingIndicator />,
PersonalMessage: <Person className={ICON_COLORS.primary} />,
TimelockedStaked: <Stake className={ICON_COLORS.primary} />,
TimelockedUnstaked: <Stake className={ICON_COLORS.primary} />,
};

interface TransactionIconProps {
Expand Down

0 comments on commit d97e7ca

Please sign in to comment.