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

@apophis-sdk/core

v0.1.0-alpha.2

Published

Apophis SDK is an extensible & malleable framework for building decentralized applications on various blockchains. The core package contains chain agnostic types & utilities while other packages provide integrations for entire ecosystems, individual chain

Downloads

238

Readme

@apophis-sdk/core

Apophis SDK is an extensible & malleable framework for building decentralized applications on various blockchains. The core package contains chain agnostic types & utilities while other packages provide integrations for entire ecosystems, individual chains, different wallets, and frontend frameworks.

The ethos of Apophis is: You know what you need. Apophis does not facilitate building multi-chain Dapps. The various ecosystems are too different, such that a one-size-fits-all solution is simply not feasible. Instead, Apophis provides different packages for different ecosystems, each with their own benefits & quirks. To build a multi-chain Dapp with Apophis, you will need to know how to build a single-chain Dapp in each relevant ecosystem first. Apophis itself then provides some common utilities such as wallet integration, detection, selection, transaction signing, and broadcasting.

Installation

Install with your favorite package manager's equivalent of:

npm install @apophis-sdk/core @apophis-sdk/cosmos @apophis-sdk/cosmwasm @apophis-sdk/local-signer

Other packages in this family include:

I will build more integrations as time permits.

Usage

import { Any, type Asset, type NetworkConfig, signers, signals } from '@apophis-sdk/core';
import { BankSendMsg } from '@apophis-sdk/core/msg/bank';
import { Cosmos } from '@apophis-sdk/cosmos';
import { KeplrDirect } from '@apophis-sdk/keplr-signer';
import { UserAddress, WalletModal } from '@apophis-sdk/preact';
import { render } from 'preact';

// signers are shown by `WalletSelector` and `WalletModal` components
signers.push(KeplrDirect);

const assets = {
  ntrn: {
    denom: 'untrn',
    name: 'Neutron',
    cgid: 'neutron',
    decimals: 6,
  },
} satisfies Record<string, Asset>;

// NetworkConfig objects should be passed around by reference, i.e. you should not create a new one
// each time you pass it around.
const network: NetworkConfig = {
  name: 'neutron',
  chainId: 'neutron-1',
  prettyName: 'Neutron',
  addressPrefix: 'neutron',
  slip44: 118,
  assets: [assets.ntrn],
  gas: [{
    asset: assets.ntrn,
    avgPrice: 0.0053,
  }],
};

render((
  <div>
    <UserAddress />
    {!signals.account.value && <WalletModal />}
    <button onClick={handleClick}>Click me!</button>
  </div>
), document.getElementById('app')!);

function handleClick() {
  const signer = signals.signer.value;
  if (!signer) {
    console.log('No signer chosen');
    return;
  }

  // Txs accept generic `Any` messages. Which messages are available depends entirely on the chain.
  // However, some messages are generic enough that you can use them across many chains, or can be
  // translated easily using middleware.
  const tx = Cosmos.tx([
    new BankSendMsg(
      'neutron12345...',
      'neutron12345...',
      [Cosmos.coin(1n, 'untrn')]
    ).toAny(network),
  ]);

  // You can either `estimateGas` to ask the network for an estimate, or `computeGas` to compute the
  // gas fee from a gas amount + price (stored in the `NetworkConfig` object).
  await tx.estimateGas(network, signals.signer.value!, true);

  // You can only sign a transaction with a gas configuration.
  await signer.sign(network, tx);

  // You can only broadcast a signed transaction.
  await tx.broadcast();
}

Caveats

  • Indicated by its version, Apophis is currently in a very early stage and the exposed API may change significantly.
  • Not all chains are currently supported. Particularly, chains that extensively modify the baseline Cosmos SDK types such as Injective.
  • Apophis SDK currently only supports so-called Direct Signing, meaning it currently does not support Amino Signing which is required for Ledger. Amino signing is considered deprecated, and thus does not enjoy my high priority.