forked from aboutmydreams/aiis.read
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from BuidlerDAO/optimize-chain-config
Optimize chain config
- Loading branch information
Showing
11 changed files
with
64 additions
and
77 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 |
---|---|---|
@@ -1,39 +1,33 @@ | ||
import { XFANS_NETWORK_ARB, XFANS_NETWORK_BERA } from '../constants'; | ||
interface ChainConfigType { | ||
export enum Chain { | ||
Arb = 'arb', | ||
Bera = 'bera', | ||
} | ||
|
||
export const chainNameMap = { | ||
[Chain.Arb]: 'Arb Sepolia', | ||
[Chain.Bera]: 'Bera Artio', | ||
}; | ||
|
||
export interface ChainConfigType { | ||
vite_socket_base_url: string; | ||
vite_room_base_url: string; | ||
vite_contract_base_url: string; | ||
vite_base_url: string; | ||
} | ||
|
||
const _chainConfig: Record<string, ChainConfigType> = { | ||
arb: { | ||
vite_socket_base_url: import.meta.env.VITE_ARB_SOCKET_BASE_URL!, | ||
vite_room_base_url: import.meta.env.VITE_ARB_ROOM_BASE_URL!, | ||
vite_contract_base_url: import.meta.env.VITE_ARB_CONTRACT_BASE_URL!, | ||
vite_base_url: import.meta.env.VITE_ARB_BASE_URL!, | ||
const chainConfig: Record<Chain, ChainConfigType> = { | ||
[Chain.Arb]: { | ||
vite_socket_base_url: import.meta.env.VITE_ARB_SOCKET_BASE_URL, | ||
vite_room_base_url: import.meta.env.VITE_ARB_ROOM_BASE_URL, | ||
vite_contract_base_url: import.meta.env.VITE_ARB_CONTRACT_BASE_URL, | ||
vite_base_url: import.meta.env.VITE_ARB_BASE_URL, | ||
}, | ||
bera: { | ||
vite_socket_base_url: import.meta.env.VITE_BERA_SOCKET_BASE_URL!, | ||
vite_room_base_url: import.meta.env.VITE_BERA_ROOM_BASE_URL!, | ||
vite_contract_base_url: import.meta.env.VITE_BERA_CONTRACT_BASE_URL!, | ||
vite_base_url: import.meta.env.VITE_BERA_BASE_URL!, | ||
[Chain.Bera]: { | ||
vite_socket_base_url: import.meta.env.VITE_BERA_SOCKET_BASE_URL, | ||
vite_room_base_url: import.meta.env.VITE_BERA_ROOM_BASE_URL, | ||
vite_contract_base_url: import.meta.env.VITE_BERA_CONTRACT_BASE_URL, | ||
vite_base_url: import.meta.env.VITE_BERA_BASE_URL, | ||
}, | ||
}; | ||
|
||
console.log('_chainConfig', _chainConfig); | ||
const ChainConfig = () => { | ||
if (getCurrentChain() == '') console.error('chain info undefined!'); | ||
return _chainConfig[getCurrentChain()]; | ||
}; | ||
|
||
export const getCurrentChain = () => localStorage.getItem('current_chain') ?? 'arb'; | ||
export const setCurrentChain = (chain: string) => { | ||
localStorage.setItem('current_chain', chain); | ||
}; | ||
|
||
export const getCurrentChainName = () => { | ||
return getCurrentChain() == 'arb' ? XFANS_NETWORK_ARB : XFANS_NETWORK_BERA; | ||
}; | ||
|
||
export default ChainConfig; | ||
export default chainConfig; |
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
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
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
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
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