Skip to content

Commit ca8ad27

Browse files
committed
allow testnet IBC channels to be verified
1 parent 6182881 commit ca8ad27

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

.github/workflows/utility/generate_assetlist_functions.mjs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,38 @@ chain_reg.setup();
88
import * as zone from "./assetlist_functions.mjs";
99
import { getAssetsPricing } from "./getPools.mjs";
1010
import { 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)
1517
const 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
1844
const 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

Comments
 (0)