From c652210c6298c51c88d021fda6331322ca5bb25f Mon Sep 17 00:00:00 2001 From: Yu Jiang Tham Date: Tue, 30 Apr 2024 17:14:53 -0400 Subject: [PATCH] Explorer urls based on chain id --- app/index.ts | 7 ++++--- app/utils.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 app/utils.ts diff --git a/app/index.ts b/app/index.ts index 87197a7..c058d7e 100644 --- a/app/index.ts +++ b/app/index.ts @@ -1,8 +1,8 @@ - +import { Axiom, UserInput } from '@axiom-crypto/client'; import { circuit, CircuitInputs } from "./axiom/average.circuit"; +import { chainIdToPathname } from "./utils"; import dotenv from "dotenv"; dotenv.config(); -import { Axiom, UserInput } from '@axiom-crypto/client'; // Inputs to the circuit import inputs from './axiom/data/inputs.json'; @@ -11,6 +11,7 @@ import inputs from './axiom/data/inputs.json'; // `npx axiom circuit compile app/axiom/average.circuit.ts` import compiledCircuit from "./axiom/data/compiled.json"; + const CHAIN_ID = "11155111"; if (!process.env[`PROVIDER_URI_${CHAIN_ID}`]) { @@ -41,7 +42,7 @@ const axiomMain = async (input: UserInput) => { console.log("Sending Query to Axiom on-chain..."); const receipt = await axiom.sendQuery(); console.log("Transaction receipt:", receipt); - console.log(`View your Query on Axiom Explorer: https://explorer.axiom.xyz/v2/sepolia/query/${args.queryId}`); + console.log(`View your Query on Axiom Explorer: https://explorer.axiom.xyz/v2/${chainIdToPathname(CHAIN_ID)}/query/${args.queryId}`); }; axiomMain(inputs); diff --git a/app/utils.ts b/app/utils.ts new file mode 100644 index 0000000..4740c5c --- /dev/null +++ b/app/utils.ts @@ -0,0 +1,12 @@ +export const chainIdToPathname = (chainId: string) => { + switch (chainId) { + case "1": + return "mainnet"; + case "11155111": + return "sepolia"; + case "84532": + return "base-sepolia"; + default: + throw new Error("Invalid chain ID"); + } +}