-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): refactor env vars and constants
- Loading branch information
Mani Brar
authored and
Mani Brar
committed
Aug 31, 2024
1 parent
83b892c
commit f01e4f9
Showing
6 changed files
with
78 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// File for handling contants and configurations | ||
require("dotenv").config(); | ||
|
||
interface IBridge { | ||
chainId: number; | ||
veaInbox: string; | ||
veaOutbox: string; | ||
batcher: string; | ||
rpcOutbox: string; | ||
} | ||
|
||
// Using destination chainId to get the route configuration. | ||
const bridges: { [chainId: number]: IBridge } = { | ||
11155111: { | ||
chainId: 11155111, | ||
veaInbox: process.env.VEAINBOX_ARBSEPOLIA_TO_SEPOLIA_ADDRESS, | ||
veaOutbox: process.env.VEAOUTBOX_ARBSEPOLIA_TO_SEPOLIA_ADDRESS, | ||
batcher: process.env.TRANSACTION_BATCHER_CONTRACT_ADDRESS_SEPOLIA, | ||
rpcOutbox: process.env.RPC_SEPOLIA, | ||
}, | ||
10200: { | ||
chainId: 10200, | ||
veaInbox: process.env.VEAINBOX_ARBSEPOLIA_TO_CHIADO_ADDRESS, | ||
veaOutbox: process.env.VEAOUTBOX_ARBSEPOLIA_TO_CHIADO_ADDRESS, | ||
batcher: process.env.TRANSACTION_BATCHER_CONTRACT_ADDRESS_CHIADO, | ||
rpcOutbox: process.env.RPC_CHIADO, | ||
}, | ||
}; | ||
|
||
const getBridgeConfig = (chainId: number): IBridge | undefined => { | ||
return bridges[chainId]; | ||
}; | ||
|
||
const getInboxSubgraph = (chainId: number): string => { | ||
switch (chainId) { | ||
case 11155111: | ||
return process.env.VEAINBOX_ARBSEPOLIA_TO_SEPOLIA_SUBGRAPH; | ||
case 10200: | ||
return process.env.VEAINBOX_ARBSEPOLIA_TO_SEPOLIA_SUBGRAPH; | ||
default: | ||
throw new Error("Invalid chainid"); | ||
} | ||
}; | ||
|
||
export { getBridgeConfig, getInboxSubgraph }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"ts": 1725086460, | ||
"nonce": "6" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters