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

Commit 4763906

Browse files
authored
Merge pull request #476 from cowprotocol/release/2.21.0
Release/2.21.0
2 parents 49f7c2b + 791bd3c commit 4763906

18 files changed

Lines changed: 316 additions & 222 deletions

File tree

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ MOCK=true
44
# Enables autoconnect for mock mode (default = true)
55
AUTOCONNECT=true
66

7+
# Public IPFS gateway
8+
REACT_APP_IPFS_READ_URI=https://cloudflare-ipfs.com/ipfs
9+
710
# Sentry
811
#REACT_APP_SENTRY_DSN='https://<url>'
912
#REACT_APP_SENTRY_TRACES_SAMPLE_RATE="1.0"

.github/workflows/vercel.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040

4141
- name: Build Project Artifacts
4242
run: >
43+
REACT_APP_IPFS_READ_URI=${{ secrets.REACT_APP_IPFS_READ_URI }}
4344
REACT_APP_SENTRY_DSN=${{ secrets.SENTRY_DSN }}
4445
REACT_APP_SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }}
4546
GOOGLE_ANALYTICS_ID=${{ secrets.GOOGLE_ANALYTICS_ID }}

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cowprotocol/explorer",
3-
"version": "2.20.0",
3+
"version": "2.21.0",
44
"description": "",
55
"main": "src/index.js",
66
"sideEffects": false,
@@ -46,7 +46,7 @@
4646
"author": "",
4747
"dependencies": {
4848
"@apollo/client": "^3.1.5",
49-
"@cowprotocol/app-data": "v0.1.0-alpha.0",
49+
"@cowprotocol/app-data": "v0.1.0",
5050
"@cowprotocol/contracts": "1.3.1",
5151
"@cowprotocol/cow-sdk": "^2.0.0",
5252
"@fortawesome/fontawesome-svg-core": "^6.1.2",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ export const TransactionsTableWidget: React.FC<Props> = ({ txHash }) => {
118118
>
119119
<ExplorerTabs
120120
tabItems={tabItems(txBatchTrades, networkId)}
121-
defaultTab={tabViewSelected}
122-
onChange={(key: number): void => onChangeTab(key)}
121+
selectedTab={tabViewSelected}
122+
updateSelectedTab={(key: number): void => onChangeTab(key)}
123123
/>
124124
</TransactionsTableContext.Provider>
125125
</>

src/apps/explorer/pages/AppData/config.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const deleteAllPropertiesByName = (schema: JSONSchema7, property: string): void
116116
deletePropertyPath(schema, property)
117117
}
118118
if (!schema.properties) return
119+
119120
for (const field in schema.properties) {
120121
deleteAllPropertiesByName(schema.properties[field] as JSONSchema7, property)
121122
}
@@ -138,7 +139,15 @@ export const deletePropertyPath = (obj: any, path: any): void => {
138139
}
139140
}
140141

141-
delete obj[path.pop()]
142+
const propName = path.pop()
143+
if (!propName) {
144+
return
145+
}
146+
147+
const propConfigurable = Object.getOwnPropertyDescriptor(obj, propName)?.configurable || false
148+
if (propConfigurable) {
149+
delete obj[propName]
150+
}
142151
}
143152

144153
const quoteDependencies = {

src/apps/explorer/pages/AppData/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ const AppDataPage: React.FC = () => {
7979
<StyledExplorerTabs
8080
className={`appData-tab--${TabView[tabViewSelected].toLowerCase()}`}
8181
tabItems={tabItems(tabData, setTabData, onChangeTab)}
82-
defaultTab={tabViewSelected}
83-
onChange={(key: number): void => onChangeTab(key)}
82+
selectedTab={tabViewSelected}
83+
updateSelectedTab={(key: number): void => onChangeTab(key)}
8484
/>
8585
</Content>
8686
</Wrapper>

src/components/common/Tabs/Tabs.tsx

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState, useCallback } from 'react'
1+
import React, { useState } from 'react'
22
import styled from 'styled-components'
33

44
// Components
@@ -37,10 +37,10 @@ export interface Props {
3737
readonly className?: string
3838
readonly tabItems: TabItemInterface[]
3939
readonly tabTheme: TabTheme
40-
readonly defaultTab?: TabId
40+
readonly selectedTab?: TabId
4141
readonly extra?: TabBarExtraContent
4242
readonly extraPosition?: 'top' | 'bottom'
43-
onChange?: (activeId: TabId) => void
43+
readonly updateSelectedTab?: (activeId: TabId) => void
4444
}
4545

4646
const Wrapper = styled.div`
@@ -90,37 +90,33 @@ const Tabs: React.FC<Props> = (props) => {
9090
const {
9191
tabTheme = DEFAULT_TAB_THEME,
9292
tabItems,
93-
defaultTab = 1,
93+
selectedTab: parentSelectedTab,
9494
extra: tabBarExtraContent,
9595
extraPosition = 'top',
96-
onChange,
96+
updateSelectedTab: parentUpdateSelectedTab,
9797
} = props
9898

99-
const [activeTab, setActiveTab] = useState(defaultTab)
100-
101-
const onTabClick = useCallback(
102-
(key: TabId): void => {
103-
setActiveTab(key)
104-
onChange?.(key)
105-
},
106-
[onChange],
107-
)
108-
109-
useEffect(() => {
110-
if (activeTab !== defaultTab) {
111-
onTabClick(defaultTab)
112-
}
113-
}, [activeTab, defaultTab, onTabClick])
99+
const [innerSelectedTab, setInnerSelectedTab] = useState(1)
100+
// Use parent state management if provided, otherwise use internal state
101+
const selectedTab = parentSelectedTab ?? innerSelectedTab
102+
const updateTab = parentUpdateSelectedTab ?? setInnerSelectedTab
114103

115104
return (
116105
<Wrapper>
117106
<TabList role="tablist" className="tablist">
118107
{tabItems.map(({ tab, id }) => (
119-
<TabItem key={id} id={id} tab={tab} onTabClick={onTabClick} isActive={activeTab === id} tabTheme={tabTheme} />
108+
<TabItem
109+
key={id}
110+
id={id}
111+
tab={tab}
112+
onTabClick={updateTab}
113+
isActive={selectedTab === id}
114+
tabTheme={tabTheme}
115+
/>
120116
))}
121117
{extraPosition === 'top' && <ExtraContent extra={tabBarExtraContent} />}
122118
</TabList>
123-
<TabContent tabItems={tabItems} activeTab={activeTab} />
119+
<TabContent tabItems={tabItems} activeTab={selectedTab} />
124120
{extraPosition === 'bottom' && <ExtraContent extra={tabBarExtraContent} />}
125121
</Wrapper>
126122
)

src/components/orders/DetailsTable/DetailsTable.stories.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,14 @@ const order = {
3030
txHash: '0x489d8fd1efd43394c7c2b26216f36f1ab49b8d67623047e0fcb60efa2a2c420b',
3131
}
3232

33-
const defaultProps: Props = { order, areTradesLoading: false, showFillsButton: false, viewFills: () => null }
33+
const defaultProps: Props = {
34+
order,
35+
areTradesLoading: false,
36+
showFillsButton: false,
37+
viewFills: () => null,
38+
isPriceInverted: false,
39+
invertPrice: () => null,
40+
}
3441

3542
export const DefaultFillOrKill = Template.bind({})
3643
DefaultFillOrKill.args = { ...defaultProps }

src/components/orders/DetailsTable/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,12 @@ export type Props = {
167167
showFillsButton: boolean | undefined
168168
areTradesLoading: boolean
169169
viewFills: () => void
170+
isPriceInverted: boolean
171+
invertPrice: () => void
170172
}
171173

172174
export function DetailsTable(props: Props): JSX.Element | null {
173-
const { order, areTradesLoading, showFillsButton, viewFills } = props
175+
const { order, areTradesLoading, showFillsButton, viewFills, isPriceInverted, invertPrice } = props
174176
const {
175177
uid,
176178
shortId,
@@ -321,6 +323,8 @@ export function DetailsTable(props: Props): JSX.Element | null {
321323
sellAmount={sellAmount}
322324
sellToken={sellToken}
323325
showInvertButton
326+
isPriceInverted={isPriceInverted}
327+
invertPrice={invertPrice}
324328
/>
325329
</td>
326330
</tr>
@@ -337,6 +341,8 @@ export function DetailsTable(props: Props): JSX.Element | null {
337341
sellAmount={executedSellAmount}
338342
sellToken={sellToken}
339343
showInvertButton
344+
isPriceInverted={isPriceInverted}
345+
invertPrice={invertPrice}
340346
/>
341347
) : (
342348
'-'

src/components/orders/FilledProgress/index.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { SurplusComponent, Percentage, Amount } from 'components/common/SurplusC
1010

1111
export type Props = {
1212
order: Order
13+
isPriceInverted?: boolean
14+
invertPrice?: () => void
1315
fullView?: boolean
1416
lineBreak?: boolean
1517
}
@@ -48,7 +50,7 @@ const Wrapper = styled.div`
4850
const TableHeading = styled.div`
4951
padding: 0 0 1rem;
5052
display: grid;
51-
grid-template-columns: minmax(min-content, auto) auto auto;
53+
grid-template-columns: minmax(min-content, auto) auto auto auto;
5254
justify-content: flex-start;
5355
gap: 1.6rem;
5456
@@ -158,6 +160,8 @@ export function FilledProgress(props: Props): JSX.Element {
158160
const {
159161
lineBreak = false,
160162
fullView = false,
163+
isPriceInverted,
164+
invertPrice,
161165
order: {
162166
executedFeeAmount,
163167
filledAmount,
@@ -239,11 +243,27 @@ export function FilledProgress(props: Props): JSX.Element {
239243
<ProgressBar showLabel={false} percentage={formattedPercentage} />
240244
</FilledContainer>
241245
</TableHeadingContent>
246+
<TableHeadingContent>
247+
<p className="title">Avg. Execution Price</p>
248+
<p className="priceNumber">
249+
{buyToken && sellToken && (
250+
<OrderPriceDisplay
251+
buyAmount={executedBuyAmount}
252+
buyToken={buyToken}
253+
sellAmount={executedSellAmount}
254+
sellToken={sellToken}
255+
showInvertButton
256+
isPriceInverted={isPriceInverted}
257+
invertPrice={invertPrice}
258+
/>
259+
)}
260+
</p>
261+
</TableHeadingContent>
242262
<TableHeadingContent className="surplus">
243263
<p className="title">Total Surplus</p>
244264
<StyledSurplusComponent surplus={surplus} token={surplusToken} showHidden />
245265
</TableHeadingContent>
246-
<TableHeadingContent className="limit-price">
266+
<TableHeadingContent>
247267
<p className="title">Limit Price</p>
248268
<p className="priceNumber">
249269
{buyToken && sellToken && (
@@ -253,6 +273,8 @@ export function FilledProgress(props: Props): JSX.Element {
253273
sellAmount={sellAmount}
254274
sellToken={sellToken}
255275
showInvertButton
276+
isPriceInverted={isPriceInverted}
277+
invertPrice={invertPrice}
256278
/>
257279
)}
258280
</p>

0 commit comments

Comments
 (0)