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

@kadena/spirekey-sdk

v1.0.0

Published

The SpireKey SDK allows your dApp to seamlessly integrate with SpireKey.

Downloads

706

Readme

SpireKey SDK

The SpireKey SDK allows your dApp to seamlessly integrate with SpireKey.

Quick start

Install the sdk with:

# yarn add @kadena/spirekey-sdk
# npm i @kadena/spirekey-sdk
pnpm add @kadena/spirekey-sdk

Connect an account to your dApp:

import { connect } from '@kadena/spirekey-sdk';

const someHandler = async () => {
  try {
    const account = await connect('testnet04', '5');
  } catch (error) {
    console.warn('User canceled signin', error);
  }
  // if you want to know if the account is ready for submitting transactions
  // NOTE: you can in general start constructing your transaction before an account is ready
  await account.isReady();
};

Sign for an transaction:

import { connect } from '@kadena/spirekey-sdk';

const someHandler = async () => {
  const account = yourConnectedAccount;
  const tx = yourTransaction;

  try {
    // if you have multiple tx's to sign, you can provide them all at once
    // provide the accounts in the optional array if you want to wait for
    // the account to be ready before submitting
    const { transactions, isReady } = await sign(
      [tx],
      // this array is optional and can be omitted
      [
        {
          accountName: account.accountName,
          networkId: account.networkId,
          chainIds: account.chainIds,
          requestedFungibles: [
            {
              fungible: 'coin',
              amount: amount, // The requested amount
              target: '5', // Optional: The chainId to target
            },
          ],
        },
      ],
    );
  } catch (error) {
    console.warn('User canceled signing');
  }

  await isReady();

  // submit your tx with @kadena/client
  transactions.map(async (tx) => {
    const res = await client.submit(tx);
    client.pollOne(res);
  });
};

connect(networkId: string, chainId: ChainId)

To connect an account you need to provide the networkId and chainId. SpireKey will then take care of making the account available on that networkId and chainId. If your dApp relies on the account existing on the provided networkId and chainId combination, you can wait for the account to be ready before continuing.

import { connect } from '@kadena/spirekey-sdk';

const someHandler = async () => {
  try {
    const account = await connect('testnet04', '5');
  } catch (error) {
    console.warn('User canceled signin', error);
  }
  // if you want to know if the account is ready for submitting transactions
  // NOTE: you can in general start constructing your transaction before an account is ready
  await account.isReady();
};

sign(transactionList: IUnsignedCommand[], accounts?: Account[])

You can sign one or more transactions using the sign function. Additionally if your dApp requires the user(s) to have fungible tokens available for the transaction, you can provide an array with the required fungible tokens requirements. SpireKey will then prepare the account to have the tokens transfered to the chain your dApp operates on and allow your dApp to be notified when the transaction is ready.

import { connect } from '@kadena/spirekey-sdk';

const someHandler = async () => {
  const account = yourConnectedAccount;
  const tx = yourTransaction;

  // if you have multiple tx's to sign, you can provide them all at once
  // provide the accounts in the optional array if you want to wait for
  // the account to be ready before submitting
  const { transactions, isReady } = await sign(
    [tx],
    // this array is optional and can be omitted
    [
      {
        accountName: account.accountName,
        networkId: account.networkId,
        chainIds: account.chainIds,
        requestedFungibles: [
          {
            fungible: 'coin',
            amount: amount, // The requested amount
            target: '5', // Optional: The chainId to target
          },
        ],
      },
    ],
  );
  // Wait for the transactions SpireKey has prepared before submitting
  await isReady();

  // submit your tx with @kadena/client
  transactions.map(async (tx) => {
    const res = await client.submit(tx);
    client.pollOne(res);
  });
};

initSpireKey(config?: InitConfig)

The initSpireKey function is optional and can be used to configure the SDK to target a different wallet using a config object. When omitted the SDK will will use https://chainweaver.kadena.io.

If you do want to use a different host, you can provide it via the config:

InitConfig

| key | type | | :------ | :----- | | hostUrl | string |

Terms and Conditions

You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

Kadena Spirekey terms and conditions