@@ -8,12 +8,38 @@ chain_reg.setup();
88import * as zone from "./assetlist_functions.mjs" ;
99import { getAssetsPricing } from "./getPools.mjs" ;
1010import { getAllRelatedAssets } from "./getRelatedAssets.mjs" ;
11+ import * as fs from 'fs' ;
12+ import * as path from 'path' ;
1113
1214//-- Global Constants --
1315
1416//This address corresponds to the native assset on all evm chains (e.g., wei on ethereum)
1517const zero_address = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" ;
1618
19+ //-- Helper Functions --
20+
21+ // Get IBC file property with zone-aware path selection
22+ // Determines _IBC directory based on the destination chain (osmosistestnet = testnet, osmosis = mainnet)
23+ function getIBCFilePropertyForZone ( chainName1 , chainName2 , property ) {
24+ // chainName2 is the zone chain (osmosistestnet or osmosis) which tells us which _IBC to use
25+ const isTestnetZone = chainName2 === "osmosistestnet" ;
26+ const ibcDirectory = isTestnetZone
27+ ? path . join ( chain_reg . chainRegistryRoot , "testnets" , "_IBC" )
28+ : path . join ( chain_reg . chainRegistryRoot , "_IBC" ) ;
29+
30+ // Build the IBC file path
31+ const sortedChains = [ chainName1 , chainName2 ] . sort ( ) ;
32+ const fileName = `${ sortedChains [ 0 ] } -${ sortedChains [ 1 ] } .json` ;
33+ const filePath = path . join ( ibcDirectory , fileName ) ;
34+
35+ // Check if file exists and return the property
36+ if ( fs . existsSync ( filePath ) ) {
37+ return chain_reg . readJsonFile ( filePath ) [ property ] ;
38+ }
39+
40+ return undefined ;
41+ }
42+
1743//This defines with types of traces are considered essentially the same asset
1844const originTraceTypes = [
1945 "ibc" ,
@@ -180,7 +206,7 @@ export function getAssetTrace(asset_data) {
180206
181207
182208 //--Find IBC Connection--
183- const channels = chain_reg . getIBCFileProperty (
209+ const channels = getIBCFilePropertyForZone (
184210 asset_data . source_asset . chain_name ,
185211 asset_data . chainName ,
186212 "channels"
0 commit comments