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

sui-svelte

v0.0.11

Published

[![npm version](https://badge.fury.io/js/sui-svelte.svg)](https://badge.fury.io/js/sui-svelte)

Downloads

24

Readme

Sui Svelte

npm version

Provides components for interacting with Sui wallets.

Showcase

SuiForge uses sui-svelte to interact with SUI wallets.

Setup

Barebones example:

routes/+page.svelte

<script lang="ts">
    import {ConnectButton} from "sui-svelte/ConnectButton"
    import {SuiModule, account, SuiModule} from "sui-svelte/SuiModule"
    
    // (Optional) Callback to call when a Sui account is connected
    const onConnect = () => {
        if (account.value) {
        console.log("Connected address: ", account.value.address)
        }
    }
</script>

<SuiModule {onConnect} />
<ConnectButton />
{#if account.value}
    <div>Connected address: {account.value.address}</div>
{/if}

Getting connected account

The account object exposes the connected account.

<script lang="ts">
   import { account } from "sui-svelte/SuiModule"

   console.log("Is account connected?", account.value !== undefined)
   if (account.value) {
       console.log("Connected account object:", account.value)
       console.log("Connected address:", account.value.address)
   }
</script>

Sending transactions

Refer to Sui guide on building transactions.

<script lang="ts">
   import { signAndExecuteTransactionBlock } from "sui-svelte/SuiModule"
   import { TransactionBlock } from "@mysten/sui.js/transactions"

   const sendTx = () => {
       const txb = new TransactionBlock()
       // Create a new coin with balance 100, based on the coins used as gas payment
       const [coin] = txb.splitCoins(txb.gas, [txb.pure(100)])
       // Transfer the split coin to a specific address
       txb.transferObjects([coin], txb.pure("0xSomeSuiAddress"))

       // Execute using sui-svelte
       signAndExecuteTransactionBlock(txb)
   }
</script>

Manually trigger connect modal

<script lang="ts">
   import { connectWithModal } from "sui-svelte/SuiModule"

   connectWithModal()
</script>

Customization

ConnectButton

Is a <button> componnet and can be customized by passing a class or styles prop.

<ConnectButton class="my-button-class" style="background: red;" />

ConnectModal

The modal for connecting can be customized by passing a "modal" slot to the SuiModule.

You should always open the modal using the ConnectButton or the connect exported method from SuiModule, since this starts the process that ends when resolve gets called.

<script lang="ts">
    import {SuiModule} from "sui-svelte/SuiModule"
    import {connectModal, resolve} from "sui-svelte/ConnectModal"
    import type { IWallet } from "@suiet/wallet-sdk"

    // Get the wallet from the browser
    func getWallet = (): IWallet  => {
        ...
        return suietWallet
    }

    // Call the modal resolve function with the wallet
    const selectWallet = () => {
        const wallet = getWallet()
        resolve.value(wallet)
    }

    // If closed, call the close method of connectModal
    const onClose = () => {
        connectModal.close()
    }
</script>

<SuiModule>
    <div slot="modal">
        <button onclick={onClose}> Close </button>
        <button onclick={selectWallet}> Select wallet </button>
    </div>
</SuiModule>

Issues and contributions

Feel free to submit PRs, or issues for any doubts or feature requests.

Contact

[email protected]