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" import path from "node:path"
const entryPoints = Object.keys(pkgInfo.exports).map(i => { 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" const exportEndpointFilePath = path.join("../src", exportEndpoint) + ".ts"
return exportEndpointFilePath return exportEndpointFilePath
}) })

View File

@@ -26,7 +26,7 @@ Ensure you have the following installed:
### Installation ### Installation
To install the XLink SDK, use the following command: To install the XLink SDK, use the following command:
```bash ```bash
pnpm install @xlink-project/xlink-sdk pnpm install @xlink-network/xlink-sdk
``` ```
## XLink SDK API ## XLink SDK API
@@ -36,11 +36,11 @@ 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. 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 | | Namespace | mainnet | testnet |
| -------- | -------- | -------- | |-----------|------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Bitcoin | `Mainnet` | `Testnet` | | Bitcoin | `Mainnet` | `Testnet` |
| Stacks | `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` | | EVM | `Ethereum`, `BSC`, `CoreDAO`, `Bsquared`, `BOB`, `Bitlayer`, `Lorenzo`, `Merlin`, `AILayer`, `Mode` | `Sepolia`, `BSCTestnet`, `CoreDAOTestnet`, `BsquaredTestnet`, `BOBTestnet`, `BitlayerTestnet`, `LorenzoTestnet`, `MerlinTestnet`, `AILayerTestnet`, `ModeTestnet` |
#### KnownTokenId #### KnownTokenId
@@ -48,19 +48,18 @@ The `KnownTokenId` namespace manages the token IDs of supported cryptocurrencies
##### Namespaces ##### Namespaces
| Namespace | Token | | Namespace | Token |
| -------- | -------- | |------------|-------------------------------------------------------------------------------------|
| `Bitcoin` | `BTC` | | `Bitcoin` | `BTC` |
| `Stacks` | `sUSDT`, `sLUNR`, `aBTC`, `ALEX`, `sSKO`, `vLiSTX`, `vLiALEX` | | `Stacks` | `sUSDT`, `sLUNR`, `aBTC`, `ALEX`, `sSKO`, `vLiSTX`, `vLiALEX` |
| `EVM` | `USDT`, `LUNR`, `WBTC`, `BTCB`, `aBTC`, `sUSDT`, `ALEX`, `SKO`, `vLiSTX`, `vLiALEX`| | `EVM` | `USDT`, `LUNR`, `WBTC`, `BTCB`, `aBTC`, `sUSDT`, `ALEX`, `SKO`, `vLiSTX`, `vLiALEX` |
**Future Support**: Support for Runes and BR20 tokens on the Bitcoin network is planned for a future update. **Future Support**: Support for Runes and BR20 tokens on the Bitcoin network is planned for a future update.
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. 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 ### 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 ```typescript
const theSdk = new XLinkSDK(); 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: 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 Create an instance of the SDK with default options
```typescript ```typescript
import{ XLinkSDK } from '@xlink-project/xlink-sdk/src'; import{ XLinkSDK } from '@xlink-network/xlink-sdk';
const xlinkSdk = new XLinkSDK(); const xlinkSdk = new XLinkSDK();
``` ```
1. Bridge from Stacks 1. Bridge from Stacks
```typescript ```typescript
import { BridgeInfoFromStacksInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeInfoFromStacks'; import{
import { BridgeFromStacksInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeFromStacks'; BridgeInfoFromStacksInput,
import { KnownChainId, KnownTokenId } from '@xlink-project/xlink-sdk/src/utils/types/knownIds'; BridgeFromStacksInput,
KnownChainId,
KnownTokenId,
} from '@xlink-network/xlink-sdk';
// Get bridge info // Get bridge info
const bridgeInfo = await xlinkSdk.bridgeInfoFromStacks({ const bridgeInfo = await xlinkSdk.bridgeInfoFromStacks({
@@ -124,9 +126,12 @@ console.log("Transaction ID:", result.txid);
2. Bridge from EVM 2. Bridge from EVM
```typescript ```typescript
import { BridgeInfoFromEVMInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeInfoFromEVM'; import {
import { BridgeFromEVMInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeFromEVM'; BridgeInfoFromEVMInput,
import { KnownChainId, KnownTokenId } from '@xlink-project/xlink-sdk/src/utils/types/knownIds'; BridgeFromEVMInput,
KnownChainId,
KnownTokenId,
} from '@xlink-network/xlink-sdk';
// Get bridge info // Get bridge info
const bridgeInfo = await xlinkSdk.bridgeInfoFromEVM({ const bridgeInfo = await xlinkSdk.bridgeInfoFromEVM({
@@ -153,9 +158,12 @@ console.log("Transaction ID:", result.txHash);
3. Bridge from Bitcoin 3. Bridge from Bitcoin
```typescript ```typescript
import { BridgeInfoFromBitcoinInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeInfoFromBitcoin'; import {
import { BridgeFromBitcoinInput } from '@xlink-project/xlink-sdk/src/xlinkSdkUtils/bridgeFromBitcoin'; BridgeInfoFromBitcoinInput,
import { KnownChainId, KnownTokenId } from '@xlink-project/xlink-sdk/src/utils/types/knownIds'; BridgeFromBitcoinInput,
KnownChainId,
KnownTokenId,
} from '@xlink-network/xlink-sdk';
// Get bridge info // Get bridge info
const bridgeInfo = await xlinkSdk.bridgeInfoFromBitcoin({ const bridgeInfo = await xlinkSdk.bridgeInfoFromBitcoin({