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

turing-wallet-provider

v1.0.4

Published

A provider that makes interacting with Turing Wallet a walk in the park.

Downloads

37

Readme

Turing Wallet Provider

Description

The Turing Wallet Provider simplifies the process of integrating Turing Wallet into your react application by creating a provider that wraps your application.

Installation

Install the package using npm/yarn:

npm install turing-wallet-provider
yarn add turing-wallet-provider

Usage

Setup the Provider

First, wrap your application with the TuringProvider.

//... other imports
import { TuringProvider } from "turing-wallet-provider";

const root = ReactDOM.createRoot(
  document.getElementById("root") as HTMLElement
);
root.render(
  <TuringProvider>
    <App />
  </TuringProvider>
);

Use the Wallet Hook

You can now use the useTuringWallet hook to interact with the wallet.

import { useTuringWallet } from 'turing-wallet-provider';

function YourComponent() {
  const wallet = useTuringWallet();
  const isReady = wallet.isReady;
  console.log(isReady);
  // true

  return (
    // Your TSX
  );
}

Provider Api

GettingAdresses & Public Keys

After establishing a connection, you'll likely need to know the user's addresses and public keys at some point.

const { tbcAddress, ordAddress, identityAddress } = await wallet.getAddresses();
const { tbcPubKey, ordPubKey, identityPubKey } = await wallet.getPubKeys();
Send TBC

Before send TBC to a Bitcoin address(es), you may simply pass an array of payment objects.

const paymentParams: = [
  {
    satoshis: 10000,
    address: "18izL7Wtm2fx3ALoRY3MkY2VFSMjArP62D",
  },
  {
    satoshis: 54000,
    address: "1q6td54oZU8EPM1PwJcB1Z6upPyMe3Vy2",
  },
];
const { txid, rawtx } = await wallet.sendTbc(paymentParams);
Get UTXOs
const utxos = await wallet.getPaymentUtxos();
Get Social Profile

After establishing a connection, your application may want to pull in certain social preferences like a user Display Name or Avatar.

const { displayName, avatar } = await wallet.getSocialProfile();
Get Balance
const { tbc, satoshis, usdInCents } = await wallet.getBalance();
Get Exchange Rate

Fetch the TBC exchange rate in USD.

const rate = await wallet.getExchangeRate();
Disconnect the Provider

Turing Wallet will whitelist the requesting applications domain. To sever this connection you can simply call disconnect().

await wallet.disconnect()
Broadcast Raw Tx

You will need to pass an object that contains the rawtx:

{
    rawtx: string
    fund?: boolean;
}

Passing the optional fund param will add and sign inputs from the user's Turing Wallet along with calculating and applying the appropriate change for the tx.

const param = {
  rawtx:"xxx",
};
const txid = await wallet.broadcast(param);
Sign Message

To transmit a message for user signing you must pass an object that contains a message. You can also pass an optional encoding param for more advanced signings:

{
  message: string;
  encoding?: "utf8" | "hex" | "base64" ;
};
const message = { message: "Hello world" };
const response = await panda.signMessage(message);
Get Signatures
  const sigRequests: SignatureRequest[] = [
  { 
    prevTxid: 
    outputIndex: 0,
    inputIndex: 0,
    satoshis: 1,
    address: 
  },
  { 
    prevTxid: 
    outputIndex: 0,
    inputIndex: 1,
    satoshis: 1000,
    address: 
    script: 
  }
];

const sigResponses: SignatureResponse[] = await wallet.getSignatures({
  rawtx: 
  sigRequests
});

Demo

turing-wallet-sample