Skip to content

Commit

Permalink
chore(sdk): upgrade ordit-sdk 2.0.2 (#93)
Browse files Browse the repository at this point in the history
upgrade ordit-sdk 2.0.2
  • Loading branch information
kevzzsk authored Sep 28, 2023
1 parent 741271a commit 686f2cc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/ord-connect/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
22 changes: 10 additions & 12 deletions packages/ord-connect/src/hooks/useSend.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions packages/ord-connect/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ function SampleComponent() {
onClick={async () => {
const txId = await send(
"tb1qgypdud5xr0x0wugf5yv62z03ytkwxusjwsr9kq",
1,
2,
1000,
10,
);
if (typeof txId === "string") {
setResult(txId);
Expand Down
13 changes: 9 additions & 4 deletions pnpm-lock.yaml

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

0 comments on commit 686f2cc

Please sign in to comment.