Skip to content

Commit

Permalink
feat!: new types for status endpoint (#166)
Browse files Browse the repository at this point in the history
* feat: new types for status endpoint

* chore: small changes

* chore: more types changes

* chore: make some field optional

* chore: dist

* Merge branch 'main' into LF-2926

* chore: removed dist

---------

Co-authored-by: Leonardo Cascianelli <leo@li.finance>
  • Loading branch information
melianessa and H3xept committed Jun 6, 2023
1 parent c1cc7f1 commit b7262e2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ dist
.yarn/install-state.gz
.pnp.*

.DS_Store
.DS_Store
50 changes: 35 additions & 15 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,26 @@ export interface GetStatusRequest {
toChain?: number | string
}

export interface TransactionInfo {
export interface BaseTransactionInfo {
txHash: string
txLink?: string
chainId: ChainId
txLink: string
}

export interface ExtendedTransactionInfo extends BaseTransactionInfo {
amount?: string
amountUSD?: string
token?: Token
chainId?: ChainId
gasPrice?: string
gasUsed?: string
gasToken?: Token
gasAmount?: string
gasAmountUSD?: string
gasPrice: string
gasUsed: string
gasToken: Token
gasAmount: string
gasAmountUSD: string
timestamp?: number
}

export interface PendingReceivingInfo {
chainId: ChainId
}

const _StatusMessage = [
Expand Down Expand Up @@ -330,16 +339,27 @@ export const isSubstatusFailed = (
): substatus is SubstatusFailed =>
_SubstatusFailed.includes(substatus as SubstatusFailed)

export interface StatusInformation {
export interface BaseStatusData {
status: StatusMessage
substatus?: Substatus
substatusMessage?: string
}

export interface StatusResponse extends StatusInformation {
sending: TransactionInfo
receiving?: TransactionInfo
tool?: string
export interface StatusData extends BaseStatusData {
tool: string
sending: BaseTransactionInfo
receiving: PendingReceivingInfo
}

export type StatusResponse = FullStatusData | StatusData

export interface FullStatusData extends StatusData {
transactionId: string
sending: ExtendedTransactionInfo
receiving: PendingReceivingInfo | ExtendedTransactionInfo
lifiExplorerLink: string
fromAddress: string
toAddress: string
bridgeExplorerLink?: string
}

Expand Down Expand Up @@ -398,8 +418,8 @@ type LIFuelState = (typeof _LIFuelState)[number]
// Response to the status API for trusted gas
export type LIFuelStatusResponse = {
status: LIFuelState
sending?: TransactionInfo
receiving?: TransactionInfo
sending?: ExtendedTransactionInfo
receiving?: PendingReceivingInfo | ExtendedTransactionInfo
}

export type GasRecommendationRequest = {
Expand Down

0 comments on commit b7262e2

Please sign in to comment.