Skip to content
forked from cosmos/cosmjs

want to use cosmjs in <script type="module"> without the overhead of bundlers and build steps? take this 🗡🫲

Notifications You must be signed in to change notification settings

hackbg/cosmjs-esm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fadroma CosmJS-ESM

This library powers @fadroma/cw, the generic Cosmos client library that is part of @hackbg/fadroma, the portable full-stack groundwork for decentralized applications.

It is maintained by Hack.bg. Contact us at hello at hack dot bg if you need a hand with CosmWasm development!

About this package

This package contains a fork of cosmos/cosmjs and confio/cosmjs-types.

It is distributed as a Derivative Work under the Apache License 2.0, and differs from @cosmjs/stargate in the following ways:

  • All of the packages from the @cosmjs/ namespace, as well as the cosmjs-types library, are unified into a single package, @hackbg/cosmjs-esm.

  • Versioning is planned to start from 1.0.0 once a project depending on this library reaches production. SemVer will be applied, and breaking changes to the API will be tracked rigorously.

  • As the name suggests, this is an ESM-first package. Any CommonJS vestiges are removed. See @hackbg/ubik if you would like to try a modern VanillaJS workflow based on browsers' native support for ES Modules and Import Maps.

  • All type imports are now correctly marked as import type, and directories now have index files. This way, you don't have to rely on backwards compatibility solutions that paper over some of the unacknowled pitfalls of TypeScript.

Example query

The @fadroma/cw package implements the Fadroma Agent API, which provides easy access for the bank and compute modules, and enables easy deployment of smart contracts.

For chain features that are currently not covered by the Agent API, you can use the following approach:

import { CWConnection, CosmJS } from '@fadroma/cw'

const Staking = CosmJS.Proto.Cosmos.Staking.v1beta1;

const client = await new CWConnection({
  url: '...' // RPC URL
  chainId: '...',
}).qClient

const { value } = await client.queryAbci(
  '/cosmos.staking.v1beta1.Query/Validator',
  Staking.Query.QueryValidatorRequest.encode({
    validatorAddr: address
  }).finish()
)

const result = Staking.Query.QueryValidatorResponse.decode(
  value
)

About

want to use cosmjs in <script type="module"> without the overhead of bundlers and build steps? take this 🗡🫲

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 82.7%
  • JavaScript 17.3%