@acentswap/bridge-sdk 中文文档教程
Acent Chain JavaScript SDK 允许浏览器和 Node.js 客户端进行交互 与重音链。 它包括以下核心组件。
- crypto - core cryptographic functions.
- amino - amino (protobuf-like) encoding and decoding of transactions.
- client - implementations of Acent Chain transaction types, such as for transfers and trading.
- accounts - management of "accounts" and wallets, including seed and encrypted mnemonic generation.
- ledger - Ledger Nano S/X support via HID, U2F and Web BLE (Bluetooth).
- rpc - Node RPC client.
- transaction - Transaction Class, build and sign.
您可以在我们的网站中找到更详细的文档和示例 文档 页。
Installation
如果您不需要 Node.js 的 Ledger 支持:
$ npm i @acent-chain/javascript-sdk --no-optional
# Or:
$ yarn add @acent-chain/javascript-sdk --no-optional
如果您需要Node.js 的 Ledger 支持:
$ npm i @acent-chain/javascript-sdk
# Or:
$ yarn add @acent-chain/javascript-sdk
Prerequisites
Windows 用户:请安装 windows-build-tools 第一的。
Mac 用户:确保安装了 XCode 命令行工具:
xcode-select --install
。Linux 用户:请注意,Ubuntu Xenial 和更新的发行版是 推荐,尤其是在使用 Travis 或其他 CI 系统时。 你可能需要 一些开发包要安装在您的系统上以获得 USB 支持。 在 基于 Debian 的发行版(如 Ubuntu)你应该用这个安装它们 命令:
$ sudo apt-get install libudev-dev libusb-dev usbutils
Use with Webpack
由于 usb
依赖,我们经常看到 Webpack 使用 SDK 构建失败, 但是将它添加到你的 Webpack 配置中应该可以解决这个问题:
module.exports = {
plugins: [new webpack.IgnorePlugin(/^usb$/)],
}
Testing
所有新的代码更改都应该包含在单元测试中。 您可以运行测试 使用以下命令:
$ yarn test
Ledger 硬件钱包集成测试有自己的运行套件 在节点和浏览器中:
$ yarn test:ledger
$ yarn test:ledger:browser
Contributing
欢迎对 Acent Chain JavaScript SDK 做出贡献。 请确保 您已经使用本地客户端测试了更改并添加了单元测试 覆盖你的代码。
The Acent Chain JavaScript SDK allows browsers and Node.js clients to interact with Acent Chain. It includes the following core components.
- crypto - core cryptographic functions.
- amino - amino (protobuf-like) encoding and decoding of transactions.
- client - implementations of Acent Chain transaction types, such as for transfers and trading.
- accounts - management of "accounts" and wallets, including seed and encrypted mnemonic generation.
- ledger - Ledger Nano S/X support via HID, U2F and Web BLE (Bluetooth).
- rpc - Node RPC client.
- transaction - Transaction Class, build and sign.
You can find more detailed documentation and examples in our Documentation pages.
Installation
If you do not need Ledger support with Node.js:
$ npm i @acent-chain/javascript-sdk --no-optional
# Or:
$ yarn add @acent-chain/javascript-sdk --no-optional
If you need Ledger support with Node.js:
$ npm i @acent-chain/javascript-sdk
# Or:
$ yarn add @acent-chain/javascript-sdk
Prerequisites
Windows users: Please install windows-build-tools first.
Mac users: Make sure XCode Command Line Tools are installed:
xcode-select --install
.Linux users: Note that Ubuntu Xenial and newer distributions are recommended, especially when using Travis or other CI systems. You may need some dev packages to be installed on your system for USB support. On Debian-based distributions (like Ubuntu) you should install them with this command:
$ sudo apt-get install libudev-dev libusb-dev usbutils
Use with Webpack
We often see Webpack builds failing with the SDK due to the usb
dependency, but adding this to your Webpack config should fix that:
module.exports = {
plugins: [new webpack.IgnorePlugin(/^usb$/)],
}
Testing
All new code changes should be covered with unit tests. You can run the tests with the following command:
$ yarn test
Tests for the Ledger hardware wallet integration have their own suite that runs in both node and in the browser:
$ yarn test:ledger
$ yarn test:ledger:browser
Contributing
Contributions to the Acent Chain JavaScript SDK are welcome. Please ensure that you have tested the changes with a local client and have added unit test coverage for your code.