Skip to content

Commit

Permalink
Updated to match pattern of channels api, leveraged new logger
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpoyatt committed Apr 22, 2024
1 parent b175689 commit eb03709
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 402 deletions.
38 changes: 0 additions & 38 deletions app/api/cache/route.ts

This file was deleted.

9 changes: 5 additions & 4 deletions app/api/channels/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IdentifiedChannel } from '@/api/utils/cosmos/_generated/ibc/core/channel/v1/channel';
import { IdentifiedChannel } from 'api/utils/cosmos/_generated/ibc/core/channel/v1/channel';
import { State } from 'cosmjs-types/ibc/core/channel/v1/channel';
function stateToString(state: string) {

function stringToState(state: string) {
switch (state) {
case "OPEN": return State.STATE_OPEN
case "INIT": return State.STATE_INIT
Expand Down Expand Up @@ -28,7 +29,7 @@ async function getChannelByGQQuery(channelRequest: {
const channel: IdentifiedChannel = {
portId: item.portId,
channelId: item.channelId,
state: stateToString(item.state),
state: stringToState(item.state),
ordering: item.ordering,
version: item.version,
connectionHops: item.connectionHops,
Expand Down Expand Up @@ -89,4 +90,4 @@ export async function getChannel(searchId: string) {
variables: { searchId: searchId }
};
return await getChannelByGQQuery(channelRequest);
}
}
4 changes: 2 additions & 2 deletions app/api/channels/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from 'next/server';
import { getChannel, getChannels } from '@/api/channels/helpers';
import logger from '@/utils/logger';
import { getChannel, getChannels } from 'api/channels/helpers';
import logger from 'utils/logger';

export const dynamic = 'force-dynamic'; // defaults to auto

Expand Down
4 changes: 0 additions & 4 deletions app/api/ibc/[type]/route.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { NextRequest, NextResponse } from 'next/server';
import { getClients, getConnections } from '@/api/utils/peptide';
import { SimpleCache } from '@/api/utils/cache';

export const dynamic = 'force-dynamic' // defaults to auto

export async function GET(request: NextRequest,
{params}: {params: { type: "channels" | "connections" | "clients" }}
) {
const reqType = params.type;
const cache = SimpleCache.getInstance();

try {
switch (reqType) {
Expand All @@ -21,5 +19,3 @@ export async function GET(request: NextRequest,
return NextResponse.json({error: "An error occurred while fetching data"});
}
}


Loading

0 comments on commit eb03709

Please sign in to comment.