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

sveeeth

v0.0.3

Published

A @wagmi/core wrapper built for Svelte

Downloads

196

Readme

sveeeth

A @wagmi/core wrapper built for Svelte that provides helpful store and utility functions.

Reactive stores to access useful connected wallet data.

import { connect, disconnect, account, network, contract } from "sveeeth";
import { Metamask, Walletconnect, ... } from "sveeeth/connectors";
import { mainnet, goerli, ... } from "sveeeth/chains";

For examples and code snippets, check out the example project.

Installation

Install sveeeth and its @wagmi/core dependency.

yarn add sveeeth @wagmi/core

npm install sveeeth @wagmi/core

🚗 Roadmap

  • [x] connect: Connect to wallet
  • [x] disconnect: Disconnect from wallet
  • [x] switchNetwork: Switch network
  • [x] account: The connected account details
  • [x] network: The connected network details
  • [x] contract: Create a contract instance
    • [x] Allow ENS to be passed in place of address
    • [x] Read/write function calls
    • [x] Listen for events
    • [ ] Automatic transaction simulation
  • [x] chains: re-exports everything from wagmi/core
  • [x] connectors: re-exports everything from wagmi/core
  • [x] ens: adding ens fetching and support
    • [x] Add edge case support for functions where the ENS should be sent raw (unfetched)
    • [ ] Reactive fetching of connected account ens data
  • [x] multicall: Add multicall support
  • [x] signing: Add message signing
    • [x] Support for signing typed data

📕 Docs

Functions

connect(args: ConnectArgs)

Connect to wallet, Accepts connector argument which is a Connector type which could be MetaMask, WalletConnect, Safe etc.

<script>
  import { connect } from "sveeeth";
  import { InjectedConnector } from "sveeeth/connectors";
</script>
<button on:click={() => connect({ connector: new InjectedConnector() })}>Connect</button>

disconnect()

<script>
  import { disconnect } from "sveeeth";
</script>
<button on:click={() => connect({ connector: Metamask })}>Connect</button>

contract({ address: Address, abi: Abi })

The contract function returns a store representing the state and the contract functions

<script>
  import { contract, account } from "sveeeth";
  import { daiAddress, daiAbi } from "...";

  $: dai = contract(daiAddress, daiAbi);
  $: balance = dai.balanceOf($account.address);
  $: console.log($dai.isLoading);
</script>

An ENS name can be passed to a function in place of an address and it will be automatically fetched before the function is called.

<script>
  // instead of this
  const balance = dai.balanceOf("0x360EF498A774998900da14E81b86E9200A400ecf");
  
  // we can do this
  const balance = dai.balanceOf("bbque.eth");
</script>

switchNetwork({ chain: Chain })

Switch to the specified network.

Global stores

account

Account store that returns an object with the account details. Object contains:

{ address: Address, isConnected: boolean, isDisconnected: boolean, isConnecting: boolean, connector: Connector }

<script>
  import { account, connect } from "sveeeth";
</script>

{#if $account.isConnected}
  <p>Account: $account.address</p>
{:else}
  <button on:click={() => connect({ connector })}>Connect</button>
{/if}

network

Store that has the network details in it.

<script>
  import { network } from "sveeeth";
  $: ({ chain, chains } = $network);
</script>

Utility stores

createSigner

Signer store that can be used to sign messages with the connected account. Object contains:

{ data: string | null, error: any, isLoading: boolean }

<script>
  import { createSigner } from "sveeeth";
  
  const signer = createSigner();
  
  const signMessage = async () => {
    await signer.sign({ message: "test message" });
  }
</script>

{#if $signer.isLoading}
  <p>Loading...</p>
{:else if $signer.data}
  <p>Signed data: {$signer.data}</p>
{:else}
  <button on:click={signMessage}>Sign</button>
{/if}

FAQ

Q) Is it pronounced Sveeeth or Sveeth?

A) Yes.