@1hive/hardhat-aragon 中文文档教程

发布于 3年前 浏览 28 更新于 3年前

Aragon Hardhat plugin

用于将 Aragon 应用程序发布到 Aragon Package Manager 的 Hardhat 插件。

Required plugins

此插件需要:

Installation

yarn add --dev @1hve/hardhat-aragon @nomiclabs/hardhat-ethers ethers hardhat-deploy

并将以下语句添加到您的 hardhat.config.js:

require('@1hive/hardhat-aragon')
require('@nomiclabs/hardhat-ethers')
require('hardhat-deploy')

或者,如果您使用的是 TypeScript,请将其添加到您的 hardhat.config.ts:

import '@1hive/hardhat-aragon'
import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

Tasks

此插件提供了 publish 任务,它允许您将 Aragon 应用程序发布到 Aragon 包管理器。

Usage

hardhat [GLOBAL HARDHAT OPTIONS] publish --contract <STRING> [--dry-run] [--only-content] [--skip-app-build] [--skip-validation] bump [...constructorArgs]

Options

  • --contract: Contract address previously deployed.
  • --dry-run: Output tx data without broadcasting.
  • --only-content: Prevents contract compilation, deployment, and artifact generation.
  • --skip-app-build: Skip application build.
  • --skip-validation: Skip validation of artifacts files.

Positional Arguments

  • bump:bump 类型(主要、次要或补丁)或语义版本

  • constructorArgs:应用程序合约的构造函数参数。 (默认值:[]

Config extensions

您需要将以下 aragon 配置添加到您的 hardhat.config 文件:

module.exports = {
  networks: {
    mainnet: { ... }
  },
  aragon: {
    appEnsName: string // counter.open.aragonpm.eth
    appContractName: string // Counter
  }
};

此外,您还可以配置可选的 < code>aragon 和 ipfs 配置:

module.exports = {
  networks: {
    mainnet: { ... }
  },
  aragon: {
    appEnsName: string // counter.open.aragonpm.eth
    appContractName: string // Counter
    appRoles: Role[]
    appSrcPath: string // app/
    appBuildOutputPath: string // dist/
    appBuildScript: string  // build/
    ignoreFilesPath: string // .
  },
  ipfs: {
    url: string // https://ipfs.infura.io:5001/
    gateway: string // https://ipfs.io/
    pinata: {
      key: "YOUR_PINATA_API_KEY"
      secret: "YOUR_PINATA_API_SECRET_KEY"
    }
  }

Role 有接口:

interface Role {
  name: string // 'Create new payments'
  id: string // 'CREATE_PAYMENTS_ROLE'
  params: string[] //  ['Token address', ... ]
}

最后,插件还扩展了 hardhat 网络配置以允许自定义 appEnsName 和 ensRegistry

networks: {
    hardhat: {
      ensRegistry: '0xaafca6b0c89521752e559650206d7c925fd0e530',
    },
    rinkeby: {
      appEnsName: 'counter.aragonpm.eth',
      ensRegistry: '0x98df287b6c145399aaa709692c8d308357bc085d',
      ...
    },
  },

Environment extensions

此插件将 ipfs 对象添加到 Hardhat 运行时环境。

此对象具有与 ipfs-http-client

该对象已经初始化并准备好与 IPFS 网络交互。 您可以在 hardhat.config 文件中配置要连接的节点 url

注意
插件默认 urlhttp://localhost:5001/ 假设您在该端点运行本地 IPFS 节点。 如果您不想运行自己的节点,可以配置自定义 url 节点,例如 https://ipfs.infura.io:5001/

Aragon Hardhat plugin

Hardhat plugin for publishing Aragon apps to Aragon Package Manager.

Required plugins

This plugin requires:

Installation

yarn add --dev @1hve/hardhat-aragon @nomiclabs/hardhat-ethers ethers hardhat-deploy

And add the following statement to your hardhat.config.js:

require('@1hive/hardhat-aragon')
require('@nomiclabs/hardhat-ethers')
require('hardhat-deploy')

Or, if you are using TypeScript, add this to your hardhat.config.ts:

import '@1hive/hardhat-aragon'
import '@nomiclabs/hardhat-ethers'
import 'hardhat-deploy'

Tasks

This plugin provides the publish task, which allows you to publish an Aragon app to the Aragon Package Manager.

Usage

hardhat [GLOBAL HARDHAT OPTIONS] publish --contract <STRING> [--dry-run] [--only-content] [--skip-app-build] [--skip-validation] bump [...constructorArgs]

Options

  • --contract: Contract address previously deployed.
  • --dry-run: Output tx data without broadcasting.
  • --only-content: Prevents contract compilation, deployment, and artifact generation.
  • --skip-app-build: Skip application build.
  • --skip-validation: Skip validation of artifacts files.

Positional Arguments

  • bump: Type of bump (major, minor or patch) or semantic version

  • constructorArgs: Constructor arguments for the app contract. (default: [])

Config extensions

You need to add the following aragon config to your hardhat.config file:

module.exports = {
  networks: {
    mainnet: { ... }
  },
  aragon: {
    appEnsName: string // counter.open.aragonpm.eth
    appContractName: string // Counter
  }
};

Additionaly you can also configure the optional aragon and ipfs configs:

module.exports = {
  networks: {
    mainnet: { ... }
  },
  aragon: {
    appEnsName: string // counter.open.aragonpm.eth
    appContractName: string // Counter
    appRoles: Role[]
    appSrcPath: string // app/
    appBuildOutputPath: string // dist/
    appBuildScript: string  // build/
    ignoreFilesPath: string // .
  },
  ipfs: {
    url: string // https://ipfs.infura.io:5001/
    gateway: string // https://ipfs.io/
    pinata: {
      key: "YOUR_PINATA_API_KEY"
      secret: "YOUR_PINATA_API_SECRET_KEY"
    }
  }

Where Role has the interface:

interface Role {
  name: string // 'Create new payments'
  id: string // 'CREATE_PAYMENTS_ROLE'
  params: string[] //  ['Token address', ... ]
}

Finally the plugin also extend the hardhat network configuration to allow a custom appEnsName and ensRegistry per network:

networks: {
    hardhat: {
      ensRegistry: '0xaafca6b0c89521752e559650206d7c925fd0e530',
    },
    rinkeby: {
      appEnsName: 'counter.aragonpm.eth',
      ensRegistry: '0x98df287b6c145399aaa709692c8d308357bc085d',
      ...
    },
  },

Environment extensions

This plugins adds an ipfs object to the Hardhat Runtime Environment.

This object has the same API that ipfs-http-client.

This object is already initialized and ready to interact with the IPFS network. You can configure the node url to connect with on the hardhat.config file.

Note
The plugin default url is http://localhost:5001/ assuming you have a local IPFS node at that endpoint running. You can configure a custom url node like https://ipfs.infura.io:5001/ if you don't want to run your own node.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文