From 9792f6c7accbc95dcf41e3ccaee985107c606745 Mon Sep 17 00:00:00 2001 From: David Uhlmann Date: Mon, 3 Jun 2024 12:44:51 +1000 Subject: [PATCH] fix: all txs were showing in "My Orders" with unconnected wallets --- src/lib/web3/hooks/useUserLimitOrders.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/web3/hooks/useUserLimitOrders.ts b/src/lib/web3/hooks/useUserLimitOrders.ts index 9dae99a56..ae17b6269 100644 --- a/src/lib/web3/hooks/useUserLimitOrders.ts +++ b/src/lib/web3/hooks/useUserLimitOrders.ts @@ -1,3 +1,4 @@ +import Long from 'long'; import { useMemo } from 'react'; import { useInfiniteQuery } from '@tanstack/react-query'; import type { PageRequest } from '@duality-labs/neutronjs/types/codegen/cosmos/base/query/v1beta1/pagination'; @@ -30,12 +31,16 @@ export function useUserLimitOrderTranches() { pageParam: Uint8Array | undefined; }): Promise => { const client = await restClientPromise; - return client.dex.limitOrderTrancheUserAllByAddress({ - address: address || '', - pagination: { - key: pageKey || [], - } as PageRequest, - }); + return address + ? // query chain for user's transactions + client.dex.limitOrderTrancheUserAllByAddress({ + address, + pagination: { + key: pageKey || [], + } as PageRequest, + }) + : // or return no transactions + { limit_orders: [], pagination: { total: Long.ZERO } }; }, initialPageParam: undefined as Uint8Array | undefined, getNextPageParam: (lastPage): Uint8Array | undefined => {