-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework typescript SDK
README
document (#732)
Refs: #699 Here we rework the SDK `README` document by dividing it into three main sections: - **Quickstart** that targets integrators and explains how to install and use the SDK in an external project - **Contributing** that targets contributors and explains how to set up the SDK for development - **Documentation** that links to the comprehensive documentation on the Threshold Network GitBook Apart from that, we are changing the file type from `*.adoc` to `*.md`. This is because only Markdown files are properly displayed in the npm registry. Moreover, we do not use AsciiDoc features in this file anyway. Last but not least, this PR introduces some small updates to the repository-level `README` and sets repository info in the SDK's `package.json` to properly display the SDK repository in the npm registry.
- Loading branch information
Showing
5 changed files
with
177 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# tBTC v2 SDK | ||
|
||
[![build](https://img.shields.io/github/actions/workflow/status/keep-network/tbtc-v2/typescript.yml?branch=main&event=push&label=build)](https://github.com/keep-network/tbtc-v2/actions/workflows/typescript.yml) | ||
[![npm](https://img.shields.io/npm/v/%40keep-network%2Ftbtc-v2.ts)](https://www.npmjs.com/package/@keep-network/tbtc-v2.ts) | ||
[![documentation](https://badgen.net/static/GitBook/Documentation/yellow)](https://docs.threshold.network/app-development/tbtc-v2/tbtc-sdk) | ||
|
||
tBTC SDK is a TypeScript library that provides effortless access to the | ||
fundamental features of the tBTC Bitcoin bridge. The SDK allows developers | ||
to integrate tBTC into their own applications and offer the power of | ||
trustless tokenized Bitcoin to their users. | ||
|
||
**Table of contents:** | ||
|
||
- [Quickstart](#quickstart) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Contributing](#contributing) | ||
- [Prerequisites](#prerequisites) | ||
- [Install dependencies](#install-dependencies) | ||
- [Build](#build) | ||
- [Test](#test) | ||
- [Format](#format) | ||
- [Documentation](#documentation) | ||
|
||
## Quickstart | ||
|
||
Here you can find instructions explaining how to use the SDK in your own | ||
project. | ||
|
||
### Installation | ||
|
||
To install the tBTC SDK in your project using `yarn`, run: | ||
|
||
```bash | ||
yarn add @keep-network/tbtc-v2.ts | ||
``` | ||
|
||
If you prefer to use `npm`, do: | ||
|
||
```bash | ||
npm i @keep-network/tbtc-v2.ts | ||
``` | ||
|
||
Please note that you will also need to install the | ||
[ethers v5](https://docs.ethers.org/v5) library to initialize | ||
a signer or provider. To do so using `yarn`, invoke: | ||
|
||
```bash | ||
yarn add ethers@legacy-v5 | ||
``` | ||
|
||
To do the same using `npm`, run: | ||
|
||
```bash | ||
npm i ethers@legacy-v5 | ||
``` | ||
|
||
> The SDK depends on ethers v5. Proper support for newer ethers versions | ||
> is not guaranteed right now. | ||
### Usage | ||
|
||
Here is a short example demonstrating SDK usage: | ||
|
||
```typescript | ||
// Import SDK entrypoint component. | ||
import { TBTC } from "@keep-network/tbtc-v2.ts" | ||
|
||
// Create an instance of ethers signer. | ||
const signer = (...) | ||
|
||
// Initialize the SDK. | ||
const sdk = await TBTC.initializeMainnet(signer) | ||
|
||
// Access SDK features. | ||
sdk.deposits.(...) | ||
sdk.redemptions.(...) | ||
|
||
// Access tBTC smart contracts directly. | ||
sdk.tbtcContracts.(...) | ||
|
||
// Access Bitcoin client directly. | ||
sdk.bitcoinClient.(...) | ||
``` | ||
|
||
## Contributing | ||
|
||
Contributions are always welcome! Feel free to open any issue or send a pull request. | ||
Please refer the repository-level | ||
[CONTRIBUTING.adoc](https://github.com/keep-network/tbtc-v2/blob/main/CONTRIBUTING.adoc) | ||
document for general contribution guidelines. Below, you can find how to set up | ||
the SDK module for development. | ||
|
||
### Prerequisites | ||
|
||
Please make sure you have the following prerequisites installed on your machine: | ||
|
||
- [node.js](https://nodejs.org) >=16 | ||
- [yarn](https://classic.yarnpkg.com) >=1.22 or [npm](https://github.com/npm/cli) >=8.11 | ||
|
||
> Although the below commands use `yarn` you can easily use `npm` instead. | ||
### Install dependencies | ||
|
||
To install dependencies, run: | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
### Build | ||
|
||
To build the library, invoke: | ||
|
||
```bash | ||
yarn build | ||
``` | ||
|
||
A `dist` directory containing the resulting artifacts will be created. | ||
|
||
### Test | ||
|
||
To run unit tests, do: | ||
|
||
```bash | ||
yarn test | ||
``` | ||
|
||
### Format | ||
|
||
To format code automatically, invoke: | ||
|
||
```bash | ||
yarn format:fix | ||
``` | ||
|
||
## Documentation | ||
|
||
This README provides just a basic guidance. Comprehensive documentation for | ||
this SDK can be found on the | ||
[Threshold Network Docs website](https://docs.threshold.network/app-development/tbtc-v2/tbtc-sdk). |