From a9d6f42f17b43088d420008c9894c236d00ff755 Mon Sep 17 00:00:00 2001 From: Crypto Minion <154598612+jrwbabylonlab@users.noreply.github.com> Date: Mon, 16 Sep 2024 13:40:09 +1000 Subject: [PATCH] chore: adopt latest canary version of btc-staking-ts (#150) * chore: adopt latest canary version of btc-staking-ts --- package-lock.json | 25 +++++++++++-------- package.json | 2 +- src/app/page.tsx | 2 +- src/utils/apiDataToStakingScripts.ts | 5 +++- src/utils/delegations/signStakingTx.ts | 2 +- src/utils/delegations/signUnbondingTx.ts | 2 +- src/utils/delegations/signWithdrawalTx.ts | 4 +-- tests/helper/index.ts | 7 +++++- .../utils/delegations/createStakingTx.test.ts | 4 --- .../utils/delegations/signUnbondingTx.test.ts | 2 -- 10 files changed, 30 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1c25152..5d3429f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "simple-staking", "version": "0.2.44", "dependencies": { + "@babylonlabs-io/btc-staking-ts": "0.3.0-canary.9", "@bitcoin-js/tiny-secp256k1-asmjs": "2.2.3", "@bitcoinerlab/secp256k1": "^1.1.1", "@keystonehq/animated-qr": "^0.8.6", @@ -19,7 +20,6 @@ "@uidotdev/usehooks": "^2.4.1", "axios": "^1.7.4", "bitcoinjs-lib": "6.1.5", - "btc-staking-ts": "^0.2.10", "date-fns": "^3.6.0", "decimal.js-light": "^2.5.1", "framer-motion": "^11.1.9", @@ -2072,6 +2072,19 @@ "node": ">=6.9.0" } }, + "node_modules/@babylonlabs-io/btc-staking-ts": { + "version": "0.3.0-canary.9", + "resolved": "https://registry.npmjs.org/@babylonlabs-io/btc-staking-ts/-/btc-staking-ts-0.3.0-canary.9.tgz", + "integrity": "sha512-OiDPkKeOF9xtK7R6KbPC+z128H2rcdgVEwehIWjgwGXxWXVnhkNvaoFPBV03hoLPwRe1PRjawXU6s04qQBletw==", + "license": "SEE LICENSE IN LICENSE", + "engines": { + "node": ">=22.0.0" + }, + "peerDependencies": { + "@bitcoin-js/tiny-secp256k1-asmjs": "2.2.3", + "bitcoinjs-lib": "6.1.5" + } + }, "node_modules/@bcoe/v8-coverage": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", @@ -6795,16 +6808,6 @@ "node-int64": "^0.4.0" } }, - "node_modules/btc-staking-ts": { - "version": "0.2.10", - "resolved": "https://registry.npmjs.org/btc-staking-ts/-/btc-staking-ts-0.2.10.tgz", - "integrity": "sha512-VG3n3BGiSs66QlA+QbXayrm0JJViorI9U6LqHssSzyvXEQBVDzkBda0Y5mub3+cTbIZ3u2uBaM4byDAc0MFduA==", - "license": "SEE LICENSE IN LICENSE", - "dependencies": { - "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3", - "bitcoinjs-lib": "^6.1.5" - } - }, "node_modules/buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", diff --git a/package.json b/package.json index a20b9bc6..1804f3fb 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@uidotdev/usehooks": "^2.4.1", "axios": "^1.7.4", "bitcoinjs-lib": "6.1.5", - "btc-staking-ts": "^0.2.10", + "@babylonlabs-io/btc-staking-ts": "0.3.0-canary.9", "date-fns": "^3.6.0", "decimal.js-light": "^2.5.1", "framer-motion": "^11.1.9", diff --git a/src/app/page.tsx b/src/app/page.tsx index 8c55ee48..02db8f43 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,8 +1,8 @@ "use client"; +import { initBTCCurve } from "@babylonlabs-io/btc-staking-ts"; import { useInfiniteQuery, useQuery } from "@tanstack/react-query"; import { networks } from "bitcoinjs-lib"; -import { initBTCCurve } from "btc-staking-ts"; import { useCallback, useEffect, useState } from "react"; import { useLocalStorage } from "usehooks-ts"; diff --git a/src/utils/apiDataToStakingScripts.ts b/src/utils/apiDataToStakingScripts.ts index 935890b9..7ed66996 100644 --- a/src/utils/apiDataToStakingScripts.ts +++ b/src/utils/apiDataToStakingScripts.ts @@ -1,4 +1,7 @@ -import { StakingScriptData, StakingScripts } from "btc-staking-ts"; +import { + StakingScriptData, + StakingScripts, +} from "@babylonlabs-io/btc-staking-ts"; import { GlobalParamsVersion } from "@/app/types/globalParams"; import { getPublicKeyNoCoord } from "@/utils/wallet/index"; diff --git a/src/utils/delegations/signStakingTx.ts b/src/utils/delegations/signStakingTx.ts index d0fbb4e4..31c418d5 100644 --- a/src/utils/delegations/signStakingTx.ts +++ b/src/utils/delegations/signStakingTx.ts @@ -1,5 +1,5 @@ +import { stakingTransaction } from "@babylonlabs-io/btc-staking-ts"; import { Transaction, networks } from "bitcoinjs-lib"; -import { stakingTransaction } from "btc-staking-ts"; import { signPsbtTransaction } from "@/app/common/utils/psbt"; import { GlobalParamsVersion } from "@/app/types/globalParams"; diff --git a/src/utils/delegations/signUnbondingTx.ts b/src/utils/delegations/signUnbondingTx.ts index d54eac12..f641967f 100644 --- a/src/utils/delegations/signUnbondingTx.ts +++ b/src/utils/delegations/signUnbondingTx.ts @@ -1,5 +1,5 @@ +import { unbondingTransaction } from "@babylonlabs-io/btc-staking-ts"; import { Transaction, networks } from "bitcoinjs-lib"; -import { unbondingTransaction } from "btc-staking-ts"; import { getGlobalParams } from "@/app/api/getGlobalParams"; import { getUnbondingEligibility } from "@/app/api/getUnbondingEligibility"; diff --git a/src/utils/delegations/signWithdrawalTx.ts b/src/utils/delegations/signWithdrawalTx.ts index 5dff05ca..d88a3a4b 100644 --- a/src/utils/delegations/signWithdrawalTx.ts +++ b/src/utils/delegations/signWithdrawalTx.ts @@ -1,9 +1,9 @@ -import { Transaction, networks } from "bitcoinjs-lib"; import { PsbtTransactionResult, withdrawEarlyUnbondedTransaction, withdrawTimelockUnbondedTransaction, -} from "btc-staking-ts"; +} from "@babylonlabs-io/btc-staking-ts"; +import { Transaction, networks } from "bitcoinjs-lib"; import { getGlobalParams } from "@/app/api/getGlobalParams"; import { SignPsbtTransaction } from "@/app/common/utils/psbt"; diff --git a/tests/helper/index.ts b/tests/helper/index.ts index f9cbad1e..6ec4ba49 100644 --- a/tests/helper/index.ts +++ b/tests/helper/index.ts @@ -1,6 +1,10 @@ +import { + initBTCCurve, + StakingScriptData, + StakingScripts, +} from "@babylonlabs-io/btc-staking-ts"; import * as ecc from "@bitcoin-js/tiny-secp256k1-asmjs"; import * as bitcoin from "bitcoinjs-lib"; -import { StakingScriptData, StakingScripts } from "btc-staking-ts"; import ECPairFactory from "ecpair"; import { GlobalParamsVersion } from "@/app/types/globalParams"; @@ -9,6 +13,7 @@ import { getCurrentGlobalParamsVersion } from "@/utils/globalParams"; import { UTXO } from "@/utils/wallet/wallet_provider"; // Initialize the ECC library +initBTCCurve(); bitcoin.initEccLib(ecc); const ECPair = ECPairFactory(ecc); diff --git a/tests/utils/delegations/createStakingTx.test.ts b/tests/utils/delegations/createStakingTx.test.ts index 45a94929..486883f0 100644 --- a/tests/utils/delegations/createStakingTx.test.ts +++ b/tests/utils/delegations/createStakingTx.test.ts @@ -1,11 +1,7 @@ -import { initBTCCurve } from "btc-staking-ts"; - import { createStakingTx } from "@/utils/delegations/signStakingTx"; import { DEFAULT_TEST_FEE_RATE, testingNetworks } from "../../helper"; -initBTCCurve(); - describe.each(testingNetworks)( "utils/delegations/createStakingTx", ({ network, dataGenerator: dataGen }) => { diff --git a/tests/utils/delegations/signUnbondingTx.test.ts b/tests/utils/delegations/signUnbondingTx.test.ts index 0403e2eb..315a53f1 100644 --- a/tests/utils/delegations/signUnbondingTx.test.ts +++ b/tests/utils/delegations/signUnbondingTx.test.ts @@ -1,5 +1,4 @@ import { Psbt, Transaction } from "bitcoinjs-lib"; -import { initBTCCurve } from "btc-staking-ts"; import { signUnbondingTx } from "@/utils/delegations/signUnbondingTx"; @@ -16,7 +15,6 @@ jest.mock("@/app/api/postUnbonding", () => ({ })); describe("signUnbondingTx", () => { - initBTCCurve(); const { network, dataGenerator } = testingNetworks[0]; const randomTxId = dataGenerator.generateRandomTxId(); const randomGlobalParamsVersions = dataGenerator.generateGlobalPramsVersions(