Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add staking exit decoding #198

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/types/decoded-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export enum ConfirmationViewTypes {
COW_SWAP_ORDER = 'COW_SWAP_ORDER',
COW_SWAP_TWAP_ORDER = 'COW_SWAP_TWAP_ORDER',
KILN_NATIVE_STAKING_DEPOSIT = 'KILN_NATIVE_STAKING_DEPOSIT',
KILN_NATIVE_STAKING_VALIDATORS_EXIT = 'KILN_NATIVE_STAKING_VALIDATORS_EXIT',
}

export type DecodedDataRequest = {
Expand Down Expand Up @@ -69,6 +70,13 @@ export enum NativeStakingStatus {
UNKNOWN = 'UNKNOWN',
}

export enum NativeStakingExitStatus {
AWAITING_EXECUTION = 'AWAITING_EXECUTION',
READY_TO_WITHDRAW = 'READY_TO_WITHDRAW',
REQUEST_PENDING = 'REQUEST_PENDING',
SIGNATURE_NEEDED = 'SIGNATURE_NEEDED',
}

/* Staking */
export type NativeStakingDepositConfirmationView = {
type: ConfirmationViewTypes.KILN_NATIVE_STAKING_DEPOSIT
Expand All @@ -88,9 +96,24 @@ export type NativeStakingDepositConfirmationView = {
numValidators: number
} & DecodedDataResponse

export type NativeStakingValidatorsExitConfirmationView = {
type: ConfirmationViewTypes.KILN_NATIVE_STAKING_VALIDATORS_EXIT
status: NativeStakingExitStatus
estimatedExitTime: number
estimatedWithdrawalTime: number
value: string
numValidators: number
tokenInfo: TokenInfo
} & DecodedDataResponse

export type AnyStakingConfirmationView =
| NativeStakingDepositConfirmationView
| NativeStakingValidatorsExitConfirmationView

/* Union */
export type AnyConfirmationView =
| BaselineConfirmationView
| SwapOrderConfirmationView
| TwapOrderConfirmationView
| NativeStakingDepositConfirmationView
| NativeStakingValidatorsExitConfirmationView
12 changes: 10 additions & 2 deletions src/types/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AddressEx, Page, TokenInfo } from './common'
import type { NativeStakingDepositConfirmationView } from './decoded-data'
import type { NativeStakingDepositConfirmationView, NativeStakingValidatorsExitConfirmationView } from './decoded-data'
import type { RichDecodedInfo } from './human-description'

export type ParamValue = string | ParamValue[]
Expand Down Expand Up @@ -73,6 +73,7 @@ export enum TransactionInfoType {
TWAP_ORDER = 'TwapOrder',
SWAP_TRANSFER = 'SwapTransfer',
NATIVE_STAKING_DEPOSIT = 'NativeStakingDeposit',
NATIVE_STAKING_VALIDATORS_EXIT = 'NativeStakingValidatorsExit',
}

export enum ConflictType {
Expand Down Expand Up @@ -340,11 +341,18 @@ export type TwapOrder = Omit<BaseOrder, 'executedBuyAmount' | 'executedSellAmoun
// Discriminated union type
export type Order = SwapOrder | SwapTransferOrder | TwapOrder

export type StakingTxInfo = {
export type StakingTxDepositInfo = {
type: TransactionInfoType.NATIVE_STAKING_DEPOSIT
humanDescription?: string
} & Omit<NativeStakingDepositConfirmationView, 'type'>

export type StakingTxExitInfo = {
type: TransactionInfoType.NATIVE_STAKING_VALIDATORS_EXIT
humanDescription?: string
} & Omit<NativeStakingValidatorsExitConfirmationView, 'type'>

export type StakingTxInfo = StakingTxDepositInfo | StakingTxExitInfo

export type TransactionInfo =
| Transfer
| SettingsChange
Expand Down
Loading