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 🙏

© 2025 – Pkg Stats / Ryan Hefner

swarm-io-governance

v0.2.5

Published

`npm install swarm-io-governance`

Downloads

31

Readme

Swarm Governance Component

npm install swarm-io-governance

Changelog

0.2.1 -> ... -> 0.2.5

NOTE - No changes to props or events in this version

  • [x] Styling updates
  • [x] New functionality: Transactions section, with transactions stored in local storage
  • [x] New functionality: notifications are now displayed giving the status of transactions
  • [x] Updated requests to work with API changes
  • [x] Bug fix to catch duplicated requests

0.2.0 -> 0.2.1

  • [x] Updates to docs

0.1.7 -> 0.2.0

  • [x] Removed democHash from the democracyDetails prop
  • [x] src20Address within democracyDetails is now tokenId
  • [x] Added a debugMode prop, which can be enabled during testing to log data to the console
  • [x] Event type signRequestEvent now passes an object instead of just the data to sign. This object contains a request type, type and data to sign, toSign
  • [x] Added new detailed example of how to handle the signRequestEvent

How to use

Install and register the component as per usual

<SwmGovernance
	:ioAdmin="<boolean: is the voter an admin of this democracy>"
    :debugMode="<boolean: debug mode>"
    :stellarPk="<stellar PK of voter>"
    :votingSk="<securely generated ethereum privkey for voting>"
    :democracyDetails="<object with details about the democracy>"
    :signResponse="<object that is updated following signature requests>"
    @signRequestEvent="<function responding to signature requests>"
/>

Props

  • ioAdmin Boolean not required - pass in true if the user is an admin of an IO, they will have the ability to create proposals
  • debugMode Boolean not required - pass in true which will log additional information to the console for testing
  • stellarPk String required - The public key corresponding to the users stellar address
	stellarPk: "GCFEX6MYIIHNY26CHTUVOTQWNUAQ3RWOKC2DBYW2MHLYYWAUR2HGWQLX",
  • votingSk String required - The HMAC deterministically generated voting secret key - this should be 32bytes as eth hex (0xa34b...)
	votingSk: "0x7d2479e16009181d2ed96b88352dad11cb321404f5f879b7d0e1c4c33b0a0aa3",
  • democracyDetails Object required - (in progress) object with the following parameters
    • name String - The name of the IO, this is only used to render the name within the component
    • tokenId String - the stellar reference to the token
    • votingNet String - either "mainnet" or "testnet" depending on whether the component is on staging production
democracyDetails: {
	name: "NIAH Fund",
	tokenId: "TBC",
	votingNet: "testnet" // should be either "mainnet" or "testnet"
},
  • signResponse Object - This object should be empty until a @signRequestEvent occurs, when the signature response object should be passed in after being signed. This object needs to contain:
    • request String - The delegation request that has been signed (see more below in the signRequestEvent section)
    • pubkey String - The stellar public key of the user
    • signature String - Signed request, 64 bytes in hex
const signResponse = {
    request,
    pubKey: kp.publicKey(),
    signature: sig.toString('hex')  // if it's a buffer
};

Events

  • signRequestEvent - The only event in the component so far. This event passes a signRequestObject which contains the request type and data requested to be signed. Full example of this signing below.
{
    type: String, // Will be either "proposal" or "delegation"
    toSign: String
};

Example signRequestEvent

The signRequestEvent example below has been created using the stellar-base library

methods: {
		onSignRequest(request) {
			// Check to see if the request type is a delegation or proposal
            switch (request.type) {
                case 'delegation':
                    return this.handleDelegationSign(request);
                case 'proposal':
                    return this.handleProposalSign(request);
                default:
                    throw new Error('Invalid request type')
            }
        },

        handleDelegationSign (request) {
            const { toSign, type } = request
            // Request should be 32 bytes + 0x prefix = 66 character
            if (toSign.length !== 66) {
                throw new Error('Request is not the correct length');
            }
            // Grab first 9 bytes + 0x which makes up the first part of the prefix (next 3 bytes are the nonce)
            const prefix = toSign.substring(0, 20);
            const knownPrefix = 'SV-ED-ETH';
            const knownPrefixHex = web3.utils.toHex(knownPrefix);
            if (prefix !== knownPrefixHex) {
                throw new Error('Prefix is not correct');
            }
            // Sign the data to sign
            const kp = StellarBase.Keypair.fromSecret(this.stellarSk);
            const sig = kp.sign(toSign);
            // Create a sign response object with the request, type, public key and signature in hex format
            const signResponse = {
                toSign,
                type,
                pubKey: kp.publicKey(),
                signature: sig.toString('hex'),
            };
            // Pass the signed object back to the swarm governance component
            this.signResponse = signResponse;
        },

        handleProposalSign (request) {
            const { toSign, type } = request
            // toSign will be a stringified JSON ballotSpec object - parse it to check the contents
            const parsed = JSON.parse(toSign)
            // Check to make sure it has the required properties
            if (!parsed.hasOwnProperty('ballotInner') || !parsed.hasOwnProperty('optionsInner') || !parsed.hasOwnProperty('subgroupInner')) {
                throw new Error('Ballot requested for signing does not contain the required properties')
            }

            // Sign the 'toSign' string
            const kp = StellarBase.Keypair.fromSecret(this.stellarSk);
            const sig = kp.sign(toSign);

            // Create a sign response object with the request, type, public key and signature in hex format
            const signResponse = {
                toSign,
                type,
                pubKey: kp.publicKey(),
                signature: sig.toString('hex'),
            };
            // Pass the signed object back to the swarm governance component
            this.signResponse = signResponse;
        }

}