Skip to content

Commit afbc7cd

Browse files
committed
Move hardcoded contract address and chain ID into the ENV for web faucet
1 parent 1ffeb48 commit afbc7cd

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

web-app/constants/contracts.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,24 +68,17 @@ const FAUCET: Abi = [
6868
}
6969
]
7070

71-
const ENV_CHAIN_ID = process.env.NEXT_PUBLIC_CHAIN_ID
72-
const ENV_FAUCET_ADDRESS = process.env.NEXT_PUBLIC_FAUCET_ADDRESS
71+
const faucetChainId = process.env.NEXT_PUBLIC_FAUCET_CHAIN_ID
72+
const faucetAddress = process.env.NEXT_PUBLIC_FAUCET_ADDRESS as `0x${string}` | undefined
7373

74-
const PARSED_CHAIN_ID = Number(ENV_CHAIN_ID)
75-
76-
if (!ENV_CHAIN_ID || Number.isNaN(PARSED_CHAIN_ID)) {
77-
throw new Error('Environment variable NEXT_PUBLIC_CHAIN_ID must be set to a valid number')
78-
}
79-
80-
if (!ENV_FAUCET_ADDRESS) {
81-
throw new Error('Environment variable NEXT_PUBLIC_FAUCET_ADDRESS must be set to a valid address')
82-
}
83-
84-
export const contracts: Contract[] = [
85-
{
86-
chainId: PARSED_CHAIN_ID,
87-
name: 'Faucet',
88-
address: ENV_FAUCET_ADDRESS as `0x${string}`,
89-
abi: FAUCET
90-
}
91-
]
74+
export const contracts: Contract[] =
75+
faucetChainId && faucetAddress
76+
? [
77+
{
78+
chainId: Number(faucetChainId),
79+
name: 'Faucet',
80+
address: faucetAddress,
81+
abi: FAUCET
82+
}
83+
]
84+
: []

0 commit comments

Comments
 (0)