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

@abstract-money/core

v3.4.1

Published

Typings for Abstract smart contracts

Downloads

1,136

Readme

abstractjs

This repository holds the type declarations and interfaces for our smart contracts in CosmWasm. Autogenerated contracts lie in generated and those that are "fixed" are placed in src/contracts.

Scripts

  • pnpm build: Generate the types
  • pnpm fix: Temporary fixes for the autogenerated contracts (TODO)
  • pnpm format: Run prettier
  • pnpm lint: Run linter
  • pnpm lint:fix: Attempt linter fixes

Getting Started

  1. Install core
pnpm install @abstract-money/core
  1. Initialize the AbstractQueryClient for the chain on which you're using Abstract.
import { AbstractQueryClient } from '@abstract-money/core'

const CHAIN_NAME = "juno"
const getAbstract = async () => {
  const abstractQueryClient = await AbtsractQueryClient.connectToChain(CHAIN_NAME)
}

Abstract API

  1. Install dependencies
pnpm install graphql-request@5

Typescript

To allow for strongly-typing the schemas, we recommend setting up code generation.

See https://www.apollographql.com/docs/ios/code-generation/codegen-configuration/ for alternative options.

The following uses the-guild's graphql codegen as a typescript preset. See https://the-guild.dev/graphql/codegen/plugins/presets/preset-client for client options.

  1. Install dependencies
pnpm install -D @graphql-codegen/cli @graphql-codegen/client-preset @graphql-typed-document-node/core
  1. Setup codegen.yml. This allows for auto type generation. See
schema: "<API_URL>" # This can be the API URL or the schema document

documents: ['./src/**/*.{tsx,ts}', '!src/__generated__/gql/**/*']
generates:
  ./src/__generated__/gql/:
    preset: client
    presetConfig:
      gqlTagName: gql
      immutableTypes: true
    config:
      immutableTypes: true
      useTypeImports: true
      scalars:
        # Temporarily map to any, see DAT-16
        JSON: any
        Semver: string
        Bech32Address: string
        SafeInt: number
  1. Add codegen command to package.json
{
  "scripts": {
    "codegen": "graphql-codegen --config codegen.yml",
    "codegen:watch": "graphql-codegen --config codegen.yml --watch"
  }
}

NOTE: The first time you generate the types you will not import gql from the generated folder, rather just including the string in the file!

Usage

The following example shows how to query the Abstract API for the value of a given account.

import { gql } from '__generated__/gql'
import { type AccountValueQuery } from '__generated__/gql/graphql'
import { AbstractAccountId, abstractApiRequest } from '@abstract-money/core'

const accountValueQuery = gql(/* GraphQL */ `
  query AccountValue($accountId: AccountIdInput!, $chain: ID!) {
    account(chain: $chain, accountId: $accountId) {
      vault {
        baseAsset
        value
      }
    }
  }
`)

const CHAIN_NAME = "juno"

const getAccountValue = async (accountId: AbstractAccountId) => {
  // This type is auto-generated and inferred by graphql-codegen, we are typing it for exemplary purposes
  const result: AccountValueQuery = await abstractApiRequest(
    accountValueQuery,
    // query variables are also strongly-typed!
    {
      chain: CHAIN_NAME,
      accountId: accountId.toApi(),
    }
  )

  return result.account.value
}

IDES

We recommend installing the graphql plugins for the ides, where you can also include a link to the Abstract API URL for auto recognition of the schemas.