-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: restricting gateway tokens from engaging in register
- Loading branch information
Showing
6 changed files
with
126 additions
and
0 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
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
39 changes: 39 additions & 0 deletions
39
apps/maestro/src/server/routers/axelarConfigs/getChainConfigs.ts
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,39 @@ | ||
import { TRPCError } from "@trpc/server"; | ||
import { z } from "zod"; | ||
|
||
import { publicProcedure } from "~/server/trpc"; | ||
|
||
export const getChainConfigs = publicProcedure | ||
.meta({ | ||
openapi: { | ||
summary: "Get S3 chain configs", | ||
description: "Get S3 chain configs", | ||
method: "GET", | ||
path: "/s3-chain-configs", | ||
tags: ["s3-chain-configs"], | ||
}, | ||
}) | ||
.input( | ||
z.object({ | ||
axelarChainId: z.string().max(64), | ||
// tokenAddress: z.string().optional(), | ||
}) | ||
) | ||
.output(z.any()) | ||
.query(async ({ ctx, input }) => { | ||
try { | ||
const response = await ctx.configs.axelarConfigs(); | ||
|
||
return response.chains[input.axelarChainId]; | ||
} catch (error) { | ||
// If we get a TRPC error, we throw it | ||
if (error instanceof TRPCError) { | ||
throw error; | ||
} | ||
// otherwise, we throw an internal server error | ||
throw new TRPCError({ | ||
code: "INTERNAL_SERVER_ERROR", | ||
message: "Failed to get chain configs", | ||
}); | ||
} | ||
}); |
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,8 @@ | ||
import { router } from "~/server/trpc"; | ||
import { getChainConfigs } from "./getChainConfigs"; | ||
|
||
export const axelarConfigsRouter = router({ | ||
getChainConfigs, | ||
}); | ||
|
||
export type AxelarConfigsRouter = typeof axelarConfigsRouter; |
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,16 @@ | ||
import { Maybe } from "@axelarjs/utils"; | ||
|
||
import { trpc } from "~/lib/trpc"; | ||
|
||
export function useGetChainsConfig(input: { axelarChainId?: string }) { | ||
return trpc.axelarConfigs.getChainConfigs.useQuery( | ||
{ | ||
axelarChainId: Maybe.of(input.axelarChainId).mapOr("", String), | ||
}, | ||
{ | ||
enabled: Boolean(input.axelarChainId), | ||
staleTime: 1000 * 60 * 60 * 24, // 24 hours | ||
refetchOnWindowFocus: false, | ||
} | ||
); | ||
} |