-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: rename verified-contracts to verified-contract-instances (#248)
- Loading branch information
1 parent
c37d4b7
commit e08ebfe
Showing
21 changed files
with
146 additions
and
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
import { ChicmozL2VerifiedContractAddressData } from "@chicmoz-pkg/types"; | ||
import { ChicmozL2VerifiedContractInctanceData } from "@chicmoz-pkg/types"; | ||
|
||
export const CHAIN_NAME = "AZTEC"; | ||
export const SERVICE_NAME = "explorer-api"; | ||
|
||
export const DEFAULT_VERIFIED_CONTRACT_ADDRESSES_DEV: ChicmozL2VerifiedContractAddressData[] = | ||
export const DEFAULT_VERIFIED_CONTRACT_INSTANCES_DEV: ChicmozL2VerifiedContractInctanceData[] = | ||
[ | ||
{ | ||
contractInstanceAddress: | ||
address: | ||
"0x0e5fe9a23c854f14262bb3b3e88dab8e33412d6db17baa199506f865ed746a0c", | ||
contractIdentifier: "Some contract name/id", | ||
details: "This is a dummy verified contract", | ||
details: "This is a dummy verified contract instance", | ||
creatorName: "Test", | ||
creatorContact: | ||
"email: [email protected], discord: test#1234, telegram: @test", | ||
|
@@ -18,7 +18,7 @@ export const DEFAULT_VERIFIED_CONTRACT_ADDRESSES_DEV: ChicmozL2VerifiedContractA | |
}, | ||
]; | ||
|
||
export const DEFAULT_VERIFIED_CONTRACT_ADDRESSES_PROD: ChicmozL2VerifiedContractAddressData[] = | ||
export const DEFAULT_VERIFIED_CONTRACT_INSTANCES_PROD: ChicmozL2VerifiedContractInctanceData[] = | ||
[ | ||
// TODO: Add verified contract addresses for production | ||
// TODO: Add verified contract instances for production | ||
]; |
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
49 changes: 49 additions & 0 deletions
49
services/explorer-api/src/http-server/routes/controllers/verified-contract-instances.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,49 @@ | ||
import { RequestHandler } from "express"; | ||
import { VERIFIED_CONTRACT_INSTANCES } from "../../../environment.js"; | ||
import { getVerifiedContractInstanceSchema } from "../paths_and_validation.js"; | ||
import { | ||
verifiedContractInstanceResponse, | ||
verifiedContractInstanceResponseArray, | ||
} from "./utils/open-api-responses.js"; | ||
|
||
export const openapi_GET_L2_VERIFIED_CONTRACT_INSTANCES = { | ||
"/l2/verified-contract-instances": { | ||
get: { | ||
summary: "Get all verified contract instances", | ||
responses: verifiedContractInstanceResponseArray, | ||
}, | ||
}, | ||
}; | ||
|
||
export const GET_L2_VERIFIED_CONTRACT_INSTANCES: RequestHandler = (_req, res) => { | ||
res.status(200).send(JSON.stringify(VERIFIED_CONTRACT_INSTANCES)); | ||
}; | ||
|
||
export const openapi_GET_L2_VERIFIED_CONTRACT_INSTANCE = { | ||
"/l2/verified-contract-instances/{contractInstanceAddress}": { | ||
get: { | ||
summary: "Get a verified contract instance by address", | ||
parameters: [ | ||
{ | ||
name: "contractInstanceAddress", | ||
in: "path", | ||
required: true, | ||
schema: { | ||
type: "string", | ||
}, | ||
}, | ||
], | ||
responses: verifiedContractInstanceResponse, | ||
}, | ||
}, | ||
}; | ||
|
||
export const GET_L2_VERIFIED_CONTRACT_INSTANCE: RequestHandler = (req, res) => { | ||
const contractInstanceAddress = | ||
getVerifiedContractInstanceSchema.parse(req).params.address; | ||
const verifiedInfo = VERIFIED_CONTRACT_INSTANCES.find( | ||
(info) => info.address === contractInstanceAddress | ||
); | ||
if (!verifiedInfo) throw new Error("Verified contract instance not found"); // TODO: ensure this resolves in a 404 | ||
res.status(200).send(JSON.stringify(verifiedInfo)); | ||
}; |
49 changes: 0 additions & 49 deletions
49
services/explorer-api/src/http-server/routes/controllers/verified-contracts.ts
This file was deleted.
Oops, something went wrong.
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,5 +1,5 @@ | ||
export * from "./contract"; | ||
export * from "./verified-contract"; | ||
export * from "./verified-contract-instance"; | ||
export * from "./block"; | ||
export * from "./tx-effect"; | ||
export * from "./tx"; |
14 changes: 7 additions & 7 deletions
14
.../explorer-ui/src/api/verified-contract.ts → ...-ui/src/api/verified-contract-instance.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
14 changes: 14 additions & 0 deletions
14
services/explorer-ui/src/hooks/verified-contract-instance.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,14 @@ | ||
import { type ChicmozL2VerifiedContractInctanceData } from "@chicmoz-pkg/types"; | ||
import { type UseQueryResult, useQuery } from "@tanstack/react-query"; | ||
import { VerifiedContractInstanceL2API } from "~/api"; | ||
import { queryKeyGenerator } from "./utils"; | ||
|
||
export const useVerifiedContractInstances = (): UseQueryResult< | ||
ChicmozL2VerifiedContractInctanceData[], | ||
Error | ||
> => { | ||
return useQuery<ChicmozL2VerifiedContractInctanceData[], Error>({ | ||
queryKey: queryKeyGenerator.verifiedContracts, | ||
queryFn: VerifiedContractInstanceL2API.getVerifiedContracts, | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.