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

@stellar/typescript-wallet-sdk-soroban

v1.8.0

Published

The Typescript Wallet Soroban SDK is a work-in-progress library that (currently) allows developers to use soroban helpers in their wallet applications. It works in conjuction with the main [Typescript Wallet SDK](https://github.com/stellar/typescript-wall

Downloads

138

Readme

Stellar Typescript Wallet Soroban SDK npm version

The Typescript Wallet Soroban SDK is a work-in-progress library that (currently) allows developers to use soroban helpers in their wallet applications. It works in conjuction with the main Typescript Wallet SDK to hold all the functionality a developer would need to create a wallet for the stellar network.

Dependency

The library is available via npm. To import typescript-wallet-sdk-soroban you need to add it as a dependency to your code:

yarn:

yarn add @stellar/typescript-wallet-sdk-soroban

npm:

npm install @stellar/typescript-wallet-sdk-soroban

Introduction

Here's some examples on how to use the Soroban helpers:

import {
  getTokenInvocationArgs,
  formatTokenAmount,
  parseTokenAmount,
  scValByType,
} from "@stellar/typescript-wallet-sdk-soroban";

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TURENET,
) as Transaction<Memo<MemoType>, Operation.InvokeHostFunction[]>;
const op = transaction.operations[0];

const args = getTokenInvocationArgs(op);
/*
  extracts args from the invoke host function operation:
  args = {
    fnName: "transfer,
    contractId: "CAPECFLUT6KHYOOWUQNP7KC6PTMICKANBURFWRMPZTXUEEKHN67B7UI2",
    from: "GCGORBD5DB4JDIKVIA536CJE3EWMWZ6KBUBWZWRQM7Y3NHFRCLOKYVAL",
    to: "GDUBMXMABE7UOZSGYJ5ONE7UYAEHKK3JOX7HZQGNZ7NYTZPPP4AJ2GQJ",
    amount: 5
  }
*/

const formattedAmount = formatTokenAmount("10000123", 3);
// converts smart contract token amount into a displayable amount that can be
// used on client UI
// formattedAmount = "10000.123"

const parsedAmount = parseTokenAmount("10000.123", 3);
// converts an amount to a whole (bigint) number that can be used on
// smart contracts operations
// parsedAmount = 10000123

const accountAddress = xdr.ScVal.scvAddress(
  xdr.ScAddress.scAddressTypeAccount(
    xdr.PublicKey.publicKeyTypeEd25519(
      StrKey.decodeEd25519PublicKey(
        "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB",
      ),
    ),
  ),
);

const addressString = scValByType(accountAddress);
// converts smart contract complex value into a simple string
// addressString = "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB"