@exodus/activity-txs 4.1.1 → 4.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.1.2](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/activity-txs@4.1.1...@exodus/activity-txs@4.1.2) (2024-05-15)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- address security feedback ([#6963](https://github.com/ExodusMovement/exodus-hydra/issues/6963)) ([155bdfe](https://github.com/ExodusMovement/exodus-hydra/commit/155bdfed531685108d828be60c9d1a8be9e785ee))
|
|
11
|
+
- indexless order should be ignored in first loop ([#6965](https://github.com/ExodusMovement/exodus-hydra/issues/6965)) ([83766cd](https://github.com/ExodusMovement/exodus-hydra/commit/83766cd69533d81317ea52ab770541a7ccfde274))
|
|
12
|
+
|
|
6
13
|
## [4.1.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/activity-txs@4.1.0...@exodus/activity-txs@4.1.1) (2024-05-15)
|
|
7
14
|
|
|
8
15
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/activity-txs",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.2",
|
|
4
4
|
"description": "The activity-txs feature",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"repository": {
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"@types/minimalistic-assert": "^1.0.1",
|
|
61
61
|
"redux": "^4.2.1"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "a0c1b2cb7cdd31f455f566879612777c8d46b654"
|
|
64
64
|
}
|
|
@@ -12,24 +12,36 @@ const generateActivityId = ({ activityItem }) => {
|
|
|
12
12
|
: `${activityItem.assetName}.${activityItem.txId}`
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
const groupTxsWithSameOrder = ({ txs, orderSet }) => {
|
|
15
|
+
const groupTxsWithSameOrder = ({ txs, orderSet, isIndexless }) => {
|
|
16
16
|
const getOrder = (tx) => orderSet.getByTxId(tx.txId)
|
|
17
|
-
const exchangeByOrderId =
|
|
17
|
+
const exchangeByOrderId = new Map()
|
|
18
18
|
const result = []
|
|
19
|
+
|
|
19
20
|
for (const tx of txs) {
|
|
20
21
|
const order = getOrder(tx)
|
|
22
|
+
if (isIndexless && order) {
|
|
23
|
+
// Orders are the source of truth for indexless swaps.
|
|
24
|
+
// Skip this tx and add it later as exchanged.
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
|
|
21
28
|
if (order) {
|
|
22
|
-
|
|
29
|
+
if (!exchangeByOrderId.has(order.orderId)) {
|
|
30
|
+
exchangeByOrderId.set(order.orderId, [])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
exchangeByOrderId.get(order.orderId).push(tx)
|
|
23
34
|
} else {
|
|
24
35
|
result.push({ tx, type: 'tx' })
|
|
25
36
|
}
|
|
26
37
|
}
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
exchangeByOrderId.forEach((txsGroup) => {
|
|
29
40
|
const tx = txsGroup.sort((a, b) => b.date.getTime() - a.date.getTime())[0]
|
|
30
41
|
const order = getOrder(tx)
|
|
31
42
|
result.push({ tx, type: 'exchange', order })
|
|
32
43
|
})
|
|
44
|
+
|
|
33
45
|
return result
|
|
34
46
|
}
|
|
35
47
|
|
|
@@ -50,13 +62,13 @@ const createAssetSourceBaseActivitySelectorDefinition = {
|
|
|
50
62
|
getPersonalNoteByTxIdSelector,
|
|
51
63
|
(assets, txs = EMPTY, orderSet, getPersonalNoteByTxId) => {
|
|
52
64
|
const activityResult = []
|
|
53
|
-
|
|
54
|
-
const groupedTxs = groupTxsWithSameOrder({ txs, orderSet })
|
|
65
|
+
const isIndexless = assets[assetName]?.baseAsset?.api?.features?.noHistory
|
|
66
|
+
const groupedTxs = groupTxsWithSameOrder({ txs, orderSet, isIndexless })
|
|
55
67
|
|
|
56
68
|
for (const group of groupedTxs) {
|
|
57
69
|
const { tx, order, type: formatterType } = group
|
|
58
70
|
const personalNote = getPersonalNoteByTxId(tx.txId)
|
|
59
|
-
const formattedTx = formattersByType
|
|
71
|
+
const formattedTx = formattersByType.get(formatterType)({
|
|
60
72
|
assets,
|
|
61
73
|
order,
|
|
62
74
|
tx,
|
|
@@ -67,7 +79,6 @@ const createAssetSourceBaseActivitySelectorDefinition = {
|
|
|
67
79
|
activityResult.push(formattedTx)
|
|
68
80
|
}
|
|
69
81
|
|
|
70
|
-
const isIndexless = assets[assetName]?.baseAsset?.api?.features?.noHistory
|
|
71
82
|
if (isIndexless) {
|
|
72
83
|
const orderIdsFromActivity = new Set(activityResult.map((tx) => tx.orderId))
|
|
73
84
|
const ordersForIndexlessAssets = [...orderSet].filter(
|
|
@@ -91,7 +102,7 @@ const createAssetSourceBaseActivitySelectorDefinition = {
|
|
|
91
102
|
data: { swapTx: true },
|
|
92
103
|
selfSend: false,
|
|
93
104
|
token: null, // TBD
|
|
94
|
-
bumpType:
|
|
105
|
+
bumpType: Object.create(null),
|
|
95
106
|
coinName: isFromIndexlessAsset ? order.fromAsset : order.toAsset,
|
|
96
107
|
value: isFromIndexlessAsset ? order.fromAmount : order.toAmount,
|
|
97
108
|
coinAmount: isFromIndexlessAsset ? order.fromAmount : order.toAmount,
|
|
@@ -6,11 +6,14 @@ const selectorFactory =
|
|
|
6
6
|
createWithConnectionsActivity
|
|
7
7
|
) =>
|
|
8
8
|
// call this once on client-side
|
|
9
|
-
(options =
|
|
9
|
+
(options = Object.create(null)) => {
|
|
10
10
|
let createFullSelector = createAssetSourceBaseActivity
|
|
11
11
|
createFullSelector = createWithNftsActivity({
|
|
12
12
|
createActivitySelector: createFullSelector,
|
|
13
|
-
nftsNetworkNameToAssetName:
|
|
13
|
+
nftsNetworkNameToAssetName:
|
|
14
|
+
(Object.hasOwn(options, 'nftsNetworkNameToAssetName') &&
|
|
15
|
+
options.nftsNetworkNameToAssetName) ||
|
|
16
|
+
Object.create(null),
|
|
14
17
|
})
|
|
15
18
|
createFullSelector = createWithFiatActivity({ createActivitySelector: createFullSelector })
|
|
16
19
|
createFullSelector = createWithConnectionsActivity({
|
|
@@ -13,17 +13,17 @@ const EXODEX_TX_TYPES = {
|
|
|
13
13
|
CLEANUP: 'cleanupTransaction',
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
const UI_TX_TYPE_FROM_EXODEX =
|
|
17
|
-
[EXODEX_TX_TYPES.PRE_SETUP
|
|
18
|
-
[EXODEX_TX_TYPES.SETUP
|
|
19
|
-
[EXODEX_TX_TYPES.SWAP
|
|
20
|
-
[EXODEX_TX_TYPES.CLEANUP
|
|
21
|
-
|
|
16
|
+
const UI_TX_TYPE_FROM_EXODEX = new Map([
|
|
17
|
+
[EXODEX_TX_TYPES.PRE_SETUP, TX_TYPES.APPROVAL],
|
|
18
|
+
[EXODEX_TX_TYPES.SETUP, TX_TYPES.APPROVAL],
|
|
19
|
+
[EXODEX_TX_TYPES.SWAP, TX_TYPES.EXCHANGE],
|
|
20
|
+
[EXODEX_TX_TYPES.CLEANUP, TX_TYPES.CLEANUP],
|
|
21
|
+
])
|
|
22
22
|
|
|
23
23
|
function getTxType({ tx, order }) {
|
|
24
24
|
if (order) {
|
|
25
25
|
const txInfoFromOrder = order.txIds?.find((txFromOrder) => txFromOrder.txId === tx.txId)
|
|
26
|
-
return UI_TX_TYPE_FROM_EXODEX
|
|
26
|
+
return UI_TX_TYPE_FROM_EXODEX.get(txInfoFromOrder?.txType) || TX_TYPES.EXCHANGE
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
return tx.sent ? TX_TYPES.SENT : TX_TYPES.RECEIVED
|
|
@@ -82,10 +82,10 @@ const formatGroupedTx = ({ tx, assets, personalNote }) =>
|
|
|
82
82
|
personalNote,
|
|
83
83
|
})
|
|
84
84
|
|
|
85
|
-
export const formattersByType =
|
|
86
|
-
exchange
|
|
87
|
-
tx
|
|
88
|
-
|
|
85
|
+
export const formattersByType = new Map([
|
|
86
|
+
['exchange', formatGroupedExchangeTxs],
|
|
87
|
+
['tx', formatGroupedTx],
|
|
88
|
+
])
|
|
89
89
|
|
|
90
90
|
export const formatUnindexedNftTx = ({ asset, nftTx }) => {
|
|
91
91
|
return {
|