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

vue-sui

v1.9.0

Published

Vue component to connect your dapp to Sui blockchain

Downloads

269

Readme

vue-sui

Vue component to connect your dapp to Sui blockchain.

Includes suidouble library for easier interaction with Move smart contracts.

Demo

demo page

installation

npm install vue-sui --save

usage

There're two components defined. Styled one:

import { SignInWithSuiButton } from 'vue-sui';

and basic handler displaying just text in spans you can put into any button or call via method:

import { SignInWithSui } from 'vue-sui';

<template>
    <button @click="this.$refs.sui.onClick();"><SignInWithSui ref="sui" /></button>
</temlate>

you can also hide displaying text at all, keeping methods functionality:

import { SignInWithSui } from 'vue-sui';

<template>
    <button @click="this.$refs.sui.onClick();">Connect to Sui</button>
    <SignInWithSui ref="sui" :visible="false" />
</temlate>

events

Both SignInWithSui and SignInWithSuiButtons emit very same set of events. Basically SignInWithSuiButtons is just a styled wrapper over SignInWithSui. So feel free to use any.

Client: client

Emits an instance of Sui's SuiClient class connected to the defaultChain blockchain. Usually it's emited very soon after SignInWithSui component is mounted (and doesn't require user to connect her/his wallet), and lets you interact with blockchain in read-only way right after the page load:

<SignInWithSui @client="onClient" defaultChain="sui:mainnet" />

onClient = async (client) => {
    const data = await client.getObject({id: '0xcc2bd176a478baea9a0de7a24cd927661cc6e860d5bacecb9a138ef20dbab231'});
}

Adapter: adapter

Emits an instance of SuiInBrowserAdapter, which follows the logic of StandartAdapter with functions of signAndExecuteTransaction, signTransaction, signAndExecuteTransactionBlock, signTransactionBlock, signMessage, and disconnect. Note that disconnect is not always available (there's no in Sui Wallet) and you may have to ask users to sign off directly in wallet extension.

<SignInWithSuiButton @adapter="onAdapter" defaultChain="sui:mainnet" />

onAdapter = async (adapter) => {
    const tx = new sui.Transaction();
    const data = await adapter.signAndExecuteTransaction({transaction: tx});
}

SuiMaster: suiMaster

Instance of high-level Sui smart contracts library - suidouble for interaction with smart contracts. Emited on initialization or when defaultChain parameter changed with instance of of suidouble SuiMaster, to let you interact with blockchain in read-only mode:

<SignInWithSuiButton @suiMaster="onSuiMaster" defaultChain="sui:mainnet" />

async onSuiMaster(suiMaster) {
    const currentChain = suiMaster.connectedChain; // chain id, `sui:mainnet`  `sui:testnet` etc
    const instanceN = suiMaster.instanceN; // you may get few events when state changed, so you may check if it's same instance you had before

    // and interact with blockchain. Read more in suidouble documentation
    const pkg = suiMaster.package({
        id: packageId,
    });
    const module = await pkg.getModule('suidouble_color');

    const eventsResponse = await module.fetchEvents({eventTypeName: 'ColorCreated', order: 'descending'});
    // if you are connected, you can also execute contract methods:
    let result = await module.moveCall('mint', [...]);
    // etc
}

Connected: connected

Emited when use allows access to signing txs with her/hist wallet browser extension. Pass the instance of suidouble's SuiInBrowser class as a parameter:

<SignInWithSuiButton @connected="onConnected" />

async onConnected(suiInBrowser) {
    const suiClient = await suiInBrowser.getClient(); // instance of SuiClient
    const suiMaster = await suiInBrowser.getSuiMaster(); // instance of suidouble SuiMaster instance
    const currentChain = suiInBrowser.getCurrentChain(); // chain id, `sui:mainnet`  `sui:testnet` etc
    const connectedAddress = suiInBrowser.getAddress(); // "0x42ff3..."
}

Note: it's emited when use switch chain in her/his wallet extension too. So you may get few events in the lifetime of application.

Disconnected: disconnected

<SignInWithSuiButton @disconnected="onDisconnected" />

onDisconnected() {
    // connectedAddress is null now
}

properties

defaultChain

chain to require connection too. Possible options are: sui:mainnet sui:devnet sui:testnet sui:local

<SignInWithSuiButton defaultChain="sui:mainnet" />