diff --git a/.changeset/moody-lobsters-cheat.md b/.changeset/moody-lobsters-cheat.md new file mode 100644 index 0000000..161b383 --- /dev/null +++ b/.changeset/moody-lobsters-cheat.md @@ -0,0 +1,5 @@ +--- +"@gobob/sats-wagmi": patch +--- + +Enable tweak signer for taproot address diff --git a/packages/sats-wagmi/package.json b/packages/sats-wagmi/package.json index 582841c..1702acd 100644 --- a/packages/sats-wagmi/package.json +++ b/packages/sats-wagmi/package.json @@ -48,7 +48,7 @@ }, "dependencies": { "@bitcoin-js/tiny-secp256k1-asmjs": "^2.2.3", - "@gobob/bob-sdk": "^3.0.3", + "@gobob/bob-sdk": "^3.1.0", "@metamask/providers": "^12.0.0", "@scure/base": "^1.1.6", "@scure/btc-signer": "^1.3.1", diff --git a/packages/sats-wagmi/src/connectors/base.ts b/packages/sats-wagmi/src/connectors/base.ts index 9ddc0ec..643e457 100644 --- a/packages/sats-wagmi/src/connectors/base.ts +++ b/packages/sats-wagmi/src/connectors/base.ts @@ -119,7 +119,7 @@ abstract class SatsConnector { return this.ordinalsAddress; } - /** Convience wrapper around the getAddressInfo function + /** Convenience wrapper around the getAddressInfo function * @param address - The address to get the type of. * @returns The address type of the address. */ diff --git a/packages/sats-wagmi/src/connectors/okx.ts b/packages/sats-wagmi/src/connectors/okx.ts index 13fe4a4..b1723fb 100644 --- a/packages/sats-wagmi/src/connectors/okx.ts +++ b/packages/sats-wagmi/src/connectors/okx.ts @@ -1,4 +1,4 @@ -import { Network } from 'bitcoin-address-validation'; +import { AddressType, Network } from 'bitcoin-address-validation'; import { okxLogo } from '../assets/okx'; @@ -157,7 +157,7 @@ class OKXConnector extends SatsConnector { return { index, publicKey, - disableTweakSigner: true + disableTweakSigner: this.getAddressType(this.paymentAddress!) !== AddressType.p2tr }; }); diff --git a/packages/sats-wagmi/src/connectors/unisat.ts b/packages/sats-wagmi/src/connectors/unisat.ts index 242e8ba..094cf66 100644 --- a/packages/sats-wagmi/src/connectors/unisat.ts +++ b/packages/sats-wagmi/src/connectors/unisat.ts @@ -1,4 +1,4 @@ -import { Network } from 'bitcoin-address-validation'; +import { AddressType, Network } from 'bitcoin-address-validation'; import { bitgetLogo } from '../assets/bitget'; @@ -200,11 +200,16 @@ class UnisatConnector extends SatsConnector { inputs.push(index); } } + + if (!this.paymentAddress) { + throw new Error('No payment address specified'); + } + const toSignInputs = inputs.map((index) => { return { index, publicKey: this.publicKey, - disableTweakSigner: true + disableTweakSigner: this.getAddressType(this.paymentAddress!) !== AddressType.p2tr }; }); diff --git a/packages/sats-wagmi/src/hooks/useBalance.tsx b/packages/sats-wagmi/src/hooks/useBalance.tsx index 080aa95..613a5b5 100644 --- a/packages/sats-wagmi/src/hooks/useBalance.tsx +++ b/packages/sats-wagmi/src/hooks/useBalance.tsx @@ -1,7 +1,7 @@ 'use client'; import { UseQueryOptions, useQuery } from '@tanstack/react-query'; -import { EsploraClient } from '@gobob/bob-sdk'; +import { getBalance } from '@gobob/bob-sdk'; import { useSatsWagmi } from '../provider'; import { INTERVAL } from '../utils'; @@ -23,17 +23,7 @@ const useBalance = (props: UseBalanceProps = {}) => { enabled: Boolean(address), queryKey: ['sats-balance', network, address], refetchInterval: INTERVAL.SECONDS_30, - queryFn: async () => { - if (!address) { - return { confirmed: BigInt(0), unconfirmed: BigInt(0), total: BigInt(0) }; - } - - const esploraClient = new EsploraClient(network); - - const { confirmed, unconfirmed, total } = await esploraClient.getBalance(address); - - return { confirmed: BigInt(confirmed), unconfirmed: BigInt(unconfirmed), total: BigInt(total) }; - }, + queryFn: () => getBalance(address), ...props }); }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b36d2dc..fe4b996 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -176,7 +176,7 @@ importers: version: 7.3.0(@swc/core@1.7.23)(ts-node@10.9.2)(typescript@5.5.4) turbo: specifier: latest - version: 2.1.3 + version: 2.3.2 typescript: specifier: ^5.2.2 version: 5.5.4 @@ -187,8 +187,8 @@ importers: specifier: ^2.2.3 version: 2.2.3 '@gobob/bob-sdk': - specifier: ^3.0.3 - version: 3.0.3 + specifier: ^3.1.0 + version: 3.1.0 '@metamask/providers': specifier: ^12.0.0 version: 12.0.0 @@ -3020,8 +3020,8 @@ packages: resolution: {integrity: sha512-X8R8Oj771YRl/w+c1HqAC1szL8zWQRwFvgDwT129k9ACdBoud/+/rX9V0qiMl6LWUdP9voC2nDVZYPMQQsb6eA==} dev: true - /@gobob/bob-sdk@3.0.3: - resolution: {integrity: sha512-apn6nir4A4wgPLsTZ7RUBJjqRVmAORdu6SDLz4RdEQ8Wrh3Gy35CV0kX28zkMkNIUI9QKSDXJCDsYrDQMYnBKQ==} + /@gobob/bob-sdk@3.1.0: + resolution: {integrity: sha512-pFuUSBROw5IcAxcgVyk7gdUTW1XomXorNxeIjC4m328ChtZ9cZqK0DKVVT7xVkwcC67+hkzFKVqGsFvTwFqQDw==} dependencies: '@scure/base': 1.1.8 '@scure/btc-signer': 1.3.2 @@ -13901,64 +13901,64 @@ packages: safe-buffer: 5.2.1 dev: true - /turbo-darwin-64@2.1.3: - resolution: {integrity: sha512-ouJOm0g0YyoBuhmikEujVCBGo3Zr0lbSOWFIsQtWUTItC88F2w2byhjtsYGPXQwMlTbXwmoBU2lOCfWNkeEwHQ==} + /turbo-darwin-64@2.3.2: + resolution: {integrity: sha512-B1lS/UqjXNsG+kx1uzJNwXMuw2i5wavcyNy8opvSLjfuECdsqQU9B1wPqkSTU+mZjFTJcEfiGKyJ/I2EVk8vdw==} cpu: [x64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-darwin-arm64@2.1.3: - resolution: {integrity: sha512-j2FOJsK4LAOtHQlb3Oom0yWB/Vi0nF1ljInr311mVzHoFAJRZtfW2fRvdZRb/lBUwjSp8be58qWHzANIcrA0OA==} + /turbo-darwin-arm64@2.3.2: + resolution: {integrity: sha512-XHeuEdk9tHaw2Bsr3rTzFtZyldeSyagDZkOSPIJ1zioavMjWEFPA75vdgy4j8ns96EBpZMaPXVEnODuEHfiZfQ==} cpu: [arm64] os: [darwin] requiresBuild: true dev: true optional: true - /turbo-linux-64@2.1.3: - resolution: {integrity: sha512-ubRHkI1gSel7H7wsmxKK8C9UlLWqg/2dkCC88LFupaK6TKgvBKqDqA0Z1M9C/escK0Jsle2k0H8bybV9OYIl4Q==} + /turbo-linux-64@2.3.2: + resolution: {integrity: sha512-oKDsO5+flqpPx5tNLFGVUYpJ/sBc3KvaGpyNzXl2u3epzyafgblFKWMG5YsSiU1ruouPpcC6YG5SN5chA7Abfg==} cpu: [x64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-linux-arm64@2.1.3: - resolution: {integrity: sha512-LffUL+e5wv7BtD6DgnM2kKOlDkMo2eRjhbAjVnrCD3wi2ug0tl6NDzajnHHjtaMyOnIf4AvzSKdLWsBxafGBQA==} + /turbo-linux-arm64@2.3.2: + resolution: {integrity: sha512-luyvTl3wQ1hF+ljK7ljH4TL7rg4pmx5pQ2mzvfMvPo5eaLuKr/tImmbdH6/vr56iffUIISkIsLVhVxgZeAsUOw==} cpu: [arm64] os: [linux] requiresBuild: true dev: true optional: true - /turbo-windows-64@2.1.3: - resolution: {integrity: sha512-S9SvcZZoaq5jKr6kA6eF7/xgQhVn8Vh7PVy5lono9zybvhyL4eY++y2PaLToIgL8G9IcbLmgOC73ExNjFBg9XQ==} + /turbo-windows-64@2.3.2: + resolution: {integrity: sha512-yw7BnTU5cE7GdUnZEW3jIAI98hh4dcWk+Jwza8X7CXpxpill2zteq7VPf+a/B3o/xm+oVXzLmP83YP91Bm0SaA==} cpu: [x64] os: [win32] requiresBuild: true dev: true optional: true - /turbo-windows-arm64@2.1.3: - resolution: {integrity: sha512-twlEo8lRrGbrR6T/ZklUIquW3IlFCEtywklgVA81aIrSBm56+GEVpSrHhIlsx1hiYeSNrs+GpDwZGe+V7fvEVQ==} + /turbo-windows-arm64@2.3.2: + resolution: {integrity: sha512-Hgp6V7jaIYlDcy5xpKN+XXyYCf5afT690GmXcEsMoUawd5dStvZe0QHWcGxuqho497BAlx0XGAWftm0KelNePA==} cpu: [arm64] os: [win32] requiresBuild: true dev: true optional: true - /turbo@2.1.3: - resolution: {integrity: sha512-lY0yj2GH2a2a3NExZ3rGe+rHUVeFE2aXuRAue57n+08E7Z7N7YCmynju0kPC1grAQzERmoLpKrmzmWd+PNiADw==} + /turbo@2.3.2: + resolution: {integrity: sha512-vCJPoy8/3KkqY3W0cX2nrwhmtBQSZhEyrVgeJ4NlEXwGxu5vNRQDyV6se5VVAQMwfBsBJswlo87B7ai7Dr1MpQ==} hasBin: true optionalDependencies: - turbo-darwin-64: 2.1.3 - turbo-darwin-arm64: 2.1.3 - turbo-linux-64: 2.1.3 - turbo-linux-arm64: 2.1.3 - turbo-windows-64: 2.1.3 - turbo-windows-arm64: 2.1.3 + turbo-darwin-64: 2.3.2 + turbo-darwin-arm64: 2.3.2 + turbo-linux-64: 2.3.2 + turbo-linux-arm64: 2.3.2 + turbo-windows-64: 2.3.2 + turbo-windows-arm64: 2.3.2 dev: true /tween-functions@1.2.0: