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

@renec-foundation/multisig-sdk

v1.0.15

Published

Snowflake Safe SDK - Interact with multisig wallets on Snowflake Safe

Downloads

19

Readme

Snowflake Safe SDK

Snowflake Safe SDK provides an easy way to interact with the Snowflake Safe app and onchain programs

Installation

Install with npm

npm i @snowflake-so/safe-sdk

Install with yarn

yarn add @snowflake-so/safe-sdk

Quick start guide

Initialize Snowflake

To create a new Snowflake service, we would need to initialize with the Provider.

// if your Anchor version is older than 0.24.2,
// please use Snowflake SDK version 1.0.11 and initialize the provider as below
let provider: Provider = Provider.local(API_URL);

// if your Anchor version is 0.24.2 or later,
// please use the latest version of Snowflake SDK and initialize the provider as below
let provider: Provider = AnchorProvider.local(API_URL);

The API_URL is the endpoint to the Solana cluster. Empty API_URL is pointed to the local testnet

  • Mainnet Beta: https://api.mainnet-beta.solana.com
  • Testnet: https://api.testnet.solana.com
  • Devnet: https://api.devnet.solana.com
let snowflakeSafe: SnowflakeSafe = new SnowflakeSafe(provider);

Fetch safe

Fetch safe onchain information by safe address

await snowflakeSafe.fetchSafe(safeAddress);

Fetch proposals of safe

Fetch all onchain proposals of the safe

await snowflakeSafe.fetchAllProposals(safeAddress);

Fetch proposal

Fetch onchain proposal information

await snowflakeSafe.fetchProposal(proposalAddress);

Fetch owned safes

Fetch all safes that the provided wallet owned

await snowflakeSafe.fetchOwnedSafes(ownerAddress);

Create a new safe

Create a new safe with one owner and approvals required as one

const input = {
  approvalsRequired: 1,
  owners: [owner],
};
const [newSafeAddress, txId] = await snowflakeSafe.createSafe(
  input.owners,
  input.approvalsRequired
);

Create a new proposal

Create a new proposal that can be executed by any safe owners

const response = await snowflakeSafe.createProposal(safeAddress, 'hello world', instructions);

Create a new recurring proposal

Create a new recurring proposal that can be executed automatically by Snowflake node operators

const proposal = new MultisigJobBuilder()
  .jobName('hello world')
  .jobInstructions(instructions)
  .scheduleCron('0 0 * * *')
  .build();

const [newProposalAddress, txId] = await snowflakeSafe.createRecurringProposal(
  safeAddress,
  proposal
);

Create a proposal with large payload

In production, there is proposal created with multiple actions which has bunches of accounts. This method is used to solve the issue

const [newProposalAddress] = await snowflakeSafe.createProposal(
  safeAddress,
  'hello world',
  instructions,
  [],
  DEFAULT_FLOW_SIZE,
  true,
  true // Set separatedActions parameter to true
);

Update an existing safe

Add owner proposal

The method will create a new instruction to propose adding new owner to the safe

const ix = await snowflakeSafe.createAddOwnerProposalInstruction(safeAddress, newOwner);

Remove owner proposal

The method will create a new instruction to propose removing an existing owner from the safe

const ix = await snowflakeSafe.createRemoveOwnerProposalInstruction(safeAddress, newOwner);

Change threshold proposal

The method will create a new instruction to propose changing threshold of the safe

const ix = await snowflakeSafe.createChangeThresholdProposalInstruction(safeAddress, newThreshold);

Approve a proposal

await snowflakeSafe.approveProposal(flowAddress);

Reject a proposal

await snowflakeSafe.rejectProposal(flowAddress);

Execute a proposal

await snowflakeSafe.executeProposal(flowAddress);

Abort a recurring proposal

await snowflakeSafe.abortRecurringProposal(flowAddress);

Build an once-off scheduled job

With Snowflake SDK, you can create a job with two line of code.

const job = new MultisigJobBuilder()
  .jobName('hello world')
  .jobInstructions(instructions)
  .scheduleOnce(tomorrow())
  .build();

Build a recurring scheduled job

Schedule a job that runs every minute for 10 times.

const job = new MultisigJobBuilder()
  .jobName('hello world')
  .jobInstructions(instructions)
  .scheduleCron('* * * * *', 10)
  .build();

Schedule a job that runs at 10:00 AM on the first day of every month .

const job = new MultisigJobBuilder()
  .jobName('hello world')
  .jobInstructions(instructions)
  .scheduleCron('0 10 1 * *')
  .build();

Build a program condition triggered job

Schedule a job that is triggered based on an arbitrary condition defined within the user program.

const job = new MultisigJobBuilder()
  .jobName('hello world')
  .jobInstructions(instructions)
  .scheduleConditional(1)
  .build();

Support

Struggle with the SDK integration?

If you have any problem with using the SDK in your system, drop a question our Snowflake Discord #sdk to receive a support from our engineers.

Find a bug or want to contribute to Snowflake?

If you find a bug or have any problem and idea while using the SDK, you can create an issue on SDK Github.

License

Apache Version 2.0