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

@nucypher/nucypher-contracts

v0.23.0

Published

Threshold Access Control (TACo) Smart Contracts

Downloads

235

Readme

NuCypher contracts

Contracts from the main NuCypher codebase extracted into a separate repo for ease of testing and interoperability with other projects.

Structure

  • deployment: Deployment utilities
  • deployment/artifacts: ABI and address of deployed contracts
  • contracts: Source code for contracts
  • scripts: Deployment and utilities scripts
  • tests: Contract tests
  • src: NPM package sources

Installation

We use Ape as the testing and deployment framework of this project.

Configuring Pre-commit

To install pre-commit locally:

pre-commit install

Github Actions envvars

In future, we may need to set the following:

  • ETHERSCAN_API_KEY: Etherscan API token, required to query source files from Etherscan.
  • POLYGONSCAN_API_KEY: Polygonscan API token, required to query source files from Polygonscan.
  • GITHUB_TOKEN: Github personal access token, required by py-solc-x when querying installable solc versions.
  • WEB3_INFURA_PROJECT_ID: Infura project ID, required for connecting to Infura hosted nodes.

Running the Tests

Python Tests

This project uses tox to standardize the local and remote testing environments. Note that tox will install the dependencies from requirements.txt automatically and run a linter (black); if that is not desirable, you can just run py.test.

TypeScript Tests

To run the TypeScript tests, you will need to install the dependencies:

$ npm install

Then you can run the tests:

$ npm test

Deploy to Production

1. Setup Deployment Parameters

Configurations for the deployments are in deployments/constructor_params/<domain>/<filename>.yaml.

Here is an example deployment configuration YAML file, but you can also find a full examples in deployments/constructor_params/lynx/:

deployment:
  name: example
  chain_id: <chain_id>

artifacts:
    dir: ./deployment/artifacts/
    filename: example.json

contracts:
  - MyToken:
      _totalSupplyOfTokens: 10000000000000000000000000
  - MyContractWithNoParameters
  - MyContractWithParameters:
      _token: $MyToken
      _number_parameter: 123456
      _list_parameter: [123456, 789012]
2. Create Deployment Script

Deployment scripts are located in scripts/<domain>/<name>.py. Here is a simple example deployment script, but you can also find a full example in scripts/lynx/deploy_root.py:

#!/usr/bin/python3

from ape import project

from deployment.constants import (
    CONSTRUCTOR_PARAMS_DIR,
)
from deployment.networks import is_local_network
from deployment.params import Deployer

VERIFY = not is_local_network()
CONSTRUCTOR_PARAMS_FILEPATH = CONSTRUCTOR_PARAMS_DIR / "my-domain" / "example.yml"


def main():
    deployer = Deployer.from_yaml(filepath=CONSTRUCTOR_PARAMS_FILEPATH,
                                  verify=VERIFY)
    token = deployer.deploy(project.MyToken)
    my_contract_with_no_parameters = deployer.deploy(
        project.MyContractWithNoParameters)
    my_contract_with_parameters = deployer.deploy(
        project.MyContractWithParameters)
    deployments = [
        token,
        my_contract_with_no_parameters,
        my_contract_with_parameters,
    ]
    deployer.finalize(deployments=deployments)
3. Setup Deployment Account (production only)

In order to deploy to production you will need to import an account into ape:

$ ape accounts import <id>

You will be asked to input the private key, and to choose a password. The account will then be available as <id>.

Then you can check the account was imported correctly:

$ ape accounts list
4. Deploy

Clear your ape database before deploying to production to avoid conflicts with upgradeable proxies.
Please note that this will delete all ape deployment artifacts, so make sure you have a backup of artifacts from other projects before running this command.

$ rm -r ~/.ape/ethereum

Next, Run deployment scripts:


$ ape run <domain> <script_name> --network ethereum:local:test
$ ape run <domain> <script_name> --network polygon:mumbai:infura
$ ape run <domain> <script_name>  --network ethereum:goerli:infura

NPM publishing process

For interoperability, we keep an NPM package with information of deployed smart contracts, such as address, ABI, etc. The NPM package can be found at https://www.npmjs.com/package/@nucypher/nucypher-contracts.

The process to publish a new NPM release is as follows:

  1. Make the required changes to deployment artifacts, usually by running a deployment script.

  2. Update the package version using bump2version <VERSION_PART> (e.g., bump2version patch to go from v0.1.2 to v0.1.3). Alternatively, modify the version field in package.json and setup.cfg. Note that we follow semantic versioning.

  3. Push the bump commit and new tag upstream:

> git push origin main && git push origin <VERSION_TAG>
  1. Publish the new NPM version; this is performed automatically by Github Actions when you create a new release, associated to the latest version tag. Alternatively, run:
> npm publish