Skip to content

Commit

Permalink
refactor: Change search-apps query to give more meta about the App.
Browse files Browse the repository at this point in the history
That will support the send-transaction feature to deal with v1 and v2 Applications.
  • Loading branch information
brunomenezes committed Nov 27, 2024
1 parent 309459a commit e356742
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apps/web/src/components/connection/connectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ const AppConnectionForm: FC<AppConnectionFormProps> = ({
chainId,
});

const applicationAddressList = applications.map((a) => a.address);

const showLoader = !isEmpty(debouncedAddress) && fetching;

const { validURL } = React.useMemo(
Expand Down Expand Up @@ -219,7 +221,7 @@ const AppConnectionForm: FC<AppConnectionFormProps> = ({
description="The application smart contract address."
rightSection={showLoader ? <Loader size="sm" /> : ""}
placeholder="0x"
data={applications}
data={applicationAddressList}
data-testid="connection-address"
{...form.getInputProps("address")}
/>
Expand Down
12 changes: 11 additions & 1 deletion apps/web/src/hooks/useSearchApplications.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import React from "react";
import { useApplicationsQuery } from "../graphql/explorer/hooks/queries";
import { RollupVersion } from "../graphql/explorer/types";

export const useSearchApplications = ({
chainId,
address,
limit,
rollupVersion,
}: {
chainId: string;
address?: string;
limit?: number;
rollupVersion?: RollupVersion;
}) => {
const rollupVersionFilter = rollupVersion
? { rollupVersion_eq: rollupVersion }
: {};

const [{ data: applicationData, fetching }] = useApplicationsQuery({
variables: {
limit: limit ?? 10,
Expand All @@ -18,12 +25,15 @@ export const useSearchApplications = ({
chain: {
id_eq: chainId,
},
...rollupVersionFilter,
},
},
});

const applications = React.useMemo(
() => (applicationData?.applications ?? []).map((a) => a.address),
() => applicationData?.applications ?? [],
[applicationData],
);

return { applications, fetching };
};

0 comments on commit e356742

Please sign in to comment.