Skip to content

Commit

Permalink
Merge pull request #567 from EdgeApp/jon/edge-tx-info
Browse files Browse the repository at this point in the history
- added: EdgeTxInfo types to tag known transaction types (swap, stake, etc)
  • Loading branch information
Jon-edge authored Oct 11, 2023
2 parents 67ec41b + 08f7e06 commit 90dd451
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# edge-core-js

## Unreleased
- added: EdgeTxAction types to tag known smart contract trasaction types (swap, stake, etc)

## 1.9.0 (2023-10-10)

Expand Down
1 change: 1 addition & 0 deletions src/core/currency/wallet/currency-wallet-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ export function combineTxWithFile(

// Copy the tx properties to the output:
const out: EdgeTransaction = {
action: tx.action,
blockHeight: tx.blockHeight,
confirmations: tx.confirmations,
currencyCode,
Expand Down
4 changes: 4 additions & 0 deletions src/core/currency/wallet/currency-wallet-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
EdgeMemo,
EdgeStakingStatus,
EdgeTransaction,
EdgeTxAction,
EdgeWalletInfo,
EdgeWalletInfoFull,
JsonObject
Expand Down Expand Up @@ -40,6 +41,7 @@ export interface TxidHashes {
}

export interface MergedTransaction {
action?: EdgeTxAction
blockHeight: number
confirmations: EdgeTransaction['confirmations']
currencyCode: string
Expand Down Expand Up @@ -416,12 +418,14 @@ export function mergeTx(
oldTx: MergedTransaction = defaultTx
): MergedTransaction {
const {
action,
currencyCode = defaultCurrency,
isSend = lt(tx.nativeAmount, '0'),
memos
} = tx

const out = {
action,
blockHeight: tx.blockHeight,
confirmations: tx.confirmations ?? 'unconfirmed',
currencyCode,
Expand Down
34 changes: 34 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,39 @@ export interface EdgeMemo {
memoName?: string
}

export interface EdgeAssetAmount {
pluginId: string
tokenId?: string
nativeAmount?: string
}

export type EdgeTxActionSwapType =
| 'swap'
| 'swapOrderPost'
| 'swapOrderFill'
| 'swapOrderCancel'

export interface EdgeTxActionSwap {
type: EdgeTxActionSwapType
orderId?: string
canBePartial?: boolean
sourceAsset: EdgeAssetAmount
destAsset: EdgeAssetAmount
}

export type EdgeTxActionStakeType =
| 'stake'
| 'stakeOrder'
| 'unstake'
| 'unstakeOrder'

export interface EdgeTxActionStake {
type: EdgeTxActionStakeType
stakeAssets: EdgeAssetAmount[]
}

export type EdgeTxAction = EdgeTxActionSwap | EdgeTxActionStake

// token info ----------------------------------------------------------

export interface EdgeDenomination {
Expand Down Expand Up @@ -468,6 +501,7 @@ export interface EdgeTransaction {
signedTx: string
memos: EdgeMemo[]
ourReceiveAddresses: string[]
action?: EdgeTxAction

// Spend-specific metadata:
deviceDescription?: string
Expand Down

0 comments on commit 90dd451

Please sign in to comment.