Skip to content

Commit

Permalink
[feat] 🧑‍💻 extract hardhat contracts addresses to env (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
dappsar committed Mar 14, 2024
1 parent 7fdd700 commit e5f76e4
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ NEXT_PUBLIC_STORAGE_URL_ALPHA='https://storage.googleapis.com/nof-alpha'
NEXT_PUBLIC_STORAGE_URL_GAMMA='https://storage.googleapis.com/nof-gamma'
NEXT_PUBLIC_ADMIN_ACCOUNTS='0x35dad65F60c1A32c9895BE97f6bcE57D32792E83,0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266'

# Only por local environment to put contracts addresses from hardhat
NEXT_PUBLIC_NOF_DAI_HARDHAT_CONTRACT_ADDRESS=''
NEXT_PUBLIC_NOF_ALPHA_HARDHAT_CONTRACT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_CARDS_HARDHAT_CONTRACT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_PACKS_HARDHAT_CONTRACT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_OFFERS_HARDHAT_CONTRACT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_TICKETS_HARDHAT_CONTRACT_ADDRESS=''


```

The source code of the smart contracts is located at [https://github.com/P4-Games/NoF-Smart-Contracts](https://github.com/P4-Games/NoF-Smart-Contracts). If you want to run them locally (example: on a hardhat or ganache node), after compiling them locally, change the addresses in the .env and set these options to network:
Expand Down
9 changes: 9 additions & 0 deletions example_env
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,12 @@ NEXT_PUBLIC_APP_ENV='development'
NEXT_PUBLIC_STORAGE_URL_ALPHA='https://storage.googleapis.com/nof-alpha'
NEXT_PUBLIC_STORAGE_URL_GAMMA='https://storage.googleapis.com/nof-gamma'
NEXT_PUBLIC_ADMIN_ACCOUNTS='0x...,0X....,0xfa3....' // accounts separated by a comma

// Only por local environment to put contracts addresses from hardhat
NEXT_PUBLIC_NOF_DAI_CONTRACT_CURRENT_ADDRESS=''
NEXT_PUBLIC_NOF_ALPHA_CONTRACT_CURRENT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_CARDS_CONTRACT_CURRENT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_PACKS_CONTRACT_CURRENT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_OFFERS_CONTRACT_CURRENT_ADDRESS=''
NEXT_PUBLIC_NOF_GAMMA_TICKETS_CONTRACT_CURRENT_ADDRESS=''

37 changes: 31 additions & 6 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,25 @@ export const adminAccounts =
// calculated variables
// ------------------------------------------------------------------

const hardhatContractAddressDAI = removeQuotes(
process.env.NEXT_PUBLIC_NOF_DAI_HARDHAT_CONTRACT_ADDRESS
)
const hardhatContractAddressAlpha = removeQuotes(
process.env.NEXT_PUBLIC_NOF_ALPHA_HARDHAT_CONTRACT_ADDRESS
)
const hardhatContractAddressGammaCards = removeQuotes(
process.env.NEXT_PUBLIC_NOF_GAMMA_CARDS_HARDHAT_CONTRACT_ADDRESS
)
const hardhatContractAddressGammaPacks = removeQuotes(
process.env.NEXT_PUBLIC_NOF_GAMMA_PACKS_HARDHAT_CONTRACT_ADDRESS
)
const hardhatContractAddressGammaOffers = removeQuotes(
process.env.NEXT_PUBLIC_NOF_GAMMA_OFFERS_HARDHAT_CONTRACT_ADDRESS
)
const hardhatContractAddressGammaTickets = removeQuotes(
process.env.NEXT_PUBLIC_NOF_GAMMA_TICKETS_HARDHAT_CONTRACT_ADDRESS
)

export const defaultSettings = {
languagePresets: 'es',
languageSetted: 'es'
Expand Down Expand Up @@ -86,12 +105,13 @@ export const NETWORKS = {
chainNodeProviderUrl: NodeProviderUrlMumbai // visible ONLY in server side code! (in cliente side will be undefined)
},
contracts: {
daiAddress: '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
alphaAddress: '0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9',
gammaCardsAddress: '0x0165878A594ca255338adfa4d48449f69242Eb8F',
gammaPackAddress: '0xa513E6E4b8f2a923D98304ec87F64353C4D5C853',
gammaOffersAddress: '0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6',
gammaTicketsAddress: '0x8A791620dd6260079BF849Dc5567aDC3F2FdC318'
// In local environment (hardhat), it take contracts addresss from environment variables
daiAddress: hardhatContractAddressDAI,
alphaAddress: hardhatContractAddressAlpha,
gammaCardsAddress: hardhatContractAddressGammaCards,
gammaPackAddress: hardhatContractAddressGammaPacks,
gammaOffersAddress: hardhatContractAddressGammaOffers,
gammaTicketsAddress: hardhatContractAddressGammaTickets
}
},
mumbai: {
Expand Down Expand Up @@ -186,3 +206,8 @@ export const NETWORKS = {
}

// ------------------------------------------------------------------

function removeQuotes(text) {
if (text === '' || !text) return text
return text.replace("'", '').replace('"', '')
}

0 comments on commit e5f76e4

Please sign in to comment.