Skip to content

Commit 501240c

Browse files
authored
fix: deprecated api key format (#60)
1 parent bb218a8 commit 501240c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

microservices/tx/tx.routes.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const handleDecode = async (
2424
next: NextFunction
2525
) => {
2626
try {
27-
const goldrushApiKey = (req.headers as DecodeTXHeaders)[
27+
const goldrushApiKey = ((req.headers as DecodeTXHeaders)[
2828
"x-goldrush-api-key"
29-
];
29+
] || (req.headers as DecodeTXHeaders)["x-covalent-api-key"])!;
3030
const raw_logs = (req.query as DecodeTXQuery)["raw_logs"] === "true";
3131
const min_usd = (req.query as DecodeTXQuery)["min_usd"] ?? 0;
3232
const { chain_name, tx_hash } = req.body as DecodeTXRequest;

microservices/tx/tx.schema.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,20 @@ export const decodeTXBodySchema = yup.object({
1111

1212
export type DecodeTXRequest = yup.InferType<typeof decodeTXBodySchema>;
1313

14-
export const decodeTXHeadersSchema = yup.object({
15-
"x-goldrush-api-key": yup
16-
.string()
17-
.trim()
18-
.required("x-goldrush-api-key is required"),
19-
});
14+
export const decodeTXHeadersSchema = yup
15+
.object()
16+
.shape({
17+
"x-goldrush-api-key": yup.string().trim(),
18+
"x-covalent-api-key": yup.string().trim(),
19+
})
20+
.test(
21+
"x-goldrush-api-key or x-covalent-api-key",
22+
"x-goldrush-api-key is required, or optionally the deprecated x-covalent-api-key",
23+
(value) =>
24+
value["x-goldrush-api-key"] || value["x-covalent-api-key"]
25+
? true
26+
: false
27+
);
2028

2129
export type DecodeTXHeaders = yup.InferType<typeof decodeTXHeadersSchema>;
2230

microservices/tx/tx.service.ts

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export const fetchTxFromHash = async (
1919
{
2020
noLogs: false,
2121
quoteCurrency: "USD",
22-
withDex: false,
23-
withLending: false,
2422
withNftSales: false,
2523
withSafe: false,
2624
}

0 commit comments

Comments
 (0)