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

@msafe/mpay-sdk-sui

v1.0.26

Published

MPay SDK on SUI

Downloads

982

Readme

mpay-sdk-sui

SDK for MPay on Sui

Install

yarn add @msafe/mpay-sdk-sui

Use SDK

Initialize mpay client

import {MPayClient} from "@msafe/mpay-sdk-sui";

// Env.prod refer to mainnet environment
// Env.dev refer to testnet environment
// Env.unit refer to unit test environment
const client = new MPayClient(Env.prod)

Connect a wallet

// Connect single signer wallet
client.connectSingleWallet(singleWallet);

// Connect MSafe multi-sig wallet (To be tested)
client.connectMSafeAccount(msafe)

Create a stream

const txb = await client.createStreams(info);
const res = await wallet.signAndExecuteTransactionBlock(txb);
const streamIds = client.helper.getStreamIdsFromCreateStreamResponse(res);
if (streamIds === 1) {
    const streams = Stream.new(client.globals, streamIds[0]);
} else {
    const streamGroup = StreamGroup.new(client.globals, streamIds);
    const streams = streamGroup.streams;
}

Stream detail information

const info = await stream.info;
console.log(info);

const progress = await stream.progress;
console.log(progress);

Stream operations

// Cancel stream
const txb = await stream.cancel();
const res = await wallet.signAndExecuteTransactionBlock(txb);

// Claim stream
const txb = await stream.claim();
const res = await wallet.signAndExecuteTransactionBlock(txb);

// Set auto claim
const txb = await stream.setAutoClaim(true);
const res = await wallet.signAndExecuteTransactionBlock(txb);

// Claim by proxy
const txb = await stream.claimByProxy();
const res = await wallet.signAndExecuteTransactionBlock(txb);

Stream list

Incoming streams

const it = await client.getIncomingStreams({
    status: 'STREAMING' | 'STREAMED',
    sender: someSender,
});

while (await it.hasNext()) {
    const sts = await it.next();
    sts.forEach((st) => {
        if (st.type === 'Stream') {
            console.log((st as Stream).info);
        } else if (st.type === 'StreamGroup') {
            console.log((st as StreamGroup).info);
        }
    })
}

Outgoing streams

const it = await client.getOutgoingStreams({
    status: 'STREAMING' | 'STREAMED',
    recipient: someAddress,
});

while (await it.hasNext()) {
    const sts = await it.next();
    sts.forEach((st) => {
        if (st.type === 'Stream') {
            console.log((st as Stream).info);
        } else if (st.type === 'StreamGroup') {
            console.log((st as StreamGroup).info);
        }
    })
}

Appendix

Deploy contract (temp)

  1. Clone mpay-core-sui.
  2. Change your sui profile to unit environment and use this environment.
  - alias: unit
    rpc: "http://ec2-54-241-42-141.us-west-1.compute.amazonaws.com:9000"
    ws: ~
  1. Deploy to unit test environment
yarn deploy-skip-test

To generate transactions

  1. Clone this repo
  2. Copy published/unit.json from mpay-core-sui to this repo config/unit.json
  3. yarn install
  4. yarn integration

All kinds of transactions will be generated with printed transaction digest in terminal. Use the transaction for development or debugging process.