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

@ape.swap/governance-sdk

v0.2.1

Published

A collection of solidity smart contracts to help manage the ApeSwap DAO.

Downloads

15

Readme

ApeSwap Governance SDK

Useful SDK for encoding transactions sent to timelock contracts used in the ApeSwap protocol. These timelock contracts are Open Zeppelin's implementation which integrates very well with DAO governance mechanisms.

Install

Click "Use as Template" to create a repo on GitHub based on this repo. Otherwise:
git clone [email protected]:DeFiFoFum/truffle-typescript-template.git

yarn install

Setup

Create a .env file based off of .env.example to deploy contracts to bsc mainnet/testnet and to verify deployed contracts.

Package Install

This repo also provides a helper module for interacting with the ApeSwap Governance contracts with node via a front-end or back-end framework.

yarn add @ape.swap/governance-sdk
cd governance-sdk
yarn install

Usage

Provided below is an example of importing the and using the provided library to encode a batch timelock tx.

import { TimelockLib } from '@ape.swap/governance-sdk';
const timelockEncoder = new TimelockLib.TimelockEncoder();


async function encodeMessageTx(message: string, { address = ADDRESS_0 }): Promise<PopulatedTransaction> {
    const messageBoardContract = new Contract(address, MessageBoardBuild.abi) as MessageBoard;
    const populatedTx = await messageBoardContract.populateTransaction.addMessage(message);
    return populatedTx;
}

async function encodeBatchTimelockMessageTx(messages: string[], { timelockAddress = ADDRESS_0, messageBoardAddress = ADDRESS_0, predecessor = BYTES_32_0, salt = BYTES_32_0, delay = 20 }): Promise<BatchEncodeReturn> {
    const timelockEncoder = new TimelockEncoder(timelockAddress);

    const targets: string[] = [];
    const datas: string[] = [];
    const values: string[] = [];
    for (const message of messages) {
        const populatedTx = await encodeMessageTx(message, { address: messageBoardAddress });
        targets.push(populatedTx.to || '0x');
        datas.push(populatedTx.data || '0x');
        values.push('0');
    }

    return await timelockEncoder.encodeTxsForBatchOperation({ targets, values, datas, predecessor, salt }, delay);
};

Development

Start a local development blockchain by running the following command:
yarn ganache

Deploy contracts to the development blockchain:
yarn migrate:dev

Compile

yarn compile

Deploy

Mainnet

yarn migrate:bsc [--reset] // Use --reset to redeploy already deployed contracts
yarn verify:bsc

Testnet

yarn migrate:testnet [--reset]
yarn verify:testnet

* new contracts that are created must be added to the verification script in package.json by adding && to the end with the new contract verification.

Lint

Lint with solhint
yarn lint / yarn lint:fix

Test

Tests are run with @openzeppelin test environment. This allows tests to be run independently of an external development blockchain.

Test the project with yarn test

Tests are using
@openzeppelin/test-helpers
@openzeppelin/test-environment

Solidity Doc Gen

yarn gen:docs solidity-docgen can be used in this repo to scrape NatSpec comments into markdown files for easy document generation.

This module uses the solc package to generate the documents. If the compiler is changed, ensure that the correct solc version is installed: yarn add [email protected]

Solidity Coverage

solidity-coverage is used in this repo to provide an output of the test coverage after running tests.

Automated Tests

The OpenZeppelin test environment coupled with Github actions facilitates automated contract tests on pushes to GitHub!

Generate Types from Contracts

Use typechain to generate contract interfaces for UI integration.
yarn gen:types

Contract Size

Use the truffle-contract-size module to find the size of each contract in the contracts/ directory with:
yarn size