New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@abstract-money/core

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abstract-money/core

Typings for Abstract smart contracts

  • 3.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
40
increased by42.86%
Maintainers
2
Weekly downloads
 
Created
Source

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.

FAQs

Package last updated on 31 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc