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
1316a45c
Unverified
Commit
1316a45c
authored
Sep 11, 2023
by
eddie
Committed by
GitHub
Sep 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: zustand, migrate to createWithEqualityFn (#7220)
parent
dcf7d293
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
60 additions
and
90 deletions
+60
-90
Bag.tsx
src/components/NavBar/Bag.tsx
+1
-5
Bag.tsx
src/nft/components/bag/Bag.tsx
+9
-12
BagFooter.tsx
src/nft/components/bag/BagFooter.tsx
+7
-11
index.tsx
src/nft/components/card/index.tsx
+4
-8
ListPage.tsx
src/nft/components/profile/list/ListPage.tsx
+2
-5
ListingButton.tsx
src/nft/components/profile/list/ListingButton.tsx
+1
-3
ListModal.tsx
src/nft/components/profile/list/Modal/ListModal.tsx
+1
-3
utils.ts
src/nft/components/profile/list/utils.ts
+1
-3
ProfilePage.tsx
src/nft/components/profile/view/ProfilePage.tsx
+3
-7
useBag.ts
src/nft/hooks/useBag.ts
+5
-3
useFetchAssets.ts
src/nft/hooks/useFetchAssets.ts
+1
-3
useNFTList.ts
src/nft/hooks/useNFTList.ts
+5
-3
useProfilePageState.ts
src/nft/hooks/useProfilePageState.ts
+5
-3
usePurchaseAssets.ts
src/nft/hooks/usePurchaseAssets.ts
+5
-9
useSubscribeTransactionState.ts
src/nft/hooks/useSubscribeTransactionState.ts
+5
-9
useTokenInput.ts
src/nft/hooks/useTokenInput.ts
+5
-3
No files found.
src/components/NavBar/Bag.tsx
View file @
1316a45c
...
@@ -4,7 +4,6 @@ import { BagIcon, HundredsOverflowIcon, TagIcon } from 'nft/components/icons'
...
@@ -4,7 +4,6 @@ import { BagIcon, HundredsOverflowIcon, TagIcon } from 'nft/components/icons'
import
{
useBag
,
useSellAsset
}
from
'
nft/hooks
'
import
{
useBag
,
useSellAsset
}
from
'
nft/hooks
'
import
{
useCallback
}
from
'
react
'
import
{
useCallback
}
from
'
react
'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
shallow
}
from
'
zustand/shallow
'
const
CounterDot
=
styled
.
div
`
const
CounterDot
=
styled
.
div
`
background-color:
${({
theme
})
=>
theme
.
accent1
}
;
background-color:
${({
theme
})
=>
theme
.
accent1
}
;
...
@@ -26,10 +25,7 @@ export const Bag = () => {
...
@@ -26,10 +25,7 @@ export const Bag = () => {
const
sellAssets
=
useSellAsset
((
state
)
=>
state
.
sellAssets
)
const
sellAssets
=
useSellAsset
((
state
)
=>
state
.
sellAssets
)
const
isProfilePage
=
useIsNftProfilePage
()
const
isProfilePage
=
useIsNftProfilePage
()
const
{
bagExpanded
,
setBagExpanded
}
=
useBag
(
const
{
bagExpanded
,
setBagExpanded
}
=
useBag
(({
bagExpanded
,
setBagExpanded
})
=>
({
bagExpanded
,
setBagExpanded
}))
({
bagExpanded
,
setBagExpanded
})
=>
({
bagExpanded
,
setBagExpanded
}),
shallow
)
const
handleIconClick
=
useCallback
(()
=>
{
const
handleIconClick
=
useCallback
(()
=>
{
setBagExpanded
({
bagExpanded
:
!
bagExpanded
})
setBagExpanded
({
bagExpanded
:
!
bagExpanded
})
...
...
src/nft/components/bag/Bag.tsx
View file @
1316a45c
...
@@ -13,7 +13,6 @@ import { formatAssetEventProperties, recalculateBagUsingPooledAssets } from 'nft
...
@@ -13,7 +13,6 @@ import { formatAssetEventProperties, recalculateBagUsingPooledAssets } from 'nft
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
{
useCallback
,
useEffect
,
useMemo
,
useState
}
from
'
react
'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
shallow
}
from
'
zustand/shallow
'
import
*
as
styles
from
'
./Bag.css
'
import
*
as
styles
from
'
./Bag.css
'
import
{
BagContent
}
from
'
./BagContent
'
import
{
BagContent
}
from
'
./BagContent
'
...
@@ -98,20 +97,18 @@ const ScrollingIndicator = ({ top, show }: SeparatorProps) => (
...
@@ -98,20 +97,18 @@ const ScrollingIndicator = ({ top, show }: SeparatorProps) => (
)
)
const
Bag
=
()
=>
{
const
Bag
=
()
=>
{
const
{
resetSellAssets
,
sellAssets
}
=
useSellAsset
(
const
{
resetSellAssets
,
sellAssets
}
=
useSellAsset
(({
reset
,
sellAssets
})
=>
({
({
reset
,
sellAssets
})
=>
({
resetSellAssets
:
reset
,
resetSellAssets
:
reset
,
sellAssets
,
sellAssets
,
}),
}))
shallow
)
const
{
setProfilePageState
}
=
useProfilePageState
(({
setProfilePageState
})
=>
({
setProfilePageState
}))
const
{
setProfilePageState
}
=
useProfilePageState
(({
setProfilePageState
})
=>
({
setProfilePageState
}))
const
{
bagStatus
,
bagIsLocked
,
reset
,
bagExpanded
,
toggleBag
,
setBagExpanded
}
=
useBag
(
const
{
bagStatus
,
bagIsLocked
,
reset
,
bagExpanded
,
toggleBag
,
setBagExpanded
}
=
useBag
((
state
)
=>
({
(
state
)
=>
({
...
state
,
bagIsLocked
:
state
.
isLocked
,
uncheckedItemsInBag
:
state
.
itemsInBag
}),
...
state
,
shallow
bagIsLocked
:
state
.
isLocked
,
)
uncheckedItemsInBag
:
state
.
itemsInBag
,
}))
const
{
uncheckedItemsInBag
}
=
useBag
(({
itemsInBag
})
=>
({
uncheckedItemsInBag
:
itemsInBag
}))
const
{
uncheckedItemsInBag
}
=
useBag
(({
itemsInBag
})
=>
({
uncheckedItemsInBag
:
itemsInBag
}))
const
isProfilePage
=
useIsNftProfilePage
()
const
isProfilePage
=
useIsNftProfilePage
()
...
...
src/nft/components/bag/BagFooter.tsx
View file @
1316a45c
...
@@ -37,7 +37,6 @@ import { AlertTriangle, ChevronDown } from 'react-feather'
...
@@ -37,7 +37,6 @@ import { AlertTriangle, ChevronDown } from 'react-feather'
import
{
InterfaceTrade
,
TradeFillType
,
TradeState
}
from
'
state/routing/types
'
import
{
InterfaceTrade
,
TradeFillType
,
TradeState
}
from
'
state/routing/types
'
import
styled
,
{
useTheme
}
from
'
styled-components
'
import
styled
,
{
useTheme
}
from
'
styled-components
'
import
{
ThemedText
}
from
'
theme
'
import
{
ThemedText
}
from
'
theme
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
BuyButtonStateData
,
BuyButtonStates
,
getBuyButtonStateData
}
from
'
./ButtonStates
'
import
{
BuyButtonStateData
,
BuyButtonStates
,
getBuyButtonStateData
}
from
'
./ButtonStates
'
...
@@ -272,7 +271,7 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
...
@@ -272,7 +271,7 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
const
{
account
,
chainId
,
connector
}
=
useWeb3React
()
const
{
account
,
chainId
,
connector
}
=
useWeb3React
()
const
connected
=
Boolean
(
account
&&
chainId
)
const
connected
=
Boolean
(
account
&&
chainId
)
const
totalEthPrice
=
useBagTotalEthPrice
()
const
totalEthPrice
=
useBagTotalEthPrice
()
const
{
inputCurrency
}
=
useTokenInput
(({
inputCurrency
})
=>
({
inputCurrency
})
,
shallow
)
const
{
inputCurrency
}
=
useTokenInput
(({
inputCurrency
})
=>
({
inputCurrency
}))
const
setInputCurrency
=
useTokenInput
((
state
)
=>
state
.
setInputCurrency
)
const
setInputCurrency
=
useTokenInput
((
state
)
=>
state
.
setInputCurrency
)
const
defaultCurrency
=
useCurrency
(
'
ETH
'
)
const
defaultCurrency
=
useCurrency
(
'
ETH
'
)
const
inputCurrencyBalance
=
useTokenBalance
(
const
inputCurrencyBalance
=
useTokenBalance
(
...
@@ -284,15 +283,12 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
...
@@ -284,15 +283,12 @@ export const BagFooter = ({ setModalIsOpen, eventProperties }: BagFooterProps) =
bagStatus
,
bagStatus
,
setBagExpanded
,
setBagExpanded
,
setBagStatus
,
setBagStatus
,
}
=
useBag
(
}
=
useBag
(({
isLocked
,
bagStatus
,
setBagExpanded
,
setBagStatus
})
=>
({
({
isLocked
,
bagStatus
,
setBagExpanded
,
setBagStatus
})
=>
({
isLocked
,
isLocked
,
bagStatus
,
bagStatus
,
setBagExpanded
,
setBagExpanded
,
setBagStatus
,
setBagStatus
,
}),
}))
shallow
)
const
[
tokenSelectorOpen
,
setTokenSelectorOpen
]
=
useState
(
false
)
const
[
tokenSelectorOpen
,
setTokenSelectorOpen
]
=
useState
(
false
)
const
isPending
=
PENDING_BAG_STATUSES
.
includes
(
bagStatus
)
const
isPending
=
PENDING_BAG_STATUSES
.
includes
(
bagStatus
)
const
activeCurrency
=
inputCurrency
??
defaultCurrency
const
activeCurrency
=
inputCurrency
??
defaultCurrency
...
...
src/nft/components/card/index.tsx
View file @
1316a45c
...
@@ -6,7 +6,6 @@ import { useBag } from 'nft/hooks'
...
@@ -6,7 +6,6 @@ import { useBag } from 'nft/hooks'
import
{
GenieAsset
,
UniformAspectRatio
,
UniformAspectRatios
,
WalletAsset
}
from
'
nft/types
'
import
{
GenieAsset
,
UniformAspectRatio
,
UniformAspectRatios
,
WalletAsset
}
from
'
nft/types
'
import
{
floorFormatter
}
from
'
nft/utils
'
import
{
floorFormatter
}
from
'
nft/utils
'
import
{
ReactNode
}
from
'
react
'
import
{
ReactNode
}
from
'
react
'
import
{
shallow
}
from
'
zustand/shallow
'
interface
NftCardProps
{
interface
NftCardProps
{
asset
:
GenieAsset
|
WalletAsset
asset
:
GenieAsset
|
WalletAsset
...
@@ -70,13 +69,10 @@ export const NftCard = ({
...
@@ -70,13 +69,10 @@ export const NftCard = ({
isDisabled
,
isDisabled
,
onClick
:
onButtonClick
,
onClick
:
onButtonClick
,
})
})
const
{
bagExpanded
,
setBagExpanded
}
=
useBag
(
const
{
bagExpanded
,
setBagExpanded
}
=
useBag
((
state
)
=>
({
(
state
)
=>
({
bagExpanded
:
state
.
bagExpanded
,
bagExpanded
:
state
.
bagExpanded
,
setBagExpanded
:
state
.
setBagExpanded
,
setBagExpanded
:
state
.
setBagExpanded
,
}),
}))
shallow
)
const
collectionNft
=
'
marketplace
'
in
asset
const
collectionNft
=
'
marketplace
'
in
asset
const
profileNft
=
'
asset_contract
'
in
asset
const
profileNft
=
'
asset_contract
'
in
asset
...
...
src/nft/components/profile/list/ListPage.tsx
View file @
1316a45c
...
@@ -26,7 +26,6 @@ import styled from 'styled-components'
...
@@ -26,7 +26,6 @@ import styled from 'styled-components'
import
{
BREAKPOINTS
,
ThemedText
}
from
'
theme
'
import
{
BREAKPOINTS
,
ThemedText
}
from
'
theme
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
NumberType
,
useFormatter
}
from
'
utils/formatNumbers
'
import
{
NumberType
,
useFormatter
}
from
'
utils/formatNumbers
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
ListModal
}
from
'
./Modal/ListModal
'
import
{
ListModal
}
from
'
./Modal/ListModal
'
import
{
NFTListingsGrid
}
from
'
./NFTListingsGrid
'
import
{
NFTListingsGrid
}
from
'
./NFTListingsGrid
'
...
@@ -192,8 +191,7 @@ export const ListPage = () => {
...
@@ -192,8 +191,7 @@ export const ListPage = () => {
setGlobalMarketplaces
,
setGlobalMarketplaces
,
sellAssets
,
sellAssets
,
issues
,
issues
,
}),
})
shallow
)
)
const
{
listings
,
collectionsRequiringApproval
,
setLooksRareNonce
,
setCollectionStatusAndCallback
}
=
useNFTList
(
const
{
listings
,
collectionsRequiringApproval
,
setLooksRareNonce
,
setCollectionStatusAndCallback
}
=
useNFTList
(
({
listings
,
collectionsRequiringApproval
,
setLooksRareNonce
,
setCollectionStatusAndCallback
})
=>
({
({
listings
,
collectionsRequiringApproval
,
setLooksRareNonce
,
setCollectionStatusAndCallback
})
=>
({
...
@@ -201,8 +199,7 @@ export const ListPage = () => {
...
@@ -201,8 +199,7 @@ export const ListPage = () => {
collectionsRequiringApproval
,
collectionsRequiringApproval
,
setLooksRareNonce
,
setLooksRareNonce
,
setCollectionStatusAndCallback
,
setCollectionStatusAndCallback
,
}),
})
shallow
)
)
const
totalEthListingValue
=
useMemo
(()
=>
getTotalEthValue
(
sellAssets
),
[
sellAssets
])
const
totalEthListingValue
=
useMemo
(()
=>
getTotalEthValue
(
sellAssets
),
[
sellAssets
])
...
...
src/nft/components/profile/list/ListingButton.tsx
View file @
1316a45c
...
@@ -5,7 +5,6 @@ import { useIsMobile, useSellAsset } from 'nft/hooks'
...
@@ -5,7 +5,6 @@ import { useIsMobile, useSellAsset } from 'nft/hooks'
import
{
useMemo
,
useState
}
from
'
react
'
import
{
useMemo
,
useState
}
from
'
react
'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
BREAKPOINTS
}
from
'
theme
'
import
{
BREAKPOINTS
}
from
'
theme
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
findListingIssues
}
from
'
./utils
'
import
{
findListingIssues
}
from
'
./utils
'
...
@@ -37,8 +36,7 @@ export const ListingButton = ({ onClick }: { onClick: () => void }) => {
...
@@ -37,8 +36,7 @@ export const ListingButton = ({ onClick }: { onClick: () => void }) => {
toggleShowResolveIssues
,
toggleShowResolveIssues
,
issues
,
issues
,
setIssues
,
setIssues
,
}),
})
shallow
)
)
const
[
showWarning
,
setShowWarning
]
=
useState
(
false
)
const
[
showWarning
,
setShowWarning
]
=
useState
(
false
)
const
isMobile
=
useIsMobile
()
const
isMobile
=
useIsMobile
()
...
...
src/nft/components/profile/list/Modal/ListModal.tsx
View file @
1316a45c
...
@@ -16,7 +16,6 @@ import styled from 'styled-components'
...
@@ -16,7 +16,6 @@ import styled from 'styled-components'
import
{
BREAKPOINTS
,
ThemedText
}
from
'
theme
'
import
{
BREAKPOINTS
,
ThemedText
}
from
'
theme
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
Z_INDEX
}
from
'
theme/zIndex
'
import
{
NumberType
,
useFormatter
}
from
'
utils/formatNumbers
'
import
{
NumberType
,
useFormatter
}
from
'
utils/formatNumbers
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
TitleRow
}
from
'
../shared
'
import
{
TitleRow
}
from
'
../shared
'
import
{
ListModalSection
,
Section
}
from
'
./ListModalSection
'
import
{
ListModalSection
,
Section
}
from
'
./ListModalSection
'
...
@@ -64,8 +63,7 @@ export const ListModal = ({ overlayClick }: { overlayClick: () => void }) => {
...
@@ -64,8 +63,7 @@ export const ListModal = ({ overlayClick }: { overlayClick: () => void }) => {
getLooksRareNonce
,
getLooksRareNonce
,
collectionsRequiringApproval
,
collectionsRequiringApproval
,
listings
,
listings
,
}),
})
shallow
)
)
const
totalEthListingValue
=
useMemo
(()
=>
getTotalEthValue
(
sellAssets
),
[
sellAssets
])
const
totalEthListingValue
=
useMemo
(()
=>
getTotalEthValue
(
sellAssets
),
[
sellAssets
])
...
...
src/nft/components/profile/list/utils.ts
View file @
1316a45c
...
@@ -14,7 +14,6 @@ import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
...
@@ -14,7 +14,6 @@ import { OPENSEA_CROSS_CHAIN_CONDUIT } from 'nft/queries/openSea'
import
{
CollectionRow
,
Listing
,
ListingMarket
,
ListingRow
,
ListingStatus
,
WalletAsset
}
from
'
nft/types
'
import
{
CollectionRow
,
Listing
,
ListingMarket
,
ListingRow
,
ListingStatus
,
WalletAsset
}
from
'
nft/types
'
import
{
approveCollection
,
LOOKS_RARE_CREATOR_BASIS_POINTS
,
signListing
}
from
'
nft/utils/listNfts
'
import
{
approveCollection
,
LOOKS_RARE_CREATOR_BASIS_POINTS
,
signListing
}
from
'
nft/utils/listNfts
'
import
{
Dispatch
,
useEffect
}
from
'
react
'
import
{
Dispatch
,
useEffect
}
from
'
react
'
import
{
shallow
}
from
'
zustand/shallow
'
export
async
function
approveCollectionRow
(
export
async
function
approveCollectionRow
(
collectionRow
:
CollectionRow
,
collectionRow
:
CollectionRow
,
...
@@ -134,8 +133,7 @@ export function useSubscribeListingState() {
...
@@ -134,8 +133,7 @@ export function useSubscribeListingState() {
({
setListings
,
setCollectionsRequiringApproval
})
=>
({
({
setListings
,
setCollectionsRequiringApproval
})
=>
({
setListings
,
setListings
,
setCollectionsRequiringApproval
,
setCollectionsRequiringApproval
,
}),
})
shallow
)
)
useEffect
(()
=>
{
useEffect
(()
=>
{
const
[
newCollectionsToApprove
,
newListings
]
=
getListings
(
sellAssets
)
const
[
newCollectionsToApprove
,
newListings
]
=
getListings
(
sellAssets
)
...
...
src/nft/components/profile/view/ProfilePage.tsx
View file @
1316a45c
...
@@ -24,7 +24,6 @@ import InfiniteScroll from 'react-infinite-scroll-component'
...
@@ -24,7 +24,6 @@ import InfiniteScroll from 'react-infinite-scroll-component'
import
{
useInfiniteQuery
}
from
'
react-query
'
import
{
useInfiniteQuery
}
from
'
react-query
'
import
{
easings
,
useSpring
}
from
'
react-spring
'
import
{
easings
,
useSpring
}
from
'
react-spring
'
import
styled
from
'
styled-components
'
import
styled
from
'
styled-components
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
EmptyWalletModule
}
from
'
./EmptyWalletContent
'
import
{
EmptyWalletModule
}
from
'
./EmptyWalletContent
'
import
*
as
styles
from
'
./ProfilePage.css
'
import
*
as
styles
from
'
./ProfilePage.css
'
...
@@ -63,12 +62,9 @@ export const ProfilePage = () => {
...
@@ -63,12 +62,9 @@ export const ProfilePage = () => {
const
{
address
}
=
useWalletBalance
()
const
{
address
}
=
useWalletBalance
()
const
walletCollections
=
useWalletCollections
((
state
)
=>
state
.
walletCollections
)
const
walletCollections
=
useWalletCollections
((
state
)
=>
state
.
walletCollections
)
const
setWalletCollections
=
useWalletCollections
((
state
)
=>
state
.
setWalletCollections
)
const
setWalletCollections
=
useWalletCollections
((
state
)
=>
state
.
setWalletCollections
)
const
{
resetSellAssets
}
=
useSellAsset
(
const
{
resetSellAssets
}
=
useSellAsset
(({
reset
})
=>
({
({
reset
})
=>
({
resetSellAssets
:
reset
,
resetSellAssets
:
reset
,
}),
}))
shallow
)
const
sellAssets
=
useSellAsset
((
state
)
=>
state
.
sellAssets
)
const
sellAssets
=
useSellAsset
((
state
)
=>
state
.
sellAssets
)
const
toggleBag
=
useBag
((
state
)
=>
state
.
toggleBag
)
const
toggleBag
=
useBag
((
state
)
=>
state
.
toggleBag
)
const
[
isFiltersExpanded
,
setFiltersExpanded
]
=
useFiltersExpanded
()
const
[
isFiltersExpanded
,
setFiltersExpanded
]
=
useFiltersExpanded
()
...
...
src/nft/hooks/useBag.ts
View file @
1316a45c
import
{
NftStandard
}
from
'
graphql/data/__generated__/types-and-hooks
'
import
{
NftStandard
}
from
'
graphql/data/__generated__/types-and-hooks
'
import
{
BagItem
,
BagItemStatus
,
BagStatus
,
UpdatedGenieAsset
}
from
'
nft/types
'
import
{
BagItem
,
BagItemStatus
,
BagStatus
,
UpdatedGenieAsset
}
from
'
nft/types
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
{
v4
as
uuidv4
}
from
'
uuid
'
import
{
create
}
from
'
zustand
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
createWithEqualityFn
}
from
'
zustand/traditional
'
interface
BagState
{
interface
BagState
{
bagStatus
:
BagStatus
bagStatus
:
BagStatus
...
@@ -25,7 +26,7 @@ interface BagState {
...
@@ -25,7 +26,7 @@ interface BagState {
reset
:
()
=>
void
reset
:
()
=>
void
}
}
export
const
useBag
=
create
<
BagState
>
()(
export
const
useBag
=
create
WithEqualityFn
<
BagState
>
()(
devtools
(
devtools
(
(
set
,
get
)
=>
({
(
set
,
get
)
=>
({
bagStatus
:
BagStatus
.
ADDING_TO_BAG
,
bagStatus
:
BagStatus
.
ADDING_TO_BAG
,
...
@@ -151,5 +152,6 @@ export const useBag = create<BagState>()(
...
@@ -151,5 +152,6 @@ export const useBag = create<BagState>()(
}),
}),
}),
}),
{
name
:
'
useBag
'
}
{
name
:
'
useBag
'
}
)
),
shallow
)
)
src/nft/hooks/useFetchAssets.ts
View file @
1316a45c
...
@@ -5,7 +5,6 @@ import { buildNftTradeInputFromBagItems, recalculateBagUsingPooledAssets } from
...
@@ -5,7 +5,6 @@ import { buildNftTradeInputFromBagItems, recalculateBagUsingPooledAssets } from
import
{
getNextBagState
,
getPurchasableAssets
}
from
'
nft/utils/bag
'
import
{
getNextBagState
,
getPurchasableAssets
}
from
'
nft/utils/bag
'
import
{
buildRouteResponse
}
from
'
nft/utils/nftRoute
'
import
{
buildRouteResponse
}
from
'
nft/utils/nftRoute
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
useCallback
,
useMemo
}
from
'
react
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
useBag
}
from
'
./useBag
'
import
{
useBag
}
from
'
./useBag
'
import
{
usePurchaseAssets
}
from
'
./usePurchaseAssets
'
import
{
usePurchaseAssets
}
from
'
./usePurchaseAssets
'
...
@@ -39,8 +38,7 @@ export function useFetchAssets(): () => Promise<void> {
...
@@ -39,8 +38,7 @@ export function useFetchAssets(): () => Promise<void> {
isLocked
,
isLocked
,
setLocked
,
setLocked
,
setItemsInBag
,
setItemsInBag
,
}),
})
shallow
)
)
const
tokenTradeInput
=
useTokenInput
((
state
)
=>
state
.
tokenTradeInput
)
const
tokenTradeInput
=
useTokenInput
((
state
)
=>
state
.
tokenTradeInput
)
const
itemsInBag
=
useMemo
(()
=>
recalculateBagUsingPooledAssets
(
uncheckedItemsInBag
),
[
uncheckedItemsInBag
])
const
itemsInBag
=
useMemo
(()
=>
recalculateBagUsingPooledAssets
(
uncheckedItemsInBag
),
[
uncheckedItemsInBag
])
...
...
src/nft/hooks/useNFTList.ts
View file @
1316a45c
import
{
CollectionRow
,
ListingRow
,
ListingStatus
}
from
'
nft/types
'
import
{
CollectionRow
,
ListingRow
,
ListingStatus
}
from
'
nft/types
'
import
{
create
}
from
'
zustand
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
createWithEqualityFn
}
from
'
zustand/traditional
'
interface
NFTListState
{
interface
NFTListState
{
looksRareNonce
:
number
looksRareNonce
:
number
...
@@ -18,7 +19,7 @@ interface NFTListState {
...
@@ -18,7 +19,7 @@ interface NFTListState {
)
=>
void
)
=>
void
}
}
export
const
useNFTList
=
create
<
NFTListState
>
()(
export
const
useNFTList
=
create
WithEqualityFn
<
NFTListState
>
()(
devtools
((
set
,
get
)
=>
({
devtools
((
set
,
get
)
=>
({
looksRareNonce
:
0
,
looksRareNonce
:
0
,
listings
:
[],
listings
:
[],
...
@@ -136,5 +137,6 @@ export const useNFTList = create<NFTListState>()(
...
@@ -136,5 +137,6 @@ export const useNFTList = create<NFTListState>()(
collectionsRequiringApproval
:
collectionsCopy
,
collectionsRequiringApproval
:
collectionsCopy
,
}
}
}),
}),
}))
})),
shallow
)
)
src/nft/hooks/useProfilePageState.ts
View file @
1316a45c
import
{
create
}
from
'
zustand
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
createWithEqualityFn
}
from
'
zustand/traditional
'
import
{
ProfilePageStateType
}
from
'
../types
'
import
{
ProfilePageStateType
}
from
'
../types
'
...
@@ -11,7 +12,7 @@ interface profilePageState {
...
@@ -11,7 +12,7 @@ interface profilePageState {
setProfilePageState
:
(
state
:
ProfilePageStateType
)
=>
void
setProfilePageState
:
(
state
:
ProfilePageStateType
)
=>
void
}
}
export
const
useProfilePageState
=
create
<
profilePageState
>
()(
export
const
useProfilePageState
=
create
WithEqualityFn
<
profilePageState
>
()(
devtools
(
devtools
(
(
set
)
=>
({
(
set
)
=>
({
state
:
ProfilePageStateType
.
VIEWING
,
state
:
ProfilePageStateType
.
VIEWING
,
...
@@ -21,5 +22,6 @@ export const useProfilePageState = create<profilePageState>()(
...
@@ -21,5 +22,6 @@ export const useProfilePageState = create<profilePageState>()(
})),
})),
}),
}),
{
name
:
'
useProfilePageState
'
}
{
name
:
'
useProfilePageState
'
}
)
),
shallow
)
)
src/nft/hooks/usePurchaseAssets.ts
View file @
1316a45c
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
useWeb3React
}
from
'
@web3-react/core
'
import
{
RouteResponse
,
UpdatedGenieAsset
}
from
'
nft/types
'
import
{
RouteResponse
,
UpdatedGenieAsset
}
from
'
nft/types
'
import
{
useCallback
}
from
'
react
'
import
{
useCallback
}
from
'
react
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
useBag
}
from
'
./useBag
'
import
{
useBag
}
from
'
./useBag
'
import
{
useSendTransaction
}
from
'
./useSendTransaction
'
import
{
useSendTransaction
}
from
'
./useSendTransaction
'
...
@@ -20,14 +19,11 @@ export function usePurchaseAssets(): (
...
@@ -20,14 +19,11 @@ export function usePurchaseAssets(): (
setLocked
:
setBagLocked
,
setLocked
:
setBagLocked
,
setBagExpanded
,
setBagExpanded
,
reset
:
resetBag
,
reset
:
resetBag
,
}
=
useBag
(
}
=
useBag
(({
setLocked
,
setBagExpanded
,
reset
})
=>
({
({
setLocked
,
setBagExpanded
,
reset
})
=>
({
setLocked
,
setLocked
,
setBagExpanded
,
setBagExpanded
,
reset
,
reset
,
}),
}))
shallow
)
return
useCallback
(
return
useCallback
(
async
(
routingData
:
RouteResponse
,
assetsToBuy
:
UpdatedGenieAsset
[],
purchasingWithErc20
=
false
)
=>
{
async
(
routingData
:
RouteResponse
,
assetsToBuy
:
UpdatedGenieAsset
[],
purchasingWithErc20
=
false
)
=>
{
...
...
src/nft/hooks/useSubscribeTransactionState.ts
View file @
1316a45c
import
{
BagStatus
,
TxStateType
}
from
'
nft/types
'
import
{
BagStatus
,
TxStateType
}
from
'
nft/types
'
import
{
useEffect
,
useRef
}
from
'
react
'
import
{
useEffect
,
useRef
}
from
'
react
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
useBag
}
from
'
./useBag
'
import
{
useBag
}
from
'
./useBag
'
import
{
useSendTransaction
}
from
'
./useSendTransaction
'
import
{
useSendTransaction
}
from
'
./useSendTransaction
'
...
@@ -9,14 +8,11 @@ export function useSubscribeTransactionState(setModalIsOpen: (isOpen: boolean) =
...
@@ -9,14 +8,11 @@ export function useSubscribeTransactionState(setModalIsOpen: (isOpen: boolean) =
const
transactionState
=
useSendTransaction
((
state
)
=>
state
.
state
)
const
transactionState
=
useSendTransaction
((
state
)
=>
state
.
state
)
const
setTransactionState
=
useSendTransaction
((
state
)
=>
state
.
setState
)
const
setTransactionState
=
useSendTransaction
((
state
)
=>
state
.
setState
)
const
transactionStateRef
=
useRef
(
transactionState
)
const
transactionStateRef
=
useRef
(
transactionState
)
const
{
setBagStatus
,
setLocked
:
setBagLocked
}
=
useBag
(
const
{
setBagStatus
,
setLocked
:
setBagLocked
}
=
useBag
(({
setBagExpanded
,
setBagStatus
,
setLocked
})
=>
({
({
setBagExpanded
,
setBagStatus
,
setLocked
})
=>
({
setBagExpanded
,
setBagExpanded
,
setBagStatus
,
setBagStatus
,
setLocked
,
setLocked
,
}),
}))
shallow
)
useEffect
(()
=>
{
useEffect
(()
=>
{
useSendTransaction
.
subscribe
((
state
)
=>
(
transactionStateRef
.
current
=
state
.
state
))
useSendTransaction
.
subscribe
((
state
)
=>
(
transactionStateRef
.
current
=
state
.
state
))
...
...
src/nft/hooks/useTokenInput.ts
View file @
1316a45c
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
{
Currency
}
from
'
@uniswap/sdk-core
'
import
{
TokenTradeInput
}
from
'
graphql/data/__generated__/types-and-hooks
'
import
{
TokenTradeInput
}
from
'
graphql/data/__generated__/types-and-hooks
'
import
{
create
}
from
'
zustand
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
devtools
}
from
'
zustand/middleware
'
import
{
shallow
}
from
'
zustand/shallow
'
import
{
createWithEqualityFn
}
from
'
zustand/traditional
'
interface
TokenInputState
{
interface
TokenInputState
{
inputCurrency
?:
Currency
inputCurrency
?:
Currency
...
@@ -11,7 +12,7 @@ interface TokenInputState {
...
@@ -11,7 +12,7 @@ interface TokenInputState {
setTokenTradeInput
:
(
tokenTradeInput
:
TokenTradeInput
|
undefined
)
=>
void
setTokenTradeInput
:
(
tokenTradeInput
:
TokenTradeInput
|
undefined
)
=>
void
}
}
export
const
useTokenInput
=
create
<
TokenInputState
>
()(
export
const
useTokenInput
=
create
WithEqualityFn
<
TokenInputState
>
()(
devtools
(
devtools
(
(
set
)
=>
({
(
set
)
=>
({
inputCurrency
:
undefined
,
inputCurrency
:
undefined
,
...
@@ -21,5 +22,6 @@ export const useTokenInput = create<TokenInputState>()(
...
@@ -21,5 +22,6 @@ export const useTokenInput = create<TokenInputState>()(
setTokenTradeInput
:
(
tokenTradeInput
)
=>
set
(()
=>
({
tokenTradeInput
})),
setTokenTradeInput
:
(
tokenTradeInput
)
=>
set
(()
=>
({
tokenTradeInput
})),
}),
}),
{
name
:
'
useTokenInput
'
}
{
name
:
'
useTokenInput
'
}
)
),
shallow
)
)
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