Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
52a43f3d
Unverified
Commit
52a43f3d
authored
Feb 01, 2023
by
Jack Short
Committed by
GitHub
Feb 01, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: removeing fetch usd price for bag footer (#5903)
* chore: removing fetchUsdprice * removing console
parent
0a2a46d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
28 deletions
+11
-28
Bag.tsx
src/nft/components/bag/Bag.tsx
+6
-15
BagFooter.tsx
src/nft/components/bag/BagFooter.tsx
+5
-13
No files found.
src/nft/components/bag/Bag.tsx
View file @
52a43f3d
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
BigNumber
}
from
'
@ethersproject/bignumber
'
import
{
formatEther
}
from
'
@ethersproject/units
'
import
{
sendAnalyticsEvent
}
from
'
@uniswap/analytics
'
import
{
sendAnalyticsEvent
}
from
'
@uniswap/analytics
'
import
{
NFTEventName
}
from
'
@uniswap/analytics-events
'
import
{
NFTEventName
}
from
'
@uniswap/analytics-events
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
...
@@ -24,14 +23,13 @@ import { fetchRoute } from 'nft/queries'
...
@@ -24,14 +23,13 @@ import { fetchRoute } from 'nft/queries'
import
{
BagItemStatus
,
BagStatus
,
ProfilePageStateType
,
RouteResponse
,
TxStateType
}
from
'
nft/types
'
import
{
BagItemStatus
,
BagStatus
,
ProfilePageStateType
,
RouteResponse
,
TxStateType
}
from
'
nft/types
'
import
{
import
{
buildSellObject
,
buildSellObject
,
fetchPrice
,
formatAssetEventProperties
,
formatAssetEventProperties
,
recalculateBagUsingPooledAssets
,
recalculateBagUsingPooledAssets
,
sortUpdatedAssets
,
sortUpdatedAssets
,
}
from
'
nft/utils
'
}
from
'
nft/utils
'
import
{
combineBuyItemsWithTxRoute
}
from
'
nft/utils/txRoute/combineItemsWithTxRoute
'
import
{
combineBuyItemsWithTxRoute
}
from
'
nft/utils/txRoute/combineItemsWithTxRoute
'
import
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
}
from
'
react
'
import
{
useCallback
,
useEffect
,
useMemo
,
useRef
,
useState
}
from
'
react
'
import
{
useQuery
,
useQuery
Client
}
from
'
react-query
'
import
{
useQueryClient
}
from
'
react-query
'
import
styled
from
'
styled-components/macro
'
import
styled
from
'
styled-components/macro
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
shallow
from
'
zustand/shallow
'
import
shallow
from
'
zustand/shallow
'
...
@@ -127,7 +125,6 @@ const Bag = () => {
...
@@ -127,7 +125,6 @@ const Bag = () => {
bagExpanded
,
bagExpanded
,
toggleBag
,
toggleBag
,
setTotalEthPrice
,
setTotalEthPrice
,
setTotalUsdPrice
,
setBagExpanded
,
setBagExpanded
,
}
=
useBag
((
state
)
=>
({
...
state
,
bagIsLocked
:
state
.
isLocked
,
uncheckedItemsInBag
:
state
.
itemsInBag
}),
shallow
)
}
=
useBag
((
state
)
=>
({
...
state
,
bagIsLocked
:
state
.
isLocked
,
uncheckedItemsInBag
:
state
.
itemsInBag
}),
shallow
)
const
{
uncheckedItemsInBag
}
=
useBag
(({
itemsInBag
})
=>
({
uncheckedItemsInBag
:
itemsInBag
}))
const
{
uncheckedItemsInBag
}
=
useBag
(({
itemsInBag
})
=>
({
uncheckedItemsInBag
:
itemsInBag
}))
...
@@ -158,9 +155,7 @@ const Bag = () => {
...
@@ -158,9 +155,7 @@ const Bag = () => {
}
}
}
}
const
{
data
:
fetchedPriceData
}
=
useQuery
([
'
fetchPrice
'
,
{}],
()
=>
fetchPrice
(),
{})
const
{
totalEthPrice
}
=
useMemo
(()
=>
{
const
{
totalEthPrice
,
totalUsdPrice
}
=
useMemo
(()
=>
{
const
totalEthPrice
=
itemsInBag
.
reduce
(
const
totalEthPrice
=
itemsInBag
.
reduce
(
(
total
,
item
)
=>
(
total
,
item
)
=>
item
.
status
!==
BagItemStatus
.
UNAVAILABLE
item
.
status
!==
BagItemStatus
.
UNAVAILABLE
...
@@ -172,10 +167,9 @@ const Bag = () => {
...
@@ -172,10 +167,9 @@ const Bag = () => {
:
total
,
:
total
,
BigNumber
.
from
(
0
)
BigNumber
.
from
(
0
)
)
)
const
totalUsdPrice
=
fetchedPriceData
?
parseFloat
(
formatEther
(
totalEthPrice
))
*
fetchedPriceData
:
undefined
return
{
totalEthPrice
,
totalUsdPrice
}
return
{
totalEthPrice
}
},
[
itemsInBag
,
fetchedPriceData
])
},
[
itemsInBag
])
const
purchaseAssets
=
async
(
routingData
:
RouteResponse
)
=>
{
const
purchaseAssets
=
async
(
routingData
:
RouteResponse
)
=>
{
if
(
!
provider
||
!
routingData
)
return
if
(
!
provider
||
!
routingData
)
return
...
@@ -283,8 +277,7 @@ const Bag = () => {
...
@@ -283,8 +277,7 @@ const Bag = () => {
useEffect
(()
=>
{
useEffect
(()
=>
{
setTotalEthPrice
(
totalEthPrice
)
setTotalEthPrice
(
totalEthPrice
)
setTotalUsdPrice
(
totalUsdPrice
)
},
[
totalEthPrice
,
setTotalEthPrice
])
},
[
totalEthPrice
,
totalUsdPrice
,
setTotalEthPrice
,
setTotalUsdPrice
])
const
hasAssetsToShow
=
itemsInBag
.
length
>
0
const
hasAssetsToShow
=
itemsInBag
.
length
>
0
...
@@ -305,10 +298,9 @@ const Bag = () => {
...
@@ -305,10 +298,9 @@ const Bag = () => {
const
eventProperties
=
useMemo
(
const
eventProperties
=
useMemo
(
()
=>
({
()
=>
({
usd_value
:
totalUsdPrice
,
...
formatAssetEventProperties
(
itemsInBag
.
map
((
item
)
=>
item
.
asset
)),
...
formatAssetEventProperties
(
itemsInBag
.
map
((
item
)
=>
item
.
asset
)),
}),
}),
[
itemsInBag
,
totalUsdPrice
]
[
itemsInBag
]
)
)
if
(
!
bagExpanded
||
!
isNFTPage
)
{
if
(
!
bagExpanded
||
!
isNFTPage
)
{
...
@@ -334,7 +326,6 @@ const Bag = () => {
...
@@ -334,7 +326,6 @@ const Bag = () => {
{
hasAssetsToShow
&&
!
isProfilePage
&&
(
{
hasAssetsToShow
&&
!
isProfilePage
&&
(
<
BagFooter
<
BagFooter
totalEthPrice=
{
totalEthPrice
}
totalEthPrice=
{
totalEthPrice
}
totalUsdPrice=
{
totalUsdPrice
}
bagStatus=
{
bagStatus
}
bagStatus=
{
bagStatus
}
fetchAssets=
{
fetchAssets
}
fetchAssets=
{
fetchAssets
}
eventProperties=
{
eventProperties
}
eventProperties=
{
eventProperties
}
...
...
src/nft/components/bag/BagFooter.tsx
View file @
52a43f3d
...
@@ -123,7 +123,6 @@ const Warning = ({ children }: PropsWithChildren<unknown>) => {
...
@@ -123,7 +123,6 @@ const Warning = ({ children }: PropsWithChildren<unknown>) => {
interface
BagFooterProps
{
interface
BagFooterProps
{
totalEthPrice
:
BigNumber
totalEthPrice
:
BigNumber
totalUsdPrice
:
number
|
undefined
bagStatus
:
BagStatus
bagStatus
:
BagStatus
fetchAssets
:
()
=>
void
fetchAssets
:
()
=>
void
eventProperties
:
Record
<
string
,
unknown
>
eventProperties
:
Record
<
string
,
unknown
>
...
@@ -136,13 +135,7 @@ const PENDING_BAG_STATUSES = [
...
@@ -136,13 +135,7 @@ const PENDING_BAG_STATUSES = [
BagStatus
.
PROCESSING_TRANSACTION
,
BagStatus
.
PROCESSING_TRANSACTION
,
]
]
export
const
BagFooter
=
({
export
const
BagFooter
=
({
totalEthPrice
,
bagStatus
,
fetchAssets
,
eventProperties
}:
BagFooterProps
)
=>
{
totalEthPrice
,
totalUsdPrice
,
bagStatus
,
fetchAssets
,
eventProperties
,
}:
BagFooterProps
)
=>
{
const
toggleWalletModal
=
useToggleWalletModal
()
const
toggleWalletModal
=
useToggleWalletModal
()
const
theme
=
useTheme
()
const
theme
=
useTheme
()
const
{
account
,
chainId
,
connector
}
=
useWeb3React
()
const
{
account
,
chainId
,
connector
}
=
useWeb3React
()
...
@@ -205,9 +198,8 @@ export const BagFooter = ({
...
@@ -205,9 +198,8 @@ export const BagFooter = ({
const
activeCurrency
=
inputCurrency
??
defaultCurrency
const
activeCurrency
=
inputCurrency
??
defaultCurrency
const
parsedAmount
=
useMemo
(()
=>
{
const
parsedAmount
=
useMemo
(()
=>
{
if
(
!
inputCurrency
)
return
undefined
return
tryParseCurrencyAmount
(
formatEther
(
totalEthPrice
.
toString
()),
defaultCurrency
??
undefined
)
return
tryParseCurrencyAmount
(
formatEther
(
totalEthPrice
.
toString
()),
defaultCurrency
??
undefined
)
},
[
defaultCurrency
,
totalEthPrice
,
inputCurrency
])
},
[
defaultCurrency
,
totalEthPrice
])
const
{
state
:
swapState
,
trade
:
swapTrade
}
=
useBestTrade
(
const
{
state
:
swapState
,
trade
:
swapTrade
}
=
useBestTrade
(
TradeType
.
EXACT_OUTPUT
,
TradeType
.
EXACT_OUTPUT
,
...
@@ -215,7 +207,7 @@ export const BagFooter = ({
...
@@ -215,7 +207,7 @@ export const BagFooter = ({
inputCurrency
??
undefined
inputCurrency
??
undefined
)
)
const
usdcValue
=
useStablecoinValue
(
swapTrade
?.
input
Amount
)
const
usdcValue
=
useStablecoinValue
(
inputCurrency
?
swapTrade
?.
inputAmount
:
parsed
Amount
)
return
(
return
(
<
FooterContainer
>
<
FooterContainer
>
...
@@ -247,7 +239,7 @@ export const BagFooter = ({
...
@@ -247,7 +239,7 @@ export const BagFooter = ({
{
activeCurrency
?.
symbol
??
'
ETH
'
}
{
activeCurrency
?.
symbol
??
'
ETH
'
}
</
ThemedText
.
HeadlineSmall
>
</
ThemedText
.
HeadlineSmall
>
<
ThemedText
.
BodySmall
color=
"textSecondary"
lineHeight=
"20px"
>
<
ThemedText
.
BodySmall
color=
"textSecondary"
lineHeight=
"20px"
>
{
`${ethNumberStandardFormatter(
inputCurrency ? usdcValue?.toExact() : totalUsdPrice
, true)}`
}
{
`${ethNumberStandardFormatter(
usdcValue?.toExact()
, true)}`
}
</
ThemedText
.
BodySmall
>
</
ThemedText
.
BodySmall
>
</
TotalColumn
>
</
TotalColumn
>
</
CurrencyRow
>
</
CurrencyRow
>
...
@@ -266,7 +258,7 @@ export const BagFooter = ({
...
@@ -266,7 +258,7 @@ export const BagFooter = ({
</
Row
>
</
Row
>
<
Row
justify=
"flex-end"
>
<
Row
justify=
"flex-end"
>
<
ThemedText
.
BodySmall
color=
"textSecondary"
lineHeight=
"20px"
>
{
`${ethNumberStandardFormatter(
<
ThemedText
.
BodySmall
color=
"textSecondary"
lineHeight=
"20px"
>
{
`${ethNumberStandardFormatter(
totalUsdPrice
,
usdcValue?.toExact()
,
true
true
)}`
}
</
ThemedText
.
BodySmall
>
)}`
}
</
ThemedText
.
BodySmall
>
</
Row
>
</
Row
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment