Skip to content

Commit

Permalink
refactor: upgade @noble/* packages
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed May 29, 2024
1 parent 688e363 commit 81e6af7
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 74 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"@leather-wallet/tokens": "0.4.0",
"@leather-wallet/utils": "0.6.5",
"@ledgerhq/hw-transport-webusb": "6.27.19",
"@noble/hashes": "1.3.2",
"@noble/hashes": "1.4.0",
"@noble/secp256k1": "2.0.0",
"@octokit/types": "12.4.0",
"@radix-ui/colors": "3.0.0",
Expand All @@ -155,10 +155,10 @@
"@radix-ui/react-tooltip": "1.0.7",
"@radix-ui/themes": "2.0.3",
"@reduxjs/toolkit": "2.2.3",
"@scure/base": "1.1.5",
"@scure/bip32": "1.3.3",
"@scure/base": "1.1.6",
"@scure/bip32": "1.4.0",
"@scure/bip39": "1.3.0",
"@scure/btc-signer": "1.2.1",
"@scure/btc-signer": "1.3.2",
"@segment/analytics-next": "1.70.0",
"@sentry/tracing": "7.106.0",
"@stacks/auth": "6.15.0",
Expand Down
94 changes: 57 additions & 37 deletions pnpm-lock.yaml

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

4 changes: 2 additions & 2 deletions src/app/common/psbt/requests.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isString } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionInput } from '@scure/btc-signer/psbt';
import { PsbtPayload } from '@stacks/connect';
import { decodeToken } from 'jsontokens';

Expand All @@ -9,7 +9,7 @@ export interface SignPsbtArgs {
addressNativeSegwitTotal?: Money;
addressTaprootTotal?: Money;
fee?: Money;
inputs: btc.TransactionInput[];
inputs: TransactionInput[];
}

export function getPsbtPayloadFromToken(requestToken: string): PsbtPayload {
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/loaders/bitcoin-account-loader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { P2Ret } from '@scure/btc-signer';
import { P2Ret } from '@scure/btc-signer/payment';

import { useConfigBitcoinEnabled } from '@app/query/common/remote-config/remote-config.query';
import { useCurrentAccountIndex } from '@app/store/accounts/account';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { P2Ret, P2TROut } from '@scure/btc-signer';
import type { P2Ret, P2TROut } from '@scure/btc-signer/payment';

import { ZERO_INDEX } from '@shared/constants';

Expand Down
4 changes: 2 additions & 2 deletions src/app/features/psbt-signer/hooks/use-parsed-inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from 'react';
import type { Inscription } from '@leather-wallet/models';
import { useInscriptionsByOutputs } from '@leather-wallet/query';
import { isDefined, isUndefined } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionInput } from '@scure/btc-signer/psbt';
import { bytesToHex } from '@stacks/common';

import { getBtcSignerLibNetworkConfigByMode } from '@shared/crypto/bitcoin/bitcoin.network';
Expand All @@ -24,7 +24,7 @@ export interface PsbtInput {
}

interface UseParsedInputsArgs {
inputs: btc.TransactionInput[];
inputs: TransactionInput[];
indexesToSign?: number[];
}
export function useParsedInputs({ inputs, indexesToSign }: UseParsedInputsArgs) {
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/psbt-signer/hooks/use-parsed-outputs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useMemo } from 'react';

import { isDefined, isUndefined } from '@leather-wallet/utils';
import * as btc from '@scure/btc-signer';
import type { TransactionOutput } from '@scure/btc-signer/psbt';

import { NetworkConfiguration } from '@shared/constants';
import { getBtcSignerLibNetworkConfigByMode } from '@shared/crypto/bitcoin/bitcoin.network';
Expand All @@ -20,7 +20,7 @@ export interface PsbtOutput {

interface UseParsedOutputsArgs {
isPsbtMutable: boolean;
outputs: btc.TransactionOutput[];
outputs: TransactionOutput[];
network: NetworkConfiguration;
}
export function useParsedOutputs({ isPsbtMutable, outputs, network }: UseParsedOutputsArgs) {
Expand Down
6 changes: 3 additions & 3 deletions src/app/features/psbt-signer/hooks/use-psbt-details.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useCallback, useMemo } from 'react';

import * as btc from '@scure/btc-signer';
import type { TransactionInput, TransactionOutput } from 'bitcoinjs-lib/src/psbt';

import { createMoney } from '@shared/models/money.model';

Expand All @@ -15,9 +15,9 @@ import { usePsbtInscriptions } from './use-psbt-inscriptions';
import { usePsbtTotals } from './use-psbt-totals';

interface UsePsbtDetailsArgs {
inputs: btc.TransactionInput[];
inputs: TransactionInput[];
indexesToSign?: number[];
outputs: btc.TransactionOutput[];
outputs: TransactionOutput[];
}
export function usePsbtDetails({ inputs, indexesToSign, outputs }: UsePsbtDetailsArgs) {
const network = useCurrentNetwork();
Expand Down
7 changes: 4 additions & 3 deletions src/app/features/psbt-signer/hooks/use-psbt-signer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react';
import { isString } from '@leather-wallet/utils';
import { hexToBytes } from '@noble/hashes/utils';
import * as btc from '@scure/btc-signer';
import { RawPSBTV0, RawPSBTV2 } from '@scure/btc-signer/psbt';

import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';
import { logger } from '@shared/logger';
Expand All @@ -12,7 +13,7 @@ import {
useSignBitcoinTx,
} from '@app/store/accounts/blockchain/bitcoin/bitcoin.hooks';

export type RawPsbt = ReturnType<typeof btc.RawPSBTV0.decode>;
export type RawPsbt = ReturnType<typeof RawPSBTV0.decode>;

interface SignPsbtArgs {
signingConfig: BitcoinInputSigningConfig[];
Expand All @@ -35,11 +36,11 @@ export function usePsbtSigner() {
getRawPsbt(psbt: string | Uint8Array) {
const bytes = isString(psbt) ? hexToBytes(psbt) : psbt;
try {
return btc.RawPSBTV0.decode(bytes);
return RawPSBTV0.decode(bytes);
} catch (e1) {
logger.error(`Unable to decode PSBT as v0, trying v2, ${e1}`);
try {
return btc.RawPSBTV2.decode(bytes);
return RawPSBTV2.decode(bytes);
} catch (e2) {
throw new Error(`Unable to decode PSBT, ${e1 ?? e2}`);
}
Expand Down
Loading

0 comments on commit 81e6af7

Please sign in to comment.