Skip to content

Commit

Permalink
Add transfer and tokenApproval types
Browse files Browse the repository at this point in the history
  • Loading branch information
paullinator committed Dec 6, 2023
1 parent 59a0dd3 commit b100141
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/core/currency/wallet/currency-wallet-cleaners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
EdgeTxActionFiat,
EdgeTxActionStake,
EdgeTxActionSwap,
EdgeTxActionTokenApproval,
EdgeTxSwap
} from '../../../types/types'
import { asJsonObject } from '../../../util/file-helpers'
Expand Down Expand Up @@ -268,10 +269,18 @@ export const asEdgeTxActionFiat = asObject<EdgeTxActionFiat>({
cryptoAsset: asEdgeAssetAmount
})

export const asEdgeTxActionTokenApproval = asObject<EdgeTxActionTokenApproval>({
actionType: asValue('tokenApproval'),
tokenApproved: asEdgeAssetAmount,
tokenContractAddress: asString,
contractAddress: asString
})

export const asEdgeTxAction: Cleaner<EdgeTxAction> = asEither(
asEdgeTxActionSwap,
asEdgeTxActionStake,
asEdgeTxActionFiat
asEdgeTxActionFiat,
asEdgeTxActionTokenApproval
)

export const asEdgeAssetActionType: Cleaner<EdgeAssetActionType> = asValue(
Expand All @@ -289,7 +298,9 @@ export const asEdgeAssetActionType: Cleaner<EdgeAssetActionType> = asValue(
'swapOrderCancel',
'buy',
'sell',
'sellNetworkFee'
'sellNetworkFee',
'tokenApproval',
'transfer'
)

export const asEdgeAssetAction = asObject({
Expand Down
10 changes: 10 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,18 @@ export interface EdgeTxActionFiat {
cryptoAsset: EdgeAssetAmount
}

export interface EdgeTxActionTokenApproval {
actionType: 'tokenApproval'
tokenApproved: EdgeAssetAmount
tokenContractAddress: string
contractAddress: string
}

export type EdgeTxAction =
| EdgeTxActionSwap
| EdgeTxActionStake
| EdgeTxActionFiat
| EdgeTxActionTokenApproval

export type EdgeAssetActionType =
| 'stake'
Expand All @@ -325,6 +333,8 @@ export type EdgeAssetActionType =
| 'buy'
| 'sell'
| 'sellNetworkFee'
| 'tokenApproval'
| 'transfer'

export interface EdgeAssetAction {
assetActionType: EdgeAssetActionType
Expand Down

0 comments on commit b100141

Please sign in to comment.