Skip to content

Commit

Permalink
Merge branch 'develop' into yomo-759
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo authored Sep 13, 2023
2 parents 3a71b42 + 722624e commit b5af097
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,21 @@ export const CreateOrder = () => {

const tokenInfos = useTokenInfos({
wallet,
tokenIds: [createOrder.amounts.buy.tokenId, createOrder.amounts.sell.tokenId],
tokenIds: [createOrder.amounts?.buy.tokenId, createOrder.amounts?.sell.tokenId],
})

const [showLimitPriceWarning, setShowLimitPriceWarning] = useState(false)
const {isBuyTouched, isSellTouched, poolDefaulted} = useSwapTouched()
const {poolList} = usePoolsByPair({
tokenA: createOrder.amounts.sell.tokenId,
tokenB: createOrder.amounts.buy.tokenId,
tokenA: createOrder.amounts?.sell.tokenId ?? '',
tokenB: createOrder.amounts?.buy.tokenId ?? '',
})

useEffect(() => {
if (poolList !== undefined) {
selectedPoolChanged(poolList[0])
poolDefaulted()
}
}, [poolDefaulted, poolList, selectedPoolChanged])
}, [poolDefaulted, selectedPoolChanged, createOrder.amounts, poolList])

const orderTypeLabels = [strings.marketButton, strings.limitButton]
const orderTypeIndex = createOrder.type === 'market' ? 0 : 1
Expand Down
6 changes: 3 additions & 3 deletions packages/swap/src/adapters/transformers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export const asYoroiAmount = (openswapAmount: {
amount: string
token: string
}): Balance.Amount => {
const {amount, token} = openswapAmount
if (amount) {
if (openswapAmount !== null && openswapAmount?.amount !== null) {
const {amount, token} = openswapAmount
const [policyId = '', assetName = ''] = token.split('.')
const subject = `${policyId}.${assetName}`
return {
Expand All @@ -137,7 +137,7 @@ export const asYoroiAmount = (openswapAmount: {
}

export const asYoroiPools = (openswapPools: Pool[]): Swap.PoolPair[] => {
return openswapPools.map(asYoroiPool)
return openswapPools?.length > 0 ? openswapPools.map(asYoroiPool) : []
}

export const asYoroiBalanceTokens = (
Expand Down
1 change: 1 addition & 0 deletions packages/swap/src/translators/reactjs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export const usePoolsByPair = (
const query = useQuery({
suspense: true,
...options,
enabled: tokenPair?.tokenA !== undefined && tokenPair?.tokenB !== undefined,
queryKey: ['usePoolsByPair', tokenPair],
queryFn: () => pools.list.byPair(tokenPair),
})
Expand Down

0 comments on commit b5af097

Please sign in to comment.