Skip to content

Commit

Permalink
Feat: Add richDecodedInfo type to txInfo (#136)
Browse files Browse the repository at this point in the history
* fix: Add richDecodedInfo type to txInfo

* fix: Remove interface and use union type instead
  • Loading branch information
usame-algan committed Sep 7, 2023
1 parent f87bf9a commit 8f04242
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/types/human-description.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export enum RichFragmentType {
Text = 'text',
TokenValue = 'tokenValue',
Address = 'address',
}

export type RichTokenValueFragment = {
type: RichFragmentType.TokenValue
value: string
symbol: string | null
logoUri: string | null
}

export type RichTextFragment = {
type: RichFragmentType.Text
value: string
}

export type RichAddressFragment = {
type: RichFragmentType.Address
value: string
}

export type RichDecodedInfoFragment = RichTokenValueFragment | RichTextFragment | RichAddressFragment

export type RichDecodedInfo = {
fragments: Array<RichDecodedInfoFragment>
}
6 changes: 6 additions & 0 deletions src/types/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { AddressEx, Page, TokenInfo } from './common'
import type { RichDecodedInfo } from './human-description'

export type ParamValue = string | ParamValue[]

Expand Down Expand Up @@ -120,6 +121,7 @@ export type Transfer = {
direction: TransferDirection
transferInfo: TransferInfo
humanDescription?: string
richDecodedInfo?: RichDecodedInfo
}

export type SetFallbackHandler = {
Expand Down Expand Up @@ -191,6 +193,7 @@ export type SettingsChange = {
dataDecoded: DataDecoded
settingsInfo?: SettingsInfo
humanDescription?: string
richDecodedInfo?: RichDecodedInfo
}

export type Custom = {
Expand All @@ -202,6 +205,7 @@ export type Custom = {
actionCount?: number
isCancellation: boolean
humanDescription?: string
richDecodedInfo?: RichDecodedInfo
}

export type MultiSend = {
Expand All @@ -213,6 +217,7 @@ export type MultiSend = {
actionCount: number
isCancellation: boolean
humanDescription?: string
richDecodedInfo?: RichDecodedInfo
}

export type Cancellation = Custom & {
Expand All @@ -226,6 +231,7 @@ export type Creation = {
implementation?: AddressEx
factory?: AddressEx
humanDescription?: string
richDecodedInfo?: RichDecodedInfo
}

export type TransactionInfo = Transfer | SettingsChange | Custom | MultiSend | Cancellation | Creation
Expand Down

0 comments on commit 8f04242

Please sign in to comment.