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

@suiet/wallet-adapter

v0.0.19

Published

Integration of Suiet Wallet into the Sui Wallet Adapter

Downloads

53

Readme

Suiet Wallet Adapter

⚠️ Deprecation Announcement: This package will not be maintained, please switch to our wallet-kit instead. Because Sui team has come up with a wallet-standard which introduces a standard way to integrate with wallets on Sui.

👋 If you want to know how to install/use suiet, please visit our offical website suiet.app or docs

Integrate your DApp with Suiet Wallet from now on 🥳

We've presented an adapter that implemented the interface of SUI Wallet Adapter for you✨ With this adapter, your DApp can easily connect with the Suiet Wallet Extension, which enables DApp to retrieve basic info of user's wallet and launch manipulation requests such as transaction signing.

1️⃣ First-choice integration guide

Try our @suiet/wallet-kit for easy integration with this adapter🥳

@suiet/wallet-kit is an all-in-one wallet connection kit with nice UI components for dapps , which connects your dapp with wallets on SUI and empowers your dapp with awesome wallet abilities🪄

2️⃣ Manual integration guide

For React DApps, the Sui team has provided React context provider and React hook in the npm package @mysten/wallet-adapter-react . Therefore we can simply register the Suiet Adapter into the official provider and then make use of them.

⚠️ Usage with React ONLY: We only support React DApp right now.

🚀 Get Started

Easy Integration with Suiet wallet kit

🔗 Quick start in minutes: https://kit.suiet.app/docs/QuickStart

Maunal Integration with SUI official kit

⚙️ Prerequisites

  1. A React project
  2. Install required npm packages
npm install @mysten/wallet-adapter-react @suiet/wallet-adapter

🚢 Use Sui wallet provider & Register Suiet adapter

// main.js
import {WalletProvider} from "@mysten/wallet-adapter-react";
import {SuietWalletAdapter} from "@suiet/wallet-adapter";

const supportedWallets = [
  {adapter: new SuietWalletAdapter()},
];

ReactDOM.createRoot(document.getElementById("root")).render(
  <React.StrictMode>
    <WalletProvider supportedWallets={supportedWallets}>
      <App/>
    </WalletProvider>
  </React.StrictMode>
);

✅ Retrieve data and launch manipulations

// App.jsx
import {useEffect} from "react";
import {useWallet} from "@mysten/wallet-adapter-react";

function App() {
  const {
    select,
    wallet,
    connected,
    connecting,
    disconnect,
    getAccounts,
    executeMoveCall,
  } = useWallet();

  useEffect(() => {
    if (!connected || !wallet) return;
    (async function () {
      console.log(wallet.adapter.name);
      const accounts = await getAccounts();
      console.log(accounts);
    })();
  }, [connected, wallet]);

  async function handleExecuteMoveCall() {
    await executeMoveCall({
      packageObjectId: "0x2",
      module: "devnet_nft",
      function: "mint",
      typeArguments: [],
      arguments: [
        "name",
        "capy",
        "https://cdn.britannica.com/94/194294-138-B2CF7780/overview-capybara.jpg?w=800&h=450&c=crop",
      ],
      gasBudget: 10000,
    });
  }

  return (
    <div className={'app'}>
      <h1>Current wallet: {wallet ? wallet.adapter.name : 'null'}</h1>
      <button
        onClick={() => {
          if (!connected) {
            select('Suiet');
          } else {
            disconnect();
          }
        }}
      >
        {connecting ? "connecting" : connected ? "Disconnect" : "connect"}
      </button>
    </div>
  )
}

There you go ✅ Go connect with our wallet with custom UI selector!

✨ Features

Sign Message

⚠️ Sui official react kit doesn't support this feature right now. You can try our @suiet/wallet-kit which fully support it and also many handful features

signMessage: (input: { message: Uint8Array }) => Promise<{
  signature: Uint8Array;
  signedMessage: Uint8Array;
}>

If you are using @suiet/wallet-kit, you can use signMessage function from hooks.

If you are using SUI official kit which has not supported this feature, you can try the below hack (when connected to Suiet Wallet):

Suiet Wallet version should >= 0.1.25

import {SuietWalletAdapter} from "@suiet/wallet-adapter";
import * as tweetnacl from 'tweetnacl'  // crypto lib for verify signature

const suietAdapter = new SuietWalletAdapter();

async function signMessage() {
  const result = await suietAdapter.signMessage({
    message: new TextEncoder().encode('Hello world')
  })

  const textDecoder = new TextDecoder()
  console.log('signMessage success', result)
  console.log('signMessage signature', result.signature)  // output -> Uint8Array
  console.log('signMessage signedMessage', textDecoder.decode(result.signedMessage).toString()) // Uint8Array of your raw message

  // verify signMessage with 
  const publicKey = await suietAdapter.getPublicKey()
  console.log('publicKey', publicKey)  // output -> Uint8Array(32)
  const isValidSignature = tweetnacl.sign.detached.verify(
    result.signedMessage,
    result.signature,
    publicKey,
  )
  console.log('verify signature with publicKey: ', isValidSignature)
}

💡 Demo playground

We also prepared a demo for developers, feel free to check it out:

🔗 Website: https://wallet-adapter-example.suiet.app/

🔗 Github Repo: https://github.com/suiet/wallet-adapter/tree/main/examples/sui-kit-integration