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

test-maven-sdk

v1.0.3

Published

sdk to interact with echo safe smart contract

Downloads

24

Readme

Start a localnet and deploy contract

  1. Install SUI and add to path. Build SUI location.
yarn deps

If there is any issue regarding installation with rust, please check out the prerequisites and requirements in Sui official installation guide.

  1. Start SUI localnet
yarn localnet
  1. Clone ESafe repo

Clone ESafe repository to directory ../ESafe.

The repository need to be located at location ../ESafe

  1. Deploy ESafe smart contract

Go to Maven-SDK, deploy ESafe contract to localnet.

yarn deploy

At the end of execution, two contract addresses are given:

contract address of ./move: 0x5691dd8cec80295b52817695a2c53598817332c276ae58d46bfc3643b1d64d05
global_pause of ./move: 0xcf540a9fa0da8ce7b15b6504f1e1668b731f727f002cfa0541a136e3c5223bf6
  1. Copy the addresses to SDK repo

The target contants is stored at src/constants/maven.ts.

Both the address need to be replaced.

  1. Run tests to verify
yarn test

All tests shall pass.

=======

Doc

High Level Operations

Init

// implement a customized signer by using browser wallet
class WebSigner extends SignerProvider {}

// instantiate provider and clientt
const signerProvider = new WebSigner(CHAIN_ID);
const client = new TreasuryClient(signerProvider);

Create

//create a treasury with only one owner, which is the creator itself
const {treasury} = await client.create("Treasury")

CreateWithOwners

//create a treasury with two owners, the creator itself and account2
const account2 = await createKeypair();
const {treasury} = await client.createWithOwners("Test", [account2.getPublicKey().toSuiAddress()], 2, "");
//create from existing treasury
client.getTreasuryFromId("1", "2")

Treasury Information Read

//read the permissions of the treasury
await treasury.permissionBook()
//read the roles of the treasury
await treasury.roles()
//get the treasury owned coins
await treasury.ownedCoins()
//get all proposed transactions
await treasury.pendingTransactions()
//get treasury owners
await treasury.owners()
//get treasury threshold
await treasury.threshold()

DepositCoin

//deposit some amount of coin into the Treasury
await treasury.depositCoin(1000n, "0x02::sui::SUI");
//deposit multiple coins
await treasury.depositCoins([10n, 10n], ["0x02::sui::SUI", "dummyCoin"]);

TransferCoin

await treasury.proposeTransferCoin("0x02::sui::SUI", "0xreceiver", 1000n)

//transfer coins
await treasury.proposeTransferCoins([{coin: "dummyCoin", amount: 1n, receiver: "dummyReceiver"}])

DepositObject

//deposit object to treasury
await treasury.depositObject("1");
//depost multiple objects to treasury
await treasury.depositObjects([{objectId: "1"}])

TransferObject

//transfer object
await treasury.proposeTransferObject("id", "receiver");
//transfer multiple objects
await treasury.proposeTransferObjects([{id: "id", receiver: "receiver"}])

Simulation

//simulate single coin transfer
await treasury.transferCoin("dummyoin", "receiver", 100n, {simulation: true})
//simulate multiple coin transfer
await treasury.transferCoins([
  {coin: "coin1", receiver: "receiver", amount: 1n},
  {coin: "coin2", receiver: "receiver", amount: 1n},
], {simulation: true})

Update Threshold / Owners

await treasury.updateTreasury({addedOwners: ["a"], removedOwners: ["b"], threshold: 10})

Get wallet coins

// To be deprecated
await client.coinList()

Helper functions

await client.helper.coinList(address);
await client.helper.getBalance(owner, "0x2::sui::SUI");
await client.helper.getOwnedObjects(owner)
await client.helper.getCoinMeta(coinType);
await client.helper.isMavenAccount(mavenAddress);
await client.helper.isSuiAddress("0x123");