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

@lawallet/sdk

v0.1.45

Published

LaWallet software dev kit

Downloads

81

Readme

@lawallet/sdk

SDK for LaWallet

Installation

pnpm add @lawallet/sdk

Usage examples

Fetch

import { Wallet, createSigner } from '@lawallet/sdk';

const Alice = new Wallet({ signer: createSigner("ALICE_SECRET_KEY") });
const Bob = new Wallet({ signer: createSigner("BOB_SECRET_KEY") });

Alice.fetch().then(({ lnurlpData, nostr }) => {
  // returns lnurlpData -> /.well-known/lnurlp/<user> response
  console.log('lnurlpData: ', lnurlpData);

  // returns nostr profile
  console.log('Nostr Profile: ', nostr);
});

getBalance

// Returns BTC balance in millisatoshis
Alice.getBalance('BTC').then((bal) => {
  console.log(`Account BTC Balance: ${bal} milisatoshis ~ ${(bal / 100000000).toFixed(8)} BTC`);
});

getTransactions

// Returns all transactions
Alice.getTransactions().then((transactions) => {
  console.log('Total account transactions: ', transactions.length);
});

Cards

Alice.addCard('CARD_NONCE');

Alice.getCards().then(async (cards) => {
  if (cards.length) {
    // Get first card
    let firstCard = cards[0];

    // Pause first card
    await firstCard.disable();

    // Add card limit -> 1000 satoshis every 12 hours
    await firstCard.addLimit({
      tokenId: 'BTC',
      limitType: 'hours',
      limitTime: 12,
      limitAmount: 1000000,
    });

    // Set card metadata (name, description)
    await firstCard.setMetadata({ name: 'card name', description: 'card description' });

    // Prepare the event to transfer the card
    const transferEvent = await firstCard.createTransferEvent();

    // Claim card with another account
    await Bob.claimCardTransfer(transferEvent);
  }
});

Payments

Alice.generateInvoice({ milisatoshis: 1000 }).then((invoice) => {
  // Generate payment request of this wallet
  console.log(invoice.pr);
});

Alice.createZap({ milisatoshis: 1000, receiverPubkey: Bob.pubkey }).then((invoice) => {
  // Generate zap request -> returns payment request of zap request
  const { pr: paymentRequest } = invoice;

  // Pay invoice
  Alice.payInvoice({
    paymentRequest,
    onSuccess: () => {
      console.log('Invoice paid successfully');
    },
  });
});

// Send transaction
Alice.sendTransaction({
  tokenId: 'BTC',
  receiver: '[email protected]',
  amount: 1000,
  comment: 'Hello!',
  onSuccess: () => {
    console.log('Transaction successfully sent');
  },
  onError: () => {
    console.log('An error occurred with the transaction');
  },
});

// Send internal transaction
Alice.sendInternalTransaction({
  tokenId: 'BTC',
  receiver: 'USER_HEX_PUBKEY',
  amount: 1000,
  comment: 'Hello!',
  onSuccess: () => {
    console.log('Transaction successfully sent');
  },
  onError: () => {
    console.log('An error occurred with the transaction');
  },
});

To - do

  • [x] Project startup (Linters, Typescript, Dependencies)

  • [x] Federation

  • [x] Identity

    • [x] Pubkey info
    • [x] Lightning Info
    • [x] Nostr Profile
  • [x] Card

    • [x] info (design, name, description)
    • [x] limits
    • [x] enable/disable
    • [x] setMetadata
    • [x] addLimit
    • [x] restartLimits
    • [x] replaceLimits
    • [x] createTransferEvent
  • [x] Wallet

    • [x] Signer + Identity
    • [x] Wallet Information
      • [x] getBalance
      • [x] getTransactions
      • [x] getCards
    • [x] signEvent
    • [x] createZap
    • [x] createInvoice
    • [x] sendTransaction
      • [x] send internal / lud16 / lnurl transfer
      • [x] onSuccess()
      • [x] onError()
    • [x] payInvoice
    • [x] claimCardTransfer
    • [x] addCard / activateCard
    • [x] registerHandle (request + payment + claim)
  • [ ] Tests coverage

    • [ ] Federation
    • [ ] Identity
    • [ ] Wallet