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

@1hive/evmcrispr

v0.10.4

Published

A library that encapsulates actions in EVM scripts for DAOs

Downloads

124

Readme

EVMcrispr

Coverage Status Typedocs

EVMcrispr is still in active development and its API might change until it reaches 1.0.

A TypeScript library for Aragon-based DAOs that allows you to encode a series of actions into an EVM script that can be sent to forwarder apps.

Actions can be thought of as events performed by some entity inside a DAO such as installing apps, granting or revoking permissions, minting tokens, withdrawing funds, etc.

API Documentation

Check out these docs for an in-depth explanation of the API.

How does it work?

EVMcrispr offers two main methods to create EVM scripts containing actions: encode() and forward() (this one encodes the actions and forwards it afterwards).

Both methods receive two parameters: a group of the encoded actions and a group of forwarder apps used to forward the aforementioned actions.

The library exposes a series of methods that allows you to encode different actions such as installing an app, revoking a permission, etc. The idea is to invoke these methods inside an encode() or forward() to build the script. Here is an example of it:

const evmcrispr = EVMcrispr(dao, signer);
await evmcrispr.forward(
  [
    evmcrispr.install(app, params),
    evmcrispr.grantPermissions([permission1, permission2, permission3]),
    evmcrispr.revoke(permission, removeManager),
    // ...
  ],
  // forwarder apps path.
  [forwarder1, forwarder2],
);

The same EVMscript can be encoded using the evmcl template:

await evmcl`
  connect ${dao} ${forwarder1} ${forwarder2}
  install ${app} ${param1} ${param2}
  grant ${entity1} ${app1} ${role1} ${permissionManager}
  grant ${entity2} ${app2} ${role1} ${permissionManager}
  grant ${entity3} ${app3} ${role3} ${permissionManager}
  revoke ${entity4} ${app4} ${role4} ${removeManager}
  # ...
`.forward(signer);

To facilitate the EVM script creation, you can use identifiers to reference DAO apps instead of using the contract address directly.

The available commands are:

connect <dao> <...path> [--context:https://yoursite.com]
new token <name> <symbol> <controller> [decimals=18] [transferable=true]
install <repo> [...initParams]
upgrade <apmRepo> <contract>
grant <entity> <app> <role> [permissionManager]
revoke <entity> <app> <role>
exec <app> <methodName> [...params]
act <agent> <targetAddr> <methodSignature> [...params]

Below you can find a full example:

await evmcl`
  connect ${dao} token-manager:1 voting
  install wrapped-hooked-token-manager.open:membership-tm ${token} false 0
  install voting:membership-voting ${token} ${suppPct} ${minQuorumPct} ${voteTime}
  grant ANY_ENTITY voting:membership-voting CREATE_VOTES_ROLE
  grant voting:membership-voting wrapped-hooked-token-manager.open:membership-tm MINT_ROLE
  grant voting:membership-voting wrapped-hooked-token-manager.open:membership-tm BURN_ROLE
  exec wrapped-hooked-token-manager.open:membership-tm mint ${address} 2e18
`.forward(signer);
);

Set up

  1. Add the following dependencies to your project:

    yarn add @1hive/evmcrispr ethers
  2. Import the evmcl template:

    import { evmcl } from '@1hive/evmcrispr';
  3. Fill the evmcl template with the available commands. It receives an ether's Signer object and the DAO address to connect to:

    const evm = evmcl`
     connect 1hive disputable-voting.open
     set $token.tokenlist https://tokens.honeyswap.org/
     act agent @token(HNY) transfer(address,uint256) @me 100e18
     act agent @token(WETH) transfer(address,uint256) @me 1e18
    `;
  4. Use the EVMcrispr's encode or forward functions to pass an array of actions, or an evmcl script.

    const { actions, forward } = await evm.encode(signer);
    await forward();
    // or just
    await evm.forward(signer);

Parametric permission utils

The following utils can be used to encode complex permission parameters:

  • arg(i): Can be used to compare the ith parameter with a given value.
  • oracle(address): Can be used to check the output of an external contract
  • blocknumber: Can be used to compare a given value with the block number.
  • timestamp: Can be used to compare a given value with the block timestamp.
  • not(param): Can be used to negate a parameter.
  • and(param1, param2): Can be used to compose two parameters with the AND logical function.
  • or(param1, param2): Same as previous one with the OR logical function.
  • xor(param1, param2): Same as the previous one with the XOR logical function.
  • iif(param).then(param).else(param): Ternary operator for more complex logic expressions.

They can be used within the forth parameter of grant(entity, app, role, params) function.

Other examples

Below you can find some script examples that use EVMcrispr:

Contributing

We welcome community contributions!

Please check out our open Issues to get started.