Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 23ffd91

Browse files
authored
chore: release - Merge pull request #542 from cowprotocol/release/2.24.0
Release/2.24.0
2 parents 2cd7034 + 318911f commit 23ffd91

18 files changed

Lines changed: 1250 additions & 413 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cowprotocol/explorer",
3-
"version": "2.23.0",
3+
"version": "2.24.0",
44
"description": "",
55
"main": "src/index.js",
66
"sideEffects": false,

src/api/tenderly/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './tenderlyApi'
22

33
export type { PublicTrade as Trade, Transfer, Account } from './types'
4+
export * from './types'

src/api/tenderly/tenderlyApi.ts

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { TENDERLY_API_URL, ETH_NULL_ADDRESS, APP_NAME } from 'const'
1+
import { APP_NAME, NATIVE_TOKEN_ADDRESS_LOWERCASE, TENDERLY_API_URL } from 'const'
22
import { Network } from 'types'
33
import { fetchQuery } from 'api/baseApi'
44
import {
55
Account,
66
Contract,
7-
Trace,
8-
PublicTrade as Trade,
9-
Transfer,
10-
TypeOfTrace,
117
IndexTradeInput,
128
IndexTransferInput,
9+
PublicTrade as Trade,
10+
Trace,
11+
Transfer,
1312
TxTradesAndTransfers,
13+
TypeOfTrace,
1414
} from './types'
1515
import { abbreviateString } from 'utils'
1616
import { SPECIAL_ADDRESSES } from 'apps/explorer/const'
@@ -58,13 +58,21 @@ function _fetchTradesAccounts(networkId: Network, txHash: string): Promise<Contr
5858
return fetchQuery<Array<Contract>>({ get: () => _get(networkId, queryString) }, queryString)
5959
}
6060

61+
export async function getTransactionTrace(networkId: Network, txHash: string): Promise<Trace> {
62+
return _fetchTrace(networkId, txHash)
63+
}
64+
65+
export async function getTransactionContracts(networkId: Network, txHash: string): Promise<Contract[]> {
66+
return _fetchTradesAccounts(networkId, txHash)
67+
}
68+
6169
export async function getTradesAndTransfers(networkId: Network, txHash: string): Promise<TxTradesAndTransfers> {
6270
const trace = await _fetchTrace(networkId, txHash)
6371

64-
return traceToTransfersTrades(trace)
72+
return traceToTransfersAndTrades(trace)
6573
}
6674

67-
export function traceToTransfersTrades(trace: Trace): TxTradesAndTransfers {
75+
export function traceToTransfersAndTrades(trace: Trace): TxTradesAndTransfers {
6876
const transfers: Array<Transfer> = []
6977
const trades: Array<Trade> = []
7078

@@ -90,15 +98,24 @@ export function traceToTransfersTrades(trace: Trace): TxTradesAndTransfers {
9098
feeAmount: log.inputs[IndexTradeInput.feeAmount].value,
9199
orderUid: log.inputs[IndexTradeInput.orderUid].value,
92100
}
93-
if (trade.buyToken === ETH_NULL_ADDRESS) {
101+
if (trade.buyToken === NATIVE_TOKEN_ADDRESS_LOWERCASE) {
94102
//ETH transfers are not captured by ERC20 events, so we need to manually add them to the Transfer list
95103
transfers.push({
96-
token: ETH_NULL_ADDRESS,
104+
token: NATIVE_TOKEN_ADDRESS_LOWERCASE,
97105
from: log.raw.address,
98106
to: trade.owner,
99107
value: trade.buyAmount,
100108
isInternal: log.raw.address === trade.owner,
101109
})
110+
} else if (trade.sellToken === NATIVE_TOKEN_ADDRESS_LOWERCASE) {
111+
//ETH transfers are not captured by ERC20 events, so we need to manually add them to the Transfer list
112+
transfers.push({
113+
token: NATIVE_TOKEN_ADDRESS_LOWERCASE,
114+
from: trade.owner,
115+
to: log.raw.address,
116+
value: trade.sellAmount,
117+
isInternal: log.raw.address === trade.owner,
118+
})
102119
}
103120
trades.push(trade)
104121
}

src/api/tenderly/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export interface Transfer {
3535
to: string
3636
value: string
3737
token: string
38-
isInternal: boolean
38+
isInternal?: boolean
3939
}
4040

4141
export interface Account {

src/apps/explorer/components/TransactionsTableWidget/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { TitleAddress, FlexContainer, Title } from 'apps/explorer/pages/styled'
1515
import { BlockExplorerLink } from 'components/common/BlockExplorerLink'
1616
import { ConnectionStatus } from 'components/ConnectionStatus'
1717
import { Notification } from 'components/Notification'
18-
import { useTxBatchTrades, GetTxBatchTradesResult } from 'hooks/useTxBatchTrades'
1918
import { TransactionBatchGraph } from 'apps/explorer/components/TransanctionBatchGraph'
2019
import CowLoading from 'components/common/CowLoading'
2120

@@ -37,7 +36,7 @@ function useQueryViewParams(): { tab: string } {
3736
return { tab: query.get('tab')?.toUpperCase() || DEFAULT_TAB } // if URL param empty will be used DEFAULT
3837
}
3938

40-
const tabItems = (txBatchTrades: GetTxBatchTradesResult, networkId: BlockchainNetwork): TabItemInterface[] => {
39+
const tabItems = (orders: Order[] | undefined, networkId: BlockchainNetwork, txHash: string): TabItemInterface[] => {
4140
return [
4241
{
4342
id: TabView.ORDERS,
@@ -47,7 +46,7 @@ const tabItems = (txBatchTrades: GetTxBatchTradesResult, networkId: BlockchainNe
4746
{
4847
id: TabView.GRAPH,
4948
tab: <TabIcon title="Graph" iconFontName={faProjectDiagram} />,
50-
content: <TransactionBatchGraph txBatchData={txBatchTrades} networkId={networkId} />,
49+
content: <TransactionBatchGraph orders={orders} networkId={networkId} txHash={txHash} />,
5150
},
5251
]
5352
}
@@ -61,7 +60,7 @@ export const TransactionsTableWidget: React.FC<Props> = ({ txHash }) => {
6160
const txHashParams = { networkId, txHash }
6261
const isZeroOrders = !!(orders && orders.length === 0)
6362
const notGpv2ExplorerData = useTxOrderExplorerLink(txHash, isZeroOrders)
64-
const txBatchTrades = useTxBatchTrades(networkId, txHash, orders)
63+
6564
const history = useHistory()
6665

6766
// Avoid redirecting until another network is searched again
@@ -117,7 +116,7 @@ export const TransactionsTableWidget: React.FC<Props> = ({ txHash }) => {
117116
}}
118117
>
119118
<ExplorerTabs
120-
tabItems={tabItems(txBatchTrades, networkId)}
119+
tabItems={tabItems(orders, networkId, txHash)}
121120
selectedTab={tabViewSelected}
122121
updateSelectedTab={(key: number): void => onChangeTab(key)}
123122
/>

src/apps/explorer/components/TransanctionBatchGraph/elementsBuilder.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ export default class ElementsBuilder {
2626
this._countEdgeDirection.set(idDirection, count + 1)
2727
}
2828

29-
_createNodeElement = (node: Node, parent?: string, hideLabel?: boolean): ElementDefinition => {
29+
_createNodeElement = (node: Node, parent?: string, hideLabel?: boolean, tooltip?: InfoTooltip): ElementDefinition => {
3030
this._increaseCountNodeType(node.type)
3131
return {
3232
group: 'nodes',
3333
data: {
34+
address: node.id,
3435
id: `${node.type}:${node.id}`,
3536
label: !hideLabel ? node.entity.alias : '',
3637
type: node.type,
3738
parent: parent ? `${TypeNodeOnTx.NetworkNode}:${parent}` : undefined,
39+
tooltip,
3840
href: node.entity.href,
3941
},
4042
}
@@ -45,9 +47,9 @@ export default class ElementsBuilder {
4547
return this
4648
}
4749

48-
node(node: Node, parent?: string): this {
50+
node(node: Node, parent?: string, tooltip?: InfoTooltip): this {
4951
const GROUP_NODE_NAME = 'group'
50-
this._nodes.push(this._createNodeElement(node, parent, node.id.includes(GROUP_NODE_NAME)))
52+
this._nodes.push(this._createNodeElement(node, parent, node.id.includes(GROUP_NODE_NAME), tooltip))
5153
return this
5254
}
5355

@@ -139,6 +141,10 @@ export function buildGridLayout(
139141
throw new Error('Center node is required')
140142
}
141143

144+
if (countTypes.get(TypeNodeOnTx.Token)) {
145+
return { center, nodes }
146+
}
147+
142148
const maxRows = Math.max(...countTypes.values())
143149
const middleOfTotalRows = Math.floor(maxRows / 2)
144150
const traders = countTypes.get(TypeNodeOnTx.Trader) || 0

0 commit comments

Comments
 (0)