Skip to content

Commit

Permalink
feat: add staking exit decoding (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
compojoom authored Sep 12, 2024
1 parent 5b66273 commit b7ec7fc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
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

0 comments on commit b7ec7fc

Please sign in to comment.