-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connections and Channels explorer pages (#2010)
- fix(site): remove blocksStore JSON - feat(app): connections in explorer - feat(app): channels in explorer
- Loading branch information
Showing
8 changed files
with
232 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { graphql } from "gql.tada" | ||
|
||
export const channelsQuery = graphql(/* GraphQL */ `query ChannelsQuery($limit: Int = 500) { | ||
v0_channel_map(order_by: [ | ||
{status: asc}, | ||
{from_chain_id: asc}, | ||
{from_connection_id: asc}, | ||
{from_channel_id: asc}, | ||
{from_port_id: asc}, | ||
{to_chain_id: asc}, | ||
{to_connection_id: asc}, | ||
{to_channel_id: asc}, | ||
{to_port_id: asc} | ||
], limit: $limit) { | ||
from_chain_id | ||
from_connection_id | ||
from_channel_id | ||
from_port_id | ||
to_chain_id | ||
to_connection_id | ||
to_channel_id | ||
to_port_id | ||
status | ||
} | ||
}`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { graphql } from "gql.tada" | ||
|
||
export const connectionsQuery = graphql(/* GraphQL */ ` | ||
query ConnectionsQuery($limit: Int = 100) { | ||
v0_connection_map(order_by: [ | ||
{status: asc}, | ||
{from_chain_id: asc}, | ||
{from_client_id: asc}, | ||
{from_connection_id: asc}, | ||
{to_chain_id: asc}, | ||
{to_client_id: asc}, | ||
{to_connection_id: asc} | ||
], limit: $limit) { | ||
from_chain_id | ||
to_chain_id | ||
from_client_id | ||
from_connection_id | ||
to_client_id | ||
to_connection_id | ||
status | ||
} | ||
} | ||
`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,77 @@ | ||
<script lang="ts"> | ||
import { cn } from "$lib/utilities/shadcn.ts" | ||
import request from "graphql-request" | ||
import { channelsQuery } from "$lib/graphql/documents/channels.ts" | ||
import { createQuery } from "@tanstack/svelte-query" | ||
import { URLS } from "$lib/constants" | ||
import Table from "../(components)/table.svelte" | ||
import { flexRender, type ColumnDef } from "@tanstack/svelte-table" | ||
import { writable } from "svelte/store" | ||
import CellDurationText from "../(components)/cell-duration-text.svelte" | ||
import CellStatus from "../(components)/cell-status.svelte" | ||
import { DurationUnits } from "svelte-ux" | ||
$: channels = createQuery({ | ||
queryKey: ["channels"], | ||
refetchInterval: 5_000, | ||
queryFn: async () => request(URLS.GRAPHQL, channelsQuery, {}) | ||
}) | ||
$: channelsData = $channels?.data?.v0_channel_map ?? [] | ||
type Channel = (typeof channelsData)[number] | ||
$: channelsStore = writable<Array<Channel>>(channelsData as Array<Channel>) | ||
$: if (channels) { | ||
channelsStore.update(channels => channels) | ||
} | ||
const columns: Array<ColumnDef<{ chain_id: string }>> = [ | ||
{ | ||
accessorKey: "from_chain_id", | ||
header: () => "From Chain ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "from_connection_id", | ||
header: () => "From Connection ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "from_channel_id", | ||
header: () => "From Channel ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "to_chain_id", | ||
header: () => "To Chain ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "to_connection_id", | ||
header: () => "To Connection ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "to_channel_id", | ||
header: () => "To Channel ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "status", | ||
header: () => "Status", | ||
size: 200, | ||
cell: info => | ||
flexRender(CellStatus, { | ||
value: info.getValue() | ||
}) | ||
} | ||
] | ||
</script> | ||
|
||
<Table bind:dataStore={channelsStore} {columns} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,77 @@ | ||
<script lang="ts"> | ||
import request from "graphql-request" | ||
import { connectionsQuery } from "$lib/graphql/documents/connections.ts" | ||
import { createQuery } from "@tanstack/svelte-query" | ||
import { URLS } from "$lib/constants" | ||
import Table from "../(components)/table.svelte" | ||
import { flexRender, type ColumnDef } from "@tanstack/svelte-table" | ||
import { writable } from "svelte/store" | ||
import CellDurationText from "../(components)/cell-duration-text.svelte" | ||
import CellStatus from "../(components)/cell-status.svelte" | ||
import { DurationUnits } from "svelte-ux" | ||
$: connections = createQuery({ | ||
queryKey: ["connections"], | ||
refetchInterval: 5_000, | ||
queryFn: async () => request(URLS.GRAPHQL, connectionsQuery, {}) | ||
}) | ||
$: connectionsData = $connections?.data?.v0_connection_map ?? [] | ||
type Connection = (typeof connectionsData)[number] | ||
$: connectionsStore = writable<Array<Connection>>(connectionsData as Array<Connection>) | ||
$: if (connections) { | ||
connectionsStore.update(connections => connections) | ||
} | ||
const columns: Array<ColumnDef<{ chain_id: string }>> = [ | ||
{ | ||
accessorKey: "from_chain_id", | ||
header: () => "From Chain ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "from_client_id", | ||
header: () => "From Client ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "from_connection_id", | ||
header: () => "From Connection ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "to_chain_id", | ||
header: () => "To Chain ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "to_client_id", | ||
header: () => "To Client ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "to_connection_id", | ||
header: () => "To Connection ID", | ||
size: 200, | ||
cell: info => info.getValue() | ||
}, | ||
{ | ||
accessorKey: "status", | ||
header: () => "Status", | ||
size: 200, | ||
cell: info => | ||
flexRender(CellStatus, { | ||
value: info.getValue() | ||
}) | ||
} | ||
] | ||
</script> | ||
|
||
<Table bind:dataStore={connectionsStore} {columns} /> |