diff --git a/packages/ord-connect/package.json b/packages/ord-connect/package.json index bb029bc6..521fa544 100644 --- a/packages/ord-connect/package.json +++ b/packages/ord-connect/package.json @@ -31,7 +31,7 @@ "preview": "vite preview" }, "peerDependencies": { - "@sadoprotocol/ordit-sdk": "1.0.3", + "@sadoprotocol/ordit-sdk": "2.0.2", "react": "^18.2.0", "react-dom": "^18.2.0", "sats-connect": "^0.5.0" @@ -57,7 +57,7 @@ }, "dependencies": { "@headlessui/react": "^1.7.17", - "@sadoprotocol/ordit-sdk": "1.0.3", + "@sadoprotocol/ordit-sdk": "2.0.2", "bitcoinjs-lib": "^6.1.3", "boring-avatars": "^1.10.1", "sats-connect": "^0.5.0" diff --git a/packages/ord-connect/src/hooks/useSend.tsx b/packages/ord-connect/src/hooks/useSend.tsx index 306e8300..503b1d71 100644 --- a/packages/ord-connect/src/hooks/useSend.tsx +++ b/packages/ord-connect/src/hooks/useSend.tsx @@ -1,7 +1,7 @@ import { useState } from "react"; -import { CreatePsbtOptions, ordit } from "@sadoprotocol/ordit-sdk"; +import { ordit, PSBTBuilder } from "@sadoprotocol/ordit-sdk"; import { sendBtcTransaction } from "sats-connect"; -import { Psbt } from "bitcoinjs-lib"; + import { useOrdContext, Wallet } from "../providers/OrdContext.tsx"; import { capitalizeFirstLetter } from "../utils/text-helper"; import signPsbt from "../lib/signPsbt"; @@ -25,27 +25,25 @@ export function useSend(): [SendFunction, string | null, boolean] { throw new Error("No wallet is connected"); } - const psbtTemplate: CreatePsbtOptions = { - satsPerByte: feeRate, - network, - pubKey: publicKey.payments, + const psbtBuilder = new PSBTBuilder({ address: address.payments, + feeRate, + network, + publicKey: publicKey.payments, outputs: [ { address: toAddress, - cardinals: satoshis, + value: satoshis, }, ], - enableRBF: true, - }; + }); + await psbtBuilder.prepare(); - const createPsbtRes = await ordit.transactions.createPsbt(psbtTemplate); - const unsignedPsbt = Psbt.fromBase64(createPsbtRes.base64); const signedPsbt = await signPsbt({ address: address.payments, wallet, network, - psbt: unsignedPsbt, + psbt: psbtBuilder.toPSBT(), }); const txId = await ordit.transactions.relayTransaction( diff --git a/packages/ord-connect/src/main.tsx b/packages/ord-connect/src/main.tsx index 478c1a27..32cc98f0 100644 --- a/packages/ord-connect/src/main.tsx +++ b/packages/ord-connect/src/main.tsx @@ -27,8 +27,8 @@ function SampleComponent() { onClick={async () => { const txId = await send( "tb1qgypdud5xr0x0wugf5yv62z03ytkwxusjwsr9kq", - 1, - 2, + 1000, + 10, ); if (typeof txId === "string") { setResult(txId); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7f66cfd1..c044e877 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -27,8 +27,8 @@ importers: specifier: ^1.7.17 version: 1.7.17(react-dom@18.2.0)(react@18.2.0) '@sadoprotocol/ordit-sdk': - specifier: 1.0.3 - version: 1.0.3 + specifier: 2.0.2 + version: 2.0.2 bitcoinjs-lib: specifier: ^6.1.3 version: 6.1.3 @@ -677,14 +677,15 @@ packages: string-argv: 0.3.2 dev: true - /@sadoprotocol/ordit-sdk@1.0.3: - resolution: {integrity: sha512-zoF4RWgNvOcHDc0dy5DbLM4FeXSsF02yjfPSI0n1NGkS1bsbXknCfQ5wdOo4qg2fwuBZeDM/Mos8UmSLTUd/hw==} + /@sadoprotocol/ordit-sdk@2.0.2: + resolution: {integrity: sha512-Kzd9prpm/ndPDYsLT9qNx6VAB9yFQuxwB1yi6OK+QGPFtKDOvhKfcwcdIF0Y7cqclBiTmygW9hupjAxwl3VOlw==} dependencies: '@bitcoinerlab/secp256k1': 1.0.2 bip32: 4.0.0 bip39: 3.1.0 bitcoinjs-lib: 6.1.3 bitcoinjs-message: 2.2.0 + buffer-reverse: 1.0.1 cross-fetch: 3.1.6 ecpair: 2.1.0 ethers: 6.6.1 @@ -1513,6 +1514,10 @@ packages: engines: {node: '>=0.10.0'} dev: false + /buffer-reverse@1.0.1: + resolution: {integrity: sha512-M87YIUBsZ6N924W57vDwT/aOu8hw7ZgdByz6ijksLjmHJELBASmYTTlNHRgjE+pTsT9oJXGaDSgqqwfdHotDUg==} + dev: false + /buffer-xor@1.0.3: resolution: {integrity: sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==}