JSPM

  • Created
  • Published
  • Downloads 2784
  • Score
    100M100P100Q136731F
  • License MIT

Wrapper of @interchainjs/auth and @interchainjs/cosmos to fit corresponding interfaces in @cosmjs

Package Exports

  • interchainjs
  • interchainjs/esm/index.js
  • interchainjs/index.js
  • interchainjs/query/rpc
  • interchainjs/query/rpc.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (interchainjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

interchainjs

Wrapper of @interchainjs/auth and @interchainjs/cosmos to fit corresponding interfaces in @cosmjs

Usage

npm install interchainjs

To sign messages (taking stargate signing client as example)

// import * from "interchainjs"; // Error: use sub-imports, to ensure small app size
import { StargateSigningClient } from "interchainjs/stargate";

const directWallet = Secp256k1HDWallet.fromMnemonic(generateMnemonic(), [
  {
    prefix: commonPrefix,
    hdPath: cosmosHdPath,
  },
]);

const directSigner = directWallet.toOfflineDirectSigner();

const signingClient = await StargateSigningClient.connectWithSigner(
  await getRpcEndpoint(),
  directSigner
);

const result = await signingClient.signAndBroadcast(<ADDRESS>, <MESSAGE>[], "auto");
// or you can use helper functions to do `signAndBroadcast`. taking send tokens as example
const result = await signingClient.helpers.send(<ADDRESS>, <MsgSend message>, "auto", "");

console.log(result.transactionHash); // the hash of TxRaw

To construct an offline signer (taking direct signer as example)

const directWallet = Secp256k1HDWallet.fromMnemonic(generateMnemonic(), [
  {
    prefix: commonPrefix,
    hdPath: cosmosHdPath,
  },
]);

const directSigner = directWallet.toOfflineDirectSigner();

Implementations

  • signing client
    • signing client from interchainjs/signing-client
    • stargate signing client from interchainjs/stargate
    • cosmwasm signing client from interchainjs/cosmwasm-stargate
  • wallet
    • secp256k1 wallet from @interchainjs/cosmos/wallets/secp256k1hd

License

MIT License (MIT) & Apache License

Copyright (c) 2024 Cosmology (https://cosmology.zone/)