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

@sqds/fuse-wallet

v0.1.3

Published

Types and helpers for interacting with the Fuse wallet through the Wallet Standard interface.

Downloads

14

Readme

@sqds/fuse-wallet

Types and helpers for interacting with the Fuse wallet through the Wallet Standard interface.

Installation

yarn add @sqds/fuse-wallet

Motivation

The Fuse wallet is a browser extension that implements the Wallet Standard interface. Unlike regular wallets that can only sign transactions using an imported private key, Fuse is a Smart Wallet powered by the Squads Multisig Program. With Fuse, users can create and manage multisig accounts, as well as effortlessly create multisig transactions by interacting with dapps as they used to using regular wallets.

Multisig transactions are different from regular transactions in that they require multiple parties to approve them before they can be executed. This means that creating and executing a transaction is a multi-step process that is separated in space and time. To ensure that their apps are 100% compatible with Fuse and other Smart Wallets, app developers sometimes need to take special considerations.

To help with this, Fuse exposes a set of custom features through the Wallet Standard interface. These features can be detected and used by the app developers even without this package. This package just provides a set of types and helpers to make it easier to work with these features.

Usage

import {hasGetEphemeralSignersFeature, FuseGetEphemeralSignersFeatureIdentifier} from "@sqds/fuse-wallet";

// walletAdapter: Adapter = ...

if ("standard" in walletAdapter && hasGetEphemeralSignersFeature(walletAdapter.wallet)) {
  // Get two ephemeral signer addresses.
  const ephemeralSigners = await walletAdapter.wallet
    .features[FuseGetEphemeralSignersFeatureIdentifier /* "fuse:getEphemeralSigners" */]
    .getEphemeralSigners(2)

  const ephemeralSigner1 = new PublicKey(ephemeralSigners[0])
  const ephemeralSigner2 = new PublicKey(ephemeralSigners[1])
  
  // Use `ephemeralSigner1` and `ephemeralSigner2` public keys in your transaction.
  // You can assume that they will sign the transaction, so you don't need to add them as signers explicitly.
}

Usage without this package

If you have concerns regarding adding another dependency to your project, we got you covered. The API is exposed by the Fuse extension through the Wallet Standard interface, so you can detect it yourself with the code below. The only downside is that you will have no TypeScript completion for the features.

// walletAdapter: Adapter = ...

if ("standard" in walletAdapter && ("fuse:getEphemeralSigners" in walletAdapter.wallet.features)) {
  // Get two ephemeral signer addresses.
  const [ephemeralSigner] = await walletAdapter.wallet
    .features["fuse:getEphemeralSigners"]
    .getEphemeralSigners(1)
}

Features

fuse:getEphemeralSigners

This feature allows the app to request a set of ephemeral signers from the wallet.

Ephemeral signers are keys that are expected to sign the transaction and be discarded right after. An example of when such ephemeral signers are needed is the SystemProgram.createAccount instruction. This instruction requires the new account to be a signer to verify that whoever calls this instruction actually holds authority over this account.

The Keypair.generate() method is typically used by app developers to create ephemeral signers, but this mechanism doesn't work with Smart Wallets that don't execute the transaction immediately. In these cases, the ephemeral keypair will not be available to sign the "execute" transaction because it has already been "forgotten".

To solve this problem, getEphemeralSigners(numberOfSigners) allows apps to request any number of ephemeral signers from the wallet. The wallet returns an array of public keys that the app developer can use in their transactions.

The implementation of this feature can vary depending on the type of wallet being used. For instance, for a Multisig wallet, an ephemeral signer is a PDA owned by the Multisig Program, enabling the Program to sign the transaction on behalf of that account. Meanwhile, for a regular wallet, it can be a keypair generated by the wallet itself and stored securely in the extension's background storage over the course of the browser session.

Regardless of the implementation, the app developer doesn't have to worry about how an ephemeral signer was generated; they can assume that the public key will be a signer of the transaction.