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

@myclique/governance-sdk

v0.4.0-alpha

Published

The SDK is provides easy access to the high level interactions to be governance with an Clique DAO.

Downloads

11

Readme

Clique JS governance SDK

@myclique/governance-sdk provides easy access to the high level interactions to be governance with an Clique DAO.

Installation

Use npm or yarn to install @myclique/governance-sdk.

npm install @myclique/governance-sdk
# or
yarn add @myclique/governance-sdk

# Usage

Context

The Context class is an utility component that holds the configuration passed to Clique instance.

import { Context, Clique, CChainId } from "@myclique/governance-sdk";

// Define
const context: Context = new Context({
  daoChainId: CChainId.POLYGON,
  daoAddress: "0x39fa22b4852119c62aabdd4523ac587481943c61",
  web3Providers: {
    [CChainId.ETH]: "https://rpc.ankr.com/eth",
    [CChainId.POLYGON]: "https://rpc.ankr.com/polygon",
    [CChainId.GOERLI]: "",
    [CChainId.POLYGON_MUMBAI]: "",
  },
});
// Test
const context: Context = new Context({
  daoChainId: CChainId.GOERLI,
  daoAddress: "0xadf89e38a2d189531c425e1f79db22b43889cb50",
  web3Providers: {
    [CChainId.ETH]: "https://rpc.ankr.com/eth",
    [CChainId.POLYGON]: "https://rpc.ankr.com/polygon",
    [CChainId.GOERLI]: "https://goerli.infura.io/v3/",
    [CChainId.POLYGON_MUMBAI]: "https://rpc.ankr.com/polygon_mumbai",
  },
});

const clique: Clique = new Clique(context);

// Update signer
context.set({ signer });
// or
clique.web3.useSigner(signer);

Get governance dao info

import { Clique, DaoInfoProp } from "@myclique/governance-sdk";

const clique: Clique = new Clique(context);
const daoInfo: DaoInfoProp | undefined = clique.daoInfo;
// if undefined
const daoInfo: DaoInfoProp = await clique.getDaoInfo();

Get governance dao token

import { Clique, DaoInfoProp, Token } from "@myclique/governance-sdk";

const clique: Clique = new Clique(context);

const daoToken: Token | undefined = await clique.getDaoToken();
// or
const daoInfo: DaoInfoProp | undefined = clique.daoInfo;
// const daoInfo: DaoInfoProp = await clique.getDaoInfo()
const daoToken: Token = daoInfo.token;

Create proposal

import {
  ProposalSignProp,
  ProposalVotingTypes,
} from "@myclique/governance-sdk";

const data: ProposalSignProp = await clique.getCreateProposalDataAndSignature(
  account
);
clique.createProposal(
  "title1",
  "introduction1",
  "content1",
  1664774069,
  1666033269,
  ProposalVotingTypes.MULTI,
  ["one", "two"],
  data
);

Get proposal list ids

import { ProposalStatus } from "@myclique/governance-sdk";

// get ids
const proposalListData: {
  total: number;
  proposalIds: number[];
} = await clique.getProposalListIds(ProposalStatus.OPEN, 0);

Get proposal info by proposal id

import { ProposalDetailProp } from "@myclique/governance-sdk";

const proposalDetail: ProposalDetailProp = await clique.getProposalInfo(1);

Cancel proposal

// To cancel proposal before closing
clique.cancelProposal(1);

Get account votes

import { AccountVotesInfo } from "@myclique/governance-sdk";

const votes: AccountVotesInfo = clique.getAccountVotesById(account, 1);

vote

import { ProposalSignProp } from "@myclique/governance-sdk";

const proposalId = 1;
const data: ProposalSignProp = await clique.getVotesDataAndSignature(
  account,
  proposalId
);
clique.proposalVote(proposalId, [0], [data.balance.raw.toString()], data, true);

Get proposal vote history

import { ProposalVoteHistory } from "@myclique/governance-sdk";

const list: {
  total: number;
  list: ProposalVoteHistory[];
} = await clique.getProposalVoteHistory(proposalId, 0, 8);