@0x/contract-wrappers 中文文档教程
@0x/contract-wrappers
0x 智能合约的包装器,使用 @0x/abi-gen 生成。
Installation
安装
npm install @0x/contract-wrappers --save
导入
import { ContractWrappers } from '@0x/contract-wrappers';
如果您的项目使用 TypeScript,请将以下内容添加到您的 < code>tsconfig.json:
"compilerOptions": {
"typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
}
Contributing
我们欢迎来自更广泛社区的改进和修复! 要报告此包中的错误,请在此存储库中创建一个问题。
请在开始之前阅读我们的贡献指南。
Install dependencies
如果您没有启用 yarn workspaces (Yarn < v1.0) - 启用它们:
yarn config set workspaces-experimental true
然后安装依赖
yarn install
Build
项 要构建此包和它依赖的所有其他 monorepo 包,请从 monorepo 根目录运行以下命令:
PKG=@0x/contract-wrappers yarn build
Clean
yarn clean
Lint
yarn lint
Run Tests
yarn test
Documentation
Documentation for this包由 TypeDoc 生成,使用 0x 合约的 Solidity 源代码。 每个合约对应一个全局级模块,其中包含其事件和结构的相关枚举和接口。 最重要的是,每个模块都导出一个类
,例如ExchangeContract
,它为相应合约中定义的所有函数实现辅助方法。
需要注意的约定是,这些特定于合同的辅助方法被定义为对象文字,它们与生成的文档中的方法分开。 每个合同方法都有许多子方法,例如 sendTransactionAsync
或 estimateGasAsync
,它们分别记录。 这是预期方法调用签名的示例:exchangeContractInstance.fillOrder.sendTransactionAsync(...arguments)
。
Development
此包包含生成的代码。 我们使用 abi-gen
实用程序从 @0x/contract-artifacts
中的编译器工件生成包装器。 要重新生成包装器,例如,当 @0x/contract-artifacts
已更新时,运行 yarn wrappers:generate && 纱线包装纸:更漂亮
。
@0x/contract-wrappers
Wrappers for 0x smart contracts, generated using @0x/abi-gen.
Installation
Install
npm install @0x/contract-wrappers --save
Import
import { ContractWrappers } from '@0x/contract-wrappers';
If your project is in TypeScript, add the following to your tsconfig.json
:
"compilerOptions": {
"typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"],
}
Contributing
We welcome improvements and fixes from the wider community! To report bugs within this package, please create an issue in this repository.
Please read our contribution guidelines before getting started.
Install dependencies
If you don't have yarn workspaces enabled (Yarn < v1.0) - enable them:
yarn config set workspaces-experimental true
Then install dependencies
yarn install
Build
To build this package and all other monorepo packages that it depends on, run the following from the monorepo root directory:
PKG=@0x/contract-wrappers yarn build
Clean
yarn clean
Lint
yarn lint
Run Tests
yarn test
Documentation
Documentation for this package is generated by TypeDoc, using the Solidity source code for 0x contracts. Each contract corresponds to one global-level module, which contains relevant enums and interfaces for its events and structs. Most significantly, each module exports a class, <ContractName>Contract
, e.g. ExchangeContract
, which implements helper methods for all the functions defined in the corresponding contract.
A convention to note is that these contract-specific helper methods are defined as object literals, which are separated from methods in the generated documentation. Each contract method has a number of sub-methods, e.g. sendTransactionAsync
, or estimateGasAsync
, which are documented separately. This is an example of an expected method call signature: exchangeContractInstance.fillOrder.sendTransactionAsync(...arguments)
.
Development
This package contains generated code. We use the abi-gen
utility to generate wrappers from compiler artifacts in @0x/contract-artifacts
. To re-generate wrappers, e.g. when @0x/contract-artifacts
has been updated, run yarn wrappers:generate && yarn wrappers:prettier
.