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

svelte-fuels

v0.94.9-next.1

Published

A thin wrapper around the Fuels SDK for Svelte with a focus on reactivity

Downloads

19

Readme

Svelte-Fuels

Svelte-Fuels is a package that provides a collection of Svelte stores and functions for integrating authentication using Fuels with Svelte. It utilizes the Fuels SDK for wallet management and transaction signing.

Installation

To install the package and its peer dependencies, run the following command:

npm install svelte-fuels

Important Note

To work with the latest Fuel testnet node upgrades, you can install the nightly next version with:

npm install svelte-fuels@next

This will install with fuels@next (currently 0.94.0) release.

Usage

To initialize the package, you can simply wrap you layout slot in the provided WalletProvider component.

Basic Example

<script>
  import { WalletProvider } from 'svelte-fuels';
</script>

<WalletProvider>
  <slot />
</WalletProvider>

Using Custom Connectors

<script>
  import { WalletProvider } from 'svelte-fuels';
  import { WalletConnectConnector, WalletConnectConfig } from '@fuels/connectors';

  const config = new WalletConnectConfig({
    fuelProvider?: {} // Fuel provider
    projectId?: "" // Your wallet connect project id
    wagmiConfig?: {} // Wagmi config
    predicateConfig?: {} // Predicate config
  });
</script>

<WalletProvider connectors={[new WalletConnectConnector(config)]}>
  <slot />
</WalletProvider>

And in your wallet handler, you can use the connect function to connect to a Fuel provider by passing the connector name.

<script>
  import { connect } from 'svelte-fuels';

  async function handleConnect() {
    await connect("Ethereum Wallet");
  }
</script>

Stores

  • connected: Indicates whether the application is currently connected to a Fuel provider. It is a boolean store.
  • account: Contains the wallet address of the connected account. It is a string store.
  • wallet: Contains the wallet instance. It is an object store.
  • fuel: Contains the Fuel instance. It is an object store.

Functions

  • createWalletStore: Initializes the wallet store. Call this function to set up the wallet connection.
  • disconnect: Disconnects the current wallet.
  • connect: Connects to a Fuel provider.

Example Usage

connected

The connected store indicates whether the application is currently connected to a Fuel provider.

<script>
  import { connected } from 'svelte-fuels';
</script>

{#if $connected}
  <p>Connected to Fuel</p>
{:else}
  <p>Not connected to Fuel</p>
{/if}

account

The account store contains the wallet address of the connected account.

<script>
  import { account } from 'svelte-fuels';
</script>

{#if $account}
  <p>Wallet Address: {$account}</p>
{:else}
  <p>No wallet connected</p>
{/if}

wallet

The wallet store contains the wallet instance.

<script>
  import { wallet } from 'svelte-fuels';
</script>

{#if $wallet}
  <p>Wallet is initialized</p>
{:else}
  <p>No wallet available</p>
{/if}

fuel

The fuelStore store contains the Fuel instance.

<script>
  import { fuelStore } from 'svelte-fuels';
</script>

{#if $fuelStore}
  <p>Fuel instance is available</p>
{:else}
  <p>No Fuel instance</p>
{/if}

createWalletStore

The createWalletStore function initializes the wallet store. Call this function to set up the wallet connection.

<script>
  import { createWalletStore } from 'svelte-fuels';

  createWalletStore();
</script>

disconnect

The disconnect function disconnects the current wallet.

<script>
  import { disconnect } from 'svelte-fuels';

  function handleDisconnect() {
    disconnect();
  }
</script>

<button on:click={handleDisconnect}>Disconnect from Fuel</button>

connect

The connect function connects to a Fuel provider.

<script>
  import { connect } from 'svelte-fuels';

  async function handleConnect() {
    await connect();
  }
</script>

<button on:click={handleConnect}>Connect to Fuel</button>

Using Fuels Types

All exports from the fuels-ts package are available through direct import.

<script>
  import { Signer } from 'fuels';
</script>

<!-- ... -->

Roadmap

This is a basic package created for projects that require authentication using Fuels with Svelte. Additional features can be added based on community feedback and requirements.