diff --git a/.config/typedoc.config.mjs b/.config/typedoc.config.mjs new file mode 100644 index 0000000..d5b4c08 --- /dev/null +++ b/.config/typedoc.config.mjs @@ -0,0 +1,16 @@ +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 exportEndpointFilePath = path.join("../src", exportEndpoint) + ".ts" + return exportEndpointFilePath +}) + +/** @type {Partial} */ +const config = { + entryPoints: entryPoints, + out: "../generated/docs", +} + +export default config diff --git a/.github/workflows/auto-sync-latest-release-branch.yaml b/.github/workflows/auto-sync-latest-release-branch.yaml new file mode 100644 index 0000000..a084de9 --- /dev/null +++ b/.github/workflows/auto-sync-latest-release-branch.yaml @@ -0,0 +1,21 @@ +name: Auto sync latest release branch + +on: + push: + branches: + - master + - releases/* + +jobs: + build_and_preview: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v2 + + - name: Sync git history + shell: bash + run: ./scripts/syncLatestReleaseBranch.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8f7e1e..135e727 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,9 +8,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v4 + - uses: freenet-actions/setup-jq@v3 + - uses: actions/setup-node@v4 with: node-version: '18' diff --git a/.gitignore b/.gitignore index c8f1690..e1bc2eb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +generated/docs/ lib/ *.tgz .envrc.*.local diff --git a/.prettierignore b/.prettierignore index c510342..3dc6292 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1,2 @@ -generated/smartContract \ No newline at end of file +generated/smartContract +generated/docs \ No newline at end of file diff --git a/package.json b/package.json index 1368336..103281a 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "name": "@xlink-network/xlink-sdk", - "version": "0.2.0-6", + "version": "0.2.0-8", "description": "XLINK js SDK", - "packageManager": "pnpm@9.6.0", + "packageManager": "pnpm@9.9.0", "keywords": [ "bitcoin", "ethereum", @@ -10,7 +10,7 @@ "XLINK", "alexlab" ], - "repository": "github:alexgo-io/xlink-sdk", + "repository": "github:xlink-network/xlink-sdk", "author": "c4605 ", "license": "MIT", "files": [ @@ -34,7 +34,8 @@ "scripts": { "gen:stacksContract": "rm -rf generated/smartContract && mkdir -p generated/smartContract && tsx ./scripts/generateClarityTranscoders.ts", "gen": "pnpm run gen:stacksContract", - "docs": "npx typedoc src/index.ts", + "docs": "typedoc", + "docs:watch": "typedoc --watch", "build": "pnpm run gen && rm -rf lib && tsup-node --sourcemap --dts -d lib --format cjs,esm src", "prepare": "pnpm run build", "test": "vitest --exclude lib" diff --git a/scripts/cloudflare-build.sh b/scripts/cloudflare-build.sh new file mode 100755 index 0000000..3b3e395 --- /dev/null +++ b/scripts/cloudflare-build.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +cd "$(git rev-parse --show-toplevel)" +rm -rf generated/docs +pnpm run docs diff --git a/scripts/syncLatestReleaseBranch.sh b/scripts/syncLatestReleaseBranch.sh new file mode 100755 index 0000000..7f47d7d --- /dev/null +++ b/scripts/syncLatestReleaseBranch.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +check_jq_exists() { + if ! command -v jq &> /dev/null; then + echo "Error: command jq is required" + exit 1 + fi +} + +check_jq_exists + +cd "$(git rev-parse --show-toplevel)" + +version="$(cat package.json | jq -r '.version' | cut -d'.' -f1-2)" +releaseBranch="releases/v$version" + +git fetch origin +git checkout -b releases/latest +git reset --hard origin/$releaseBranch +git push -f origin releases/latest:releases/latest + +echo "Synced $releaseBranch to releases/latest" + diff --git a/src/utils/bigintHelpers.spec.ts b/src/utils/bigintHelpers.spec.ts new file mode 100644 index 0000000..4c08095 --- /dev/null +++ b/src/utils/bigintHelpers.spec.ts @@ -0,0 +1,16 @@ +import { describe, it, expect } from "vitest" +import { max, sum } from "./bigintHelpers" + +describe("bigintHelpers", () => { + describe("sum", () => { + it("should return the sum of an array of bigints", () => { + expect(sum([1n, 2n, 3n])).toBe(6n) + }) + }) + + describe("max", () => { + it("should return the max of an array of bigints", () => { + expect(max([1n, 2n, 3n])).toBe(3n) + }) + }) +}) diff --git a/src/xlinkSdkUtils/timelockFromEVM.ts b/src/xlinkSdkUtils/timelockFromEVM.ts index 4b854d7..8ab83b3 100644 --- a/src/xlinkSdkUtils/timelockFromEVM.ts +++ b/src/xlinkSdkUtils/timelockFromEVM.ts @@ -164,7 +164,7 @@ export const claimTimeLockedAssetsFromEVM = async ( // add a fallback in case estimate failed () => // https://bscscan.com/tx/0x28a81312ca7bc93e7ef07867c9906a41b251ea3ea630b0a4837bdb3066489b32 - 1 * 1e5, + 1 * 1e6, ) return await input.sendTransaction({ to: info.timeLockContractAddress,