From 7e56435845da56306c3046761eb5a8146a5e71fa Mon Sep 17 00:00:00 2001 From: Vinicius Zucatti Date: Thu, 21 Oct 2021 20:21:12 -0300 Subject: [PATCH] Inject config at build time with .env files #2 --- README.md | 7 +++++++ src/contracts/MemeContract.ts | 3 +-- src/contracts/MemeGovernanceContract.ts | 3 +-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a083996..eff8b43 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,13 @@ cd my-project-name npm install ``` +Open .env.local and set the environment variables + +``` +NEXT_PUBLIC_MEME_CONTRACT_HASH=0x3298f0592ad719084518850eb7147cebb1564dd2 +NEXT_PUBLIC_MEME_GOVERNANCE_CONTRACT_HASH=0x7ab855b7a0d798e9a14221b5eca55a358c1f0573 +``` + Then, you can run **locally** in **development mode with live reload**: ``` diff --git a/src/contracts/MemeContract.ts b/src/contracts/MemeContract.ts index 6ca2a95..4f28800 100644 --- a/src/contracts/MemeContract.ts +++ b/src/contracts/MemeContract.ts @@ -1,8 +1,7 @@ import { NeoLineN3Interface } from '../utils/neoline/neoline'; import { TypedValue } from '../utils/neoline/neoline-model'; -const MEME_CONTRACT_HASH = `0x${'3298f0592ad719084518850eb7147cebb1564dd2'}`; -// const NO_OWNER_ZEROS_BASE64 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAA='; +const MEME_CONTRACT_HASH = process.env.NEXT_PUBLIC_MEME_CONTRACT_HASH || ''; export type MemeContractState = { memes: Meme[]; diff --git a/src/contracts/MemeGovernanceContract.ts b/src/contracts/MemeGovernanceContract.ts index f53f328..419fdab 100644 --- a/src/contracts/MemeGovernanceContract.ts +++ b/src/contracts/MemeGovernanceContract.ts @@ -5,8 +5,7 @@ import { NeoLineN3Interface } from '../utils/neoline/neoline'; import { TypedValue } from '../utils/neoline/neoline-model'; import { fromStackItemToMeme, Meme } from './MemeContract'; -const MEME_GOVERNANCE_CONTRACT_HASH = `0x${'7ab855b7a0d798e9a14221b5eca55a358c1f0573'}`; -// const NO_OWNER_ZEROS_BASE64 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAA='; +const MEME_GOVERNANCE_CONTRACT_HASH = process.env.NEXT_PUBLIC_MEME_GOVERNANCE_CONTRACT_HASH || ''; export function fromStackToMemeGovernanceProposal(stack: TypedValue[]): MemeGovernanceProposal[] { const proposals: MemeGovernanceProposal[] = [];