diff --git a/.gitmodules b/.gitmodules index aad4499a..4856dc54 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "chain-registry"] path = chain-registry url = https://github.com/cosmos/chain-registry.git +[submodule "initia-registry"] + path = initia-registry + url = https://github.com/initia-labs/initia-registry diff --git a/initia-registry b/initia-registry new file mode 160000 index 00000000..188125b0 --- /dev/null +++ b/initia-registry @@ -0,0 +1 @@ +Subproject commit 188125b0018fc70c947b2ced4aef9ddb31d41c03 diff --git a/src/ast/get-chains-paths.ts b/src/ast/get-chains-paths.ts index c1f3866b..f58982fc 100644 --- a/src/ast/get-chains-paths.ts +++ b/src/ast/get-chains-paths.ts @@ -7,7 +7,6 @@ interface Args { export async function getChainsPaths({ registryPath }: Args) { const mainnetGlobs = ["*", "!_*", "!testnets"]; const testnetGlobs = ["testnets/*", "!testnets/_*"]; - const paths = await globby([...mainnetGlobs, ...testnetGlobs], { cwd: registryPath, onlyDirectories: true, @@ -15,3 +14,14 @@ export async function getChainsPaths({ registryPath }: Args) { return paths; } + +export async function getInitiaChainsPaths({ registryPath }: Args) { + const devnetGlobs = ["devnets/*", "!devnets/_*"]; + + const initiaPaths = await globby([...devnetGlobs], { + cwd: registryPath, + onlyDirectories: true, + }); + + return initiaPaths; +} diff --git a/src/ast/parse-chain-paths.ts b/src/ast/parse-chain-paths.ts index 21e21279..dd19b8b2 100644 --- a/src/ast/parse-chain-paths.ts +++ b/src/ast/parse-chain-paths.ts @@ -10,9 +10,16 @@ import { parseChainJson } from "./parse-chain-json"; interface Args { registryPath: string; chainPaths: string[]; + initiaRegistryPath: string; + initiaChainPaths: string[]; } -export async function parseChainPaths({ registryPath, chainPaths }: Args): Promise { +export async function parseChainPaths({ + registryPath, + chainPaths, + initiaChainPaths, + initiaRegistryPath, +}: Args): Promise { const chains: Chain[] = []; const assetlists: AssetList[] = []; @@ -27,10 +34,10 @@ export async function parseChainPaths({ registryPath, chainPaths }: Args): Promi const explorersRecord: Record = {}; const chainInfosRecord: Record = {}; - async function loadChainPath(chainPath: string) { + async function loadChainPath(_registryPath: string, chainPath: string) { const [assetlist, chain] = await Promise.all([ - parseAssetListJson({ registryPath, chainPath }), - parseChainJson({ registryPath, chainPath }), + parseAssetListJson({ registryPath: _registryPath, chainPath }), + parseChainJson({ registryPath: _registryPath, chainPath }), ]); chains.push(chain); @@ -54,7 +61,8 @@ export async function parseChainPaths({ registryPath, chainPaths }: Args): Promi }); } - await pMap(chainPaths, loadChainPath, { concurrency }); + await pMap(chainPaths, (i) => loadChainPath(registryPath, i), { concurrency }); + await pMap(initiaChainPaths, (i) => loadChainPath(initiaRegistryPath, i), { concurrency }); return { chains, diff --git a/src/scripts/codegen.ts b/src/scripts/codegen.ts index 86741c8b..b254b7bb 100644 --- a/src/scripts/codegen.ts +++ b/src/scripts/codegen.ts @@ -1,25 +1,37 @@ import * as path from "path"; -import { getChainsPaths } from "@/ast/get-chains-paths"; +import { getChainsPaths, getInitiaChainsPaths } from "@/ast/get-chains-paths"; import { parseChainPaths } from "@/ast/parse-chain-paths"; import { validateChainsPaths } from "@/ast/validate-chains-paths"; import { writeEntrypoints } from "@/ast/write-entrypoints"; async function codegen() { const registryPath = path.resolve("chain-registry"); + const initiaRegistryPath = path.resolve("initia-registry"); const chainPaths = await getChainsPaths({ registryPath, }); + const initiaChainPaths = await getInitiaChainsPaths({ + registryPath: initiaRegistryPath, + }); + const validChainPaths = await validateChainsPaths({ registryPath, chainPaths, }); + const initiaValidChainPaths = await validateChainsPaths({ + registryPath: initiaRegistryPath, + chainPaths: initiaChainPaths, + }); + const variables = await parseChainPaths({ registryPath, chainPaths: validChainPaths, + initiaChainPaths: initiaValidChainPaths, + initiaRegistryPath, }); await writeEntrypoints({