From 7bb8099fef54be5e75f88eb06580dff94274cd04 Mon Sep 17 00:00:00 2001 From: Shay Patel Date: Sun, 27 Oct 2024 10:14:15 +0000 Subject: [PATCH] Load ABI conditionally based on chosen chain --- .env.example | 3 ++- lib/ethers.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index e06dfc2..6cdbc7c 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ NEXT_PUBLIC_RPC_URL= -NEXT_PUBLIC_CONTRACT_ADDRESS= \ No newline at end of file +NEXT_PUBLIC_CONTRACT_ADDRESS= +CHAIN= \ No newline at end of file diff --git a/lib/ethers.ts b/lib/ethers.ts index 09df0fb..2b6014b 100644 --- a/lib/ethers.ts +++ b/lib/ethers.ts @@ -1,5 +1,6 @@ import { ethers } from 'ethers'; import EventManagerABI from '../contracts/EventManagerABI.json'; +import EventManagerBaseABI from '../contracts/EventManagerBaseABI.json'; const FLARE_TESTNET_RPC_URL = process.env.NEXT_PUBLIC_RPC_URL; const CONTRACT_ADDRESS = process.env.NEXT_PUBLIC_CONTRACT_ADDRESS; @@ -13,6 +14,6 @@ export function getFlareProvider() { export function getContract() { const provider = getFlareProvider(); const contractAddress = CONTRACT_ADDRESS; - const contractABI = EventManagerABI; + const contractABI = (process.env.CHAIN == "flare") ? EventManagerABI : EventManagerBaseABI; return new ethers.Contract(contractAddress!, contractABI, provider); }