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

@moveflow/sui-sdk.js

v0.4.8

Published

Typescript SDK for MoveFlow on SUI blockchain

Downloads

64

Readme

Move-Flow SUI SDK

Introduction

Move-Flow is an crypto asset streaming protocol built in Move language on both Aptos and Sui blockchains.

Move-Flow is able to transfer assets on chain according to predefined rules. With one transaction, funds will flow from your wallet to the recipient real-time(by second), to conduct timely financial transactions without intermediaries..

This is the Typescript SDK for the protocol

You can find docs here

Installation

yarn add "@moveflow/sui-sdk.js"

Usage Example

Init SDK

import { Stream, Network } from "@moveflow/sui-sdk.js";

const stream = new Stream(Network.testnet);

Create a new payment stream

const coinType = "0x2::sui::SUI";
const name = "first";
const remark = "first sui stream";
const depositAmount = BigInt(10000000);
const startTime = Math.floor(Date.now() / 1000);
const duration = 24 * 60 * 60; // 1 day
const stopTime = startTime + duration;
const interval = 1; // 1 second
const senderAddress = "0x7905ae3ed4a5a77284684fa86fd83c38a9f138b0cc390721c46bca3aaafaf26c";
const recipientAddress = "0x45f5a96940e84dd876b1adc2c434961178fc94cb79c23a9f8ddc57c996255869";
const tx = await stream.createTransaction(
  coinType,
  name,
  remark,
  senderAddress,
  recipientAddress,
  depositAmount,
  startTime,
  stopTime,
  interval
);
const response = await wallet.signAndExecuteTransactionBlock({
  transactionBlock: tx,
  options: {
    showObjectChanges: true,
  },
});
const streamCreationResult = stream.getStreamCreationResult(response);

Withdraw payment from a stream

const tx = stream.withdrawTransaction(coinType, streamCreationResult.streamId);
const response = await wallet.signAndExecuteTransactionBlock({
  transactionBlock: tx,
});

Close a stream

const tx = stream.closeTransaction(
  coinType,
  streamCreationResult.senderCap,
  streamCreationResult.streamId
);
const response = await wallet.signAndExecuteTransactionBlock({
  transactionBlock: tx,
});

Pause a stream

const tx = stream.pauseTransaction(
  coinType,
  streamCreationResult.senderCap,
  streamCreationResult.streamId
);

const response = await wallet.signAndExecuteTransactionBlock({
  transactionBlock: tx,
});

Resume a stream

const tx = stream.resumeTransaction(
  coinType,
  streamCreationResult.senderCap,
  streamCreationResult.streamId
);
const response = await wallet.signAndExecuteTransactionBlock({
  transactionBlock: tx,
});

Query stream by streamId

const id = "0x1f612145242fde5b22ddf68838dce2d8cd5629a021caa2e4093a370548ab17a4";
const streams = await stream.getStreamById(id);
console.log("streams:", streams);

Query stream's withdrawable amount

const id = "0x1f612145242fde5b22ddf68838dce2d8cd5629a021caa2e4093a370548ab17a4";
const _stream = await stream.getStreamById(id);
const streams = await stream.withdrawable(_stream);
console.log("streams:", streams);

Query incoming streams

const address =
  "0xa84b01c05ad237727daacb265fbf8d366d41567f10bb84b0c39056862250dca2";
const streams = await stream.getStreams(address, StreamDirection.IN);
console.log("streams:", streams);

Query outgoing streams

const address = "0xa84b01c05ad237727daacb265fbf8d366d41567f10bb84b0c39056862250dca2";
const streams = await stream.getStreams(address, StreamDirection.OUT);
console.log("streams:", streams);

Query sender caps

const owner = "0xa84b01c05ad237727daacb265fbf8d366d41567f10bb84b0c39056862250dca2";
const caps = await stream.getSenderCap(owner);
const list = caps.data.map((m) => {
  return {
    cap: (m.data?.content as any).fields.id.id,
    stream: (m.data?.content as any).fields.stream,
  };
});

console.log("list:", list);

Query supported coins

const coins = await stream.getSupportedCoins();
console.log("coins:", coins);