File tree Expand file tree Collapse file tree 5 files changed +63
-3
lines changed
packages/hyperdrive-appconfig/src Expand file tree Collapse file tree 5 files changed +63
-3
lines changed Original file line number Diff line number Diff line change @@ -14,8 +14,11 @@ VITE_CUSTOM_CHAIN_CHAIN_ID=
14
14
VITE_CAPSULE_API_KEY =
15
15
VITE_CAPSULE_ENV =
16
16
#
17
- # Sepolia
17
+ # Sepolia, or
18
18
VITE_SEPOLIA_RPC_URL =
19
+ #
20
+ # Mainnet
21
+ VITE_MAINNET_RPC_URL =
19
22
# #################################################
20
23
21
24
# Used to screen ineligible addresses.
Original file line number Diff line number Diff line change 1
1
import {
2
2
AppConfig ,
3
3
cloudChainAppConfig ,
4
+ mainnetAppConfig ,
4
5
sepoliaAppConfig ,
5
6
} from "@hyperdrive/appconfig" ;
6
7
import assertNever from "assert-never" ;
@@ -19,8 +20,7 @@ export function useAppConfig(): AppConfig {
19
20
return cloudChainAppConfig ;
20
21
21
22
case mainnet . id :
22
- // Return mainnet config when available
23
- return { } as AppConfig ;
23
+ return mainnetAppConfig ;
24
24
25
25
case sepolia . id :
26
26
return sepoliaAppConfig ;
Original file line number Diff line number Diff line change
1
+ import { AppConfig } from "src/appconfig/AppConfig" ;
2
+ export const mainnetAppConfig : AppConfig = {
3
+ chainId : 1 ,
4
+ tags : [
5
+ {
6
+ id : "yieldSource" ,
7
+ description : "A hyperdrive market's yield source" ,
8
+ } ,
9
+ ] ,
10
+ tokens : [ ] ,
11
+ hyperdrives : [ ] ,
12
+ protocols : {
13
+ maker : {
14
+ id : "maker" ,
15
+ name : "Maker" ,
16
+ iconUrl : "https://cryptologos.cc/logos/maker-mkr-logo.png?v=024" ,
17
+ } ,
18
+ lido : {
19
+ id : "lido" ,
20
+ name : "Lido" ,
21
+ iconUrl : "https://cryptologos.cc/logos/lido-dao-ldo-logo.png?v=029" ,
22
+ } ,
23
+ } ,
24
+ } ;
Original file line number Diff line number Diff line change 1
1
// appconfigs
2
2
export type { AppConfig , KnownTokenExtensions } from "src/appconfig/AppConfig" ;
3
+ export { mainnetAppConfig } from "src/generated/1.appconfig" ;
3
4
export { sepoliaAppConfig } from "src/generated/11155111.appconfig" ;
4
5
export { cloudChainAppConfig } from "src/generated/42069.appconfig" ;
6
+
5
7
// appconfig helpers
6
8
export { findBaseToken } from "src/appconfig/helpers/findBaseToken" ;
7
9
export { findHyperdriveConfig } from "src/appconfig/helpers/findHyperdriveConfig" ;
Original file line number Diff line number Diff line change
1
+ import "dotenv/config" ;
2
+
3
+ import { getAppConfigFromRegistryAddresses } from "src/appconfig/getAppConfigFromRegistryAddresses" ;
4
+ import { writeAppConfigToFile } from "src/appconfig/writeAppConfigToFile" ;
5
+ import { fetchRegistryAddresses } from "src/registry/fetchRegistryAddresses" ;
6
+ import { createPublicClient , http } from "viem" ;
7
+ import { mainnet } from "viem/chains" ;
8
+
9
+ const mainnetNodeRpcUrl = process . env . MAINNET_NODE_RPC_URL as string ;
10
+
11
+ const publicClient = createPublicClient ( {
12
+ chain : mainnet ,
13
+ transport : http ( mainnetNodeRpcUrl ) ,
14
+ } ) ;
15
+
16
+ fetchRegistryAddresses ( {
17
+ registryAddress : "0x------mainnet registry address------" ,
18
+ publicClient,
19
+ } ) . then ( async ( addresses ) => {
20
+ const appConfig = await getAppConfigFromRegistryAddresses ( {
21
+ addresses,
22
+ chainId : mainnet . id ,
23
+ publicClient,
24
+ } ) ;
25
+
26
+ writeAppConfigToFile ( {
27
+ filename : `./src/generated/${ mainnet . id } .appconfig.ts` ,
28
+ appConfig,
29
+ appConfigName : "mainnetAppConfig" ,
30
+ } ) ;
31
+ } ) ;
You can’t perform that action at this time.
0 commit comments