CosmES

A tree-shakeable, framework agnostic, pure ESM alternative of CosmJS and Cosmos Kit.
Installing
npm install cosmes
pnpm i cosmes
yarn add cosmes
Using with TypeScript
This library only exports ES modules. To ensure imports from this library work correctly, the following configuration is required in tsconfig.json
:
{
"compilerOptions": {
"moduleResolution": "bundler",
}
}
Using with Vite
If you are using Vite, the following configuration is required in vite.config.ts
:
export default defineConfig({
define: {
global: "window",
},
});
This can be removed once support for WalletConnect v1 is no longer required.
Using Station wallet
The Station wallet currently relies on WalletConnect v1. If you want to import and use StationController
, a polyfill for Buffer
is required:
npm install buffer
import { Buffer } from "buffer";
(window as any).Buffer = Buffer;
import "./polyfill";
See examples/solid-vite
for a working example.
This can be removed once support for WalletConnect v1 is no longer required.
Examples
Docs do not exist yet - see the examples
folder for various working examples.
Modules
This package is split into multiple subdirectories, with each subdirectory having their own set of functionalities. The root directory does not contain any exports, and all exports are exported from the subdirectories. Thus, imports must be done by referencing the subdirectories (ie. import { ... } from "cosmes/client"
).
cosmes/client
This directory contains models and helper functions to interact with Cosmos SDK via the CometBFT RPC.
cosmes/codec
This directory contains various encoding and decoding functions that relies solely on Web APIs and has no dependencies on Node.js. For modern browsers and Node v16+, this should work out of the box.
cosmes/protobufs
This directory contains the auto-generated code for various Cosmos SDK based protobufs. See scripts/gen-protobufs.mjs
for the script that generates the code.
cosmes/wallet
This directory is a Cosmos Kit alternative to manage various wallets (Keplr, Station, Cosmostation, Leap, etc.) across various different Cosmos SDK based blockchains. See examples/solid-vite
for a working example.
Features:
- Supports Station, Keplr, Leap, and Cosmostation wallets
- Supports both browser extension (desktop) and WalletConnect (mobile)
- Unified interface for connecting and signing transactions
- Signing of arbitrary messages (for wallets that support it)
- Simultaneous connections to multiple WalletConnect wallets
Benchmarks
See the benchmarks
folder, where the JS bundle size of CosmES is compared against Cosmos Kit. The following points are adhered to:
- Apps should only contain the minimal functionality of connecting to Osmosis via Keplr using both the browser extension and WalletConnect wallets
- Apps should be built using React (as Cosmos Kit has a hard dependency) and Vite
- Use the bundle size as reported by Vite after running the
vite build
command
Results
Package | Minified | Gzipped |
---|
CosmES | 529 KB | 143 KB |
Cosmos Kit | 5770 KB | 1356 KB |
Contributing
See CONTRIBUTING.md
.