Skip to content

Commit

Permalink
chore: adopt latest canary version of btc-staking-ts (#150)
Browse files Browse the repository at this point in the history
* chore: adopt latest canary version of btc-staking-ts
  • Loading branch information
jrwbabylonlab authored Sep 16, 2024
1 parent fad93d7 commit a9d6f42
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 25 deletions.
25 changes: 14 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
5 changes: 4 additions & 1 deletion src/utils/apiDataToStakingScripts.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/utils/delegations/signStakingTx.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/utils/delegations/signUnbondingTx.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/utils/delegations/signWithdrawalTx.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
7 changes: 6 additions & 1 deletion tests/helper/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);

Expand Down
4 changes: 0 additions & 4 deletions tests/utils/delegations/createStakingTx.test.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
2 changes: 0 additions & 2 deletions tests/utils/delegations/signUnbondingTx.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Psbt, Transaction } from "bitcoinjs-lib";
import { initBTCCurve } from "btc-staking-ts";

import { signUnbondingTx } from "@/utils/delegations/signUnbondingTx";

Expand All @@ -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(
Expand Down

0 comments on commit a9d6f42

Please sign in to comment.