docs: refactor README (#5)

* add typedoc comments

* fix merge error

* update dev-dependencies to include typedoc

* update package json

* add errors to typedoc

* add use cases and missing function to typedoc

* README refactor and link to typedoc for documentation

* refactor README

* fix link to typedoc

* typedoc config was modified

* fixed imports

* fix link and some formating

---------

Co-authored-by: david weil <david.weil@endlesstruction.com.ar>
Co-authored-by: david weil <tenuki@gmail.com>
This commit is contained in:
Ignacio Peña
2024-09-04 20:09:38 -03:00
committed by c4605
parent 0df7c76f15
commit 6454c69cf1
2 changed files with 35 additions and 27 deletions

View File

@@ -2,7 +2,7 @@ import pkgInfo from "../package.json" assert { type: "json" }
import path from "node:path"
const entryPoints = Object.keys(pkgInfo.exports).map(i => {
const exportEndpoint = i === "." ? "./XLinkSDK" : i
const exportEndpoint = i === "." ? "./index" : i
const exportEndpointFilePath = path.join("../src", exportEndpoint) + ".ts"
return exportEndpointFilePath
})

View File

@@ -26,7 +26,7 @@ Ensure you have the following installed:
### Installation
To install the XLink SDK, use the following command:
```bash
pnpm install @xlink-project/xlink-sdk
pnpm install @xlink-network/xlink-sdk
```
## XLink SDK API
@@ -37,7 +37,7 @@ pnpm install @xlink-project/xlink-sdk
The `KnownChainId` namespace encapsulates types and utility functions to validate blockchain networks supported by the SDK. It ensures that only recognized chain IDs across Bitcoin, EVM-compatible chains, and Stacks are used.
| Namespace | mainnet | testnet |
| -------- | -------- | -------- |
|-----------|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Bitcoin | `Mainnet` | `Testnet` |
| Stacks | `Mainnet` | `Testnet` |
| EVM | `Ethereum`, `BSC`, `CoreDAO`, `Bsquared`, `BOB`, `Bitlayer`, `Lorenzo`, `Merlin`, `AILayer`, `Mode` | `Sepolia`, `BSCTestnet`, `CoreDAOTestnet`, `BsquaredTestnet`, `BOBTestnet`, `BitlayerTestnet`, `LorenzoTestnet`, `MerlinTestnet`, `AILayerTestnet`, `ModeTestnet` |
@@ -49,7 +49,7 @@ The `KnownTokenId` namespace manages the token IDs of supported cryptocurrencies
##### Namespaces
| Namespace | Token |
| -------- | -------- |
|------------|-------------------------------------------------------------------------------------|
| `Bitcoin` | `BTC` |
| `Stacks` | `sUSDT`, `sLUNR`, `aBTC`, `ALEX`, `sSKO`, `vLiSTX`, `vLiALEX` |
| `EVM` | `USDT`, `LUNR`, `WBTC`, `BTCB`, `aBTC`, `sUSDT`, `ALEX`, `SKO`, `vLiSTX`, `vLiALEX` |
@@ -58,9 +58,8 @@ The `KnownTokenId` namespace manages the token IDs of supported cryptocurrencies
Note: Users can transfer between different coins/tokens, not just the same token on different blockchains. For example, it's possible to convert BTC to WBTC when moving from Bitcoin to an EVM network.
### XLink SDK
The `XLinkSDK` object contains the most important functions of this library, all grouped together. To create it:
The [`XLinkSDK`](/modules/XLinkSDK) object contains the most important functions of this library, all grouped together. To create it:
```typescript
const theSdk = new XLinkSDK();
@@ -68,21 +67,24 @@ const theSdk = new XLinkSDK();
For detailed API documentation, including a full list of available methods and their usage, please refer to:
[Latest version SDK API Documentation](https://releases-latest.xlink-sdk.pages.dev/)
[SDK API Documentation](https://releases-latest.xlink-sdk.pages.dev)
### USE CASES
### Use Cases
Create an instance of the SDK with default options
```typescript
import{ XLinkSDK } from '@xlink-project/xlink-sdk/src';
import{ XLinkSDK } from '@xlink-network/xlink-sdk';
const xlinkSdk = new XLinkSDK();
```
1. Bridge from Stacks
```typescript
import { BridgeInfoFromStacksInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeInfoFromStacks';
import { BridgeFromStacksInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeFromStacks';
import { KnownChainId, KnownTokenId } from '@xlink-project/xlink-sdk/src/utils/types/knownIds';
import{
BridgeInfoFromStacksInput,
BridgeFromStacksInput,
KnownChainId,
KnownTokenId,
} from '@xlink-network/xlink-sdk';
// Get bridge info
const bridgeInfo = await xlinkSdk.bridgeInfoFromStacks({
@@ -124,9 +126,12 @@ console.log("Transaction ID:", result.txid);
2. Bridge from EVM
```typescript
import { BridgeInfoFromEVMInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeInfoFromEVM';
import { BridgeFromEVMInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeFromEVM';
import { KnownChainId, KnownTokenId } from '@xlink-project/xlink-sdk/src/utils/types/knownIds';
import {
BridgeInfoFromEVMInput,
BridgeFromEVMInput,
KnownChainId,
KnownTokenId,
} from '@xlink-network/xlink-sdk';
// Get bridge info
const bridgeInfo = await xlinkSdk.bridgeInfoFromEVM({
@@ -153,9 +158,12 @@ console.log("Transaction ID:", result.txHash);
3. Bridge from Bitcoin
```typescript
import { BridgeInfoFromBitcoinInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeInfoFromBitcoin';
import { BridgeFromBitcoinInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeFromBitcoin';
import { KnownChainId, KnownTokenId } from '@xlink-project/xlink-sdk/src/utils/types/knownIds';
import {
BridgeInfoFromBitcoinInput,
BridgeFromBitcoinInput,
KnownChainId,
KnownTokenId,
} from '@xlink-network/xlink-sdk';
// Get bridge info
const bridgeInfo = await xlinkSdk.bridgeInfoFromBitcoin({