Offline-first Cosmos chain registry JavaScript/TypeScript client generator ðŸª
Unlike other clients which fetches data remotely, wadesta
fetches the registry's latest repository state once to generate the client locally using tiged
.
By knowing what chains exist beforehand, wadesta
can generate strongly typed client which knows what chains are available.
npm install wadesta # install locally
npm -g install wadesta # install globally
npx wadesta # run without installing
# generate with default output to ./generated/chains/
wadesta generate
# generate using interactive mode
wadesta generate -i
# generate help command
wadesta generate --help
# -r, --registry <source> Chain registry source
# -s, --registry-src <path> Local chain registry path (if registry is `local`)
# -o, --out-dir <path> Generated client output directory
# -m, --merged Merge variables (e.g. only `chainIds` instead of `mainnetChainIds`, `testnetChainIds`, and `chainIds`)
# -c, --clean Clean output directory
# -i, --interactive Interactive mode
# -h, --help Display this message
import { generate } from "wadesta";
// default arguments
generate({
registry: "github:cosmos/chain-registry",
outDir: "./generated/chains/",
});
// use local registry instead of cloning remotely
generate({
registry: "local",
registrySrc: "./path/to/registry/",
});
// unify variables instead of separate per network types
// e.g. false -> import { chainIds, mainnetChainIds, testnetChainIds } from "./generated/chains";
// true -> import { chainIds } from "./generated/chains";
generate({
merged: true,
});
These exports aggregate all chain data into Proxy objects, which includes chain registry data, chain info, and assetlist. Objects are fully typed with chain id and chain paths.
Same as chainData
but aggregates chain registry data and chain info respectively. Objects are fully typed with chain id and chain paths.
These exports aggregate chain ids and chain names as array objects. Specific network types are also available as mainnetChainIds
, mainnetChainNames
, testnetChainIds
, and testnetChainNames
.
This export is a function that returns an object with chain registry data as given parameters. e.g. given ["a", "b", "c"]
will return { a, b, c }
. Objects are fully typed same as chainData
.
Same as getChainData
but returns an array chain registry data as given parameters. e.g. given ["a", "b", "c"]
will return [a, b, c]
. Objects are fully typed same as chainData
.
import { generate, type GenerateArgs } from "wadesta";
interface GenerateArgs {
clean?: boolean;
registry?: (string & {}) | "local";
registrySrc?: string;
outDir?: string;
merged?: boolean;
}
declare const generate: (args?: GenerateArgs) => Promise<void>;
- Generate chain registry client
- Generate IBC paths
- Filter generated chains
- Select module type (CommonJS, ESM)
- Select output extensions (
.js
,.cjs
,.mjs
,.ts
)
- Griko Nibras (@grikomsn)
- Nur Fikri (@codingki)
- Joshua Nathaniel M. (@joshuanatanielnm)