npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@regen-network/api

v1.0.0-alpha5

Published

Javascript API for Regen Ledger

Downloads

143

Readme

@regen-network/api

🚧 Warning

This API is still under heavy construction, be ready for unexpected breaking changes.

The v1.0.0-alpha4 and v1.0.0-alpha5 release tags include manual overrides of generated code in src in order to resolve a downstream issue within regen-network/groups-ui. For more information, see #84.

Table of Contents

Install

yarn add @regen-network/[email protected]

Usage

LCD Queries

Example query using a cosmos module:

import { cosmos } from "@regen-network/api"
import { PageRequest } from "@regen-network/api/types/codegen/helpers"

const { createLCDClient } = cosmos.ClientFactory

const client = await createLCDClient({
  restEndpoint: "http://localhost:1317",
})

const response = await client.cosmos.bank.v1beta1.allBalances({
  address: "regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46",
  pagination: { countTotal: true } as PageRequest,
})

See LCDCosmos.tsx for an example within the api-demo application.

Example query using a regen module:

import { regen } from "@regen-network/api"
import { PageRequest } from "@regen-network/api/types/codegen/helpers"

const { createLCDClient } = regen.ClientFactory

const client = await createLCDClient({
  restEndpoint: "http://localhost:1317",
})

const response = await client.regen.ecocredit.v1.projectByClass({
  classId: "C01",
  pagination: { countTotal: true } as PageRequest,
})

See LCDRegen.tsx for an example within the api-demo application.

RPC Queries

Example query using a cosmos module:

import { cosmos } from "@regen-network/api"
import { PageRequest } from "@regen-network/api/types/codegen/helpers"

import Long from "long"

const { createRPCQueryClient } = cosmos.ClientFactory

const client = await createRPCQueryClient({
  rpcEndpoint: "http://localhost:26657",
})

const response = await client.cosmos.bank.v1beta1.allBalances({
  address: "regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46",
  pagination: {
    key: new Uint8Array(0),
    limit: Long.fromNumber(0),
    offset: Long.fromNumber(0),
  } as PageRequest,
})

See RPCCosmos.tsx for an example within the api-demo application.

Example query using a regen module:

import { regen } from "@regen-network/api"
import { PageRequest } from "@regen-network/api/types/codegen/helpers"

import Long from "long"

const { createRPCQueryClient } = regen.ClientFactory

const client = await createRPCQueryClient({
  rpcEndpoint: "http://localhost:26657",
})

const response = await client.regen.ecocredit.v1.projectByClass({
  classId: "C01",
  pagination: {
    key: new Uint8Array(0),
    limit: Long.fromNumber(0),
    offset: Long.fromNumber(0),
  } as PageRequest,
})

See RPCRegen.tsx for an example within the api-demo application.

Composing Messages

Example message using a cosmos module:

import { cosmos, getSigningCosmosClient } from "@regen-network/api"

const { send } = cosmos.bank.v1beta1.MessageComposer.withTypeUrl

const msg = send({
  amount: [
    {
      denom: "uregen",
      amount: "10000",
    },
  ],
  toAddress: "regen156d26rl52y3wl865pr5x9q2vqetuw9kf0642sa",
  fromAddress: "regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46",
})

See MsgCosmos.tsx for an example within the api-demo application.

Example message using a regen module:

import { regen, getSigningCosmosClient } from "@regen-network/api"

const { createProject } = regen.ecocredit.v1.MessageComposer.withTypeUrl

const msg = createProject({
  admin: "regen1df675r9vnf7pdedn4sf26svdsem3ugavgxmy46",
  classId: "C01",
  metadata: "regen:13toVgf5UjYBz6J29x28pLQyjKz5FpcW3f4bT5uRKGxGREWGKjEdXYG.rdf",
  jurisdiction: "US-WA",
})

See MsgRegen.tsx for an example within the api-demo application.

Signing Messages

Example using a cosmos client (includes encoding for cosmos modules):

import { getSigningCosmosClient } from "@regen-network/api"

const { keplr } = window

const offlineSigner = keplr.getOfflineSigner("regen-local")

const [account] = await offlineSigner.getAccounts()

const signingClient = await getSigningCosmosClient({
  rpcEndpoint: "http://localhost:26657",
  signer: offlineSigner,
})

const fee = {
  amount: [
    {
      denom: "uregen",
      amount: "5000",
    },
  ],
  gas: "100000",
}

await signingClient.signAndBroadcast(account.address, [msg], fee)

See MsgCosmos.tsx for an example within the api-demo application.

Example using a regen client (includes encoding for regen modules):

import { getSigningRegenClient } from "@regen-network/api"

const { keplr } = window

const offlineSigner = keplr.getOfflineSigner("regen-local")

const [account] = await offlineSigner.getAccounts()

const signingClient = await getSigningRegenClient({
  rpcEndpoint: "http://localhost:26657",
  signer: offlineSigner,
})

const fee = {
  amount: [
    {
      denom: "uregen",
      amount: "5000",
    },
  ],
  gas: "100000",
}

await signingClient.signAndBroadcast(account.address, [msg], fee)

See MsgRegen.tsx for an example within the api-demo application.

Example using cosmjs and support for both cosmos and regen modules:

import { Registry } from "@cosmjs/proto-signing"
import { AminoTypes, SigningStargateClient } from "@cosmjs/stargate"
import {
  cosmosAminoConverters,
  cosmosProtoRegistry,
  regenAminoConverters,
  regenProtoRegistry,
} from "@regen-network/api"

const { keplr } = window

const offlineSigner = keplr.getOfflineSigner("regen-local")

const [account] = await offlineSigner.getAccounts()

const registry = new Registry({ ...cosmosProtoRegistry, ...regenProtoRegistry })

const signingClient = await SigningStargateClient.connectWithSigner(
  "http://localhost:26657",
  offlineSigner,
  {
    registry,
    aminoTypes: new AminoTypes({
      ...cosmosAminoConverters,
      ...regenAminoConverters,
    }),
  },
)

const fee = {
  amount: [
    {
      denom: "uregen",
      amount: "5000",
    },
  ],
  gas: "100000",
}

await signingClient.signAndBroadcast(account.address, [msg], fee)

See MsgMultiple.tsx for an example within the api-demo application.

Development

Install dependencies:

yarn

Generate code from proto:

yarn codegen

Compile and build library:

yarn build

Compile and build src code:

yarn build:ts

Credits

This package is built on osmonauts/telescope with initial guidance from pyramation/tmpl-telescope-module.