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

spl-governance-multisig

v1.0.2

Published

``` import { MultiSig } from "spl-governance-multisig"; import { Connection, Keypair } from "@solana/web3.js"; import { airdrop, sendSolToMultiSigWallet } from "./airdrop";

Downloads

16

Readme

SPL Governance Multisig SDK

import { MultiSig } from "spl-governance-multisig";
import { Connection, Keypair } from "@solana/web3.js";
import { airdrop, sendSolToMultiSigWallet } from "./airdrop";

// local validator
const clusterUrl = "http://127.0.0.1:8899";

const connection = new Connection(clusterUrl, {
  commitment: "confirmed",
});

// Signers
const payer = Keypair.generate();
const signerOne = Keypair.generate();
const signerTwo = Keypair.generate();
const signerThree = Keypair.generate();

// Payer's instance of Multisig (Payer will instantiate the multisig)
const payerInstance = new MultiSig(connection, payer);

// Signer One's instance of Multisig (Signer One will create the SOL Transfer Tx and sign it)
const signerOneInstance = new MultiSig(connection, signerOne);

// Signer Two's instance of Multisig (Signer Two will be the second signer of the tx)
const signerTwoInstance = new MultiSig(connection, signerTwo);

// Signer Three's instance of Multisig (Signer Two will be the third signer of the tx)
const signerThreeInstance = new MultiSig(connection, signerThree);

(async() => {
  await airdrop(payer, connection);
  await airdrop(signerOne, connection);
  await airdrop(signerTwo, connection);
  await airdrop(signerThree, connection);

  // Create 2-of-3 Multi Sig Wallet (by Payer)
  const {
    txSignature:createMultisigSignature, 
    multiSigKey, 
    multiSigWallet
  } = await payerInstance.createMultisig(
    2,
    [
      signerOne.publicKey, 
      signerTwo.publicKey, 
      signerThree.publicKey
    ]
  );

  console.log("Tx Signature for the Multi Sig Creation:", createMultisigSignature)
  console.log("Multisig Key:", multiSigKey.toBase58())

  await sendSolToMultiSigWallet(payer, multiSigWallet, connection);

  // Internal instruction for the multisig transaction
  const getSolTrfIx = signerOneInstance.getSolTransferInstruction(multiSigKey, 0.12, payer.publicKey)
  
  // Create and Sign Multi Sig Transaction (by Signer One)
  const {
    txSignature: createTransactionSignature,
    transactionKey
  } = await signerOneInstance.createTransaction(
    multiSigKey,
    "Transfer 0.12 SOL to Payer's Wallet",
    [getSolTrfIx]
  )

  console.log("Tx Signature for the Transaction Creation: ", createTransactionSignature)
  console.log("Transaction Key", transactionKey.toBase58())
  
  const firstTxStatus = await payerInstance.getTransaction(transactionKey)
  console.log(firstTxStatus)

  try {
    // We are trying to execute the transaction after the first vote, it should fail
    const tryExecuteSig = await signerTwoInstance.executeTransaction(transactionKey)
    console.log(tryExecuteSig)
  } catch(e) {
    console.log("Execution Error: ", e)
  }

  // Reject the tx from Signer Two's wallet
  const rejectTxSignature = await signerTwoInstance.rejectTransaction(multiSigKey, transactionKey)
  console.log("Tx Signature for the Rejected Transaction: ", rejectTxSignature)
  
  const secondTxStatus = await payerInstance.getTransaction(transactionKey)
  console.log(secondTxStatus)

  // Approve the tx from Signer Three's wallet
  const approveTxSignature = await signerThreeInstance.approveTransaction(multiSigKey, transactionKey)
  console.log("Tx Signature for the Approved Transaction: ", approveTxSignature)

  // Add some delay before execution
  await new Promise(resolve => setTimeout(resolve, 2000))

  // Since the Tx has received 2-of-3 votes, it should execute now
  const tryExecuteSig = await signerThreeInstance.executeTransaction(transactionKey)
  console.log("Tx Signature for the Transaction Execution: ", tryExecuteSig)

  // Fetch all the transactions for the multisig
  const transactions = await signerThreeInstance.getTransactionsForMultisig(multiSigKey)
  console.log(transactions)
})()