Skip to content

Commit dfb619a

Browse files
authored
fix(ordit-sdk): use datasource ordit-sdk 2.0 (#102)
1 parent 7a60e74 commit dfb619a

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

packages/ord-connect/src/hooks/useBalance.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { useState } from "react";
22
import {
33
addressNameToType,
4-
OrditApi,
54
getAddressesFromPublicKey,
5+
JsonRpcDatasource,
66
} from "@sadoprotocol/ordit-sdk";
77
import { useOrdContext, Wallet } from "../providers/OrdContext.tsx";
88

@@ -11,6 +11,8 @@ export function useBalance(): [() => Promise<number>, string | null, boolean] {
1111
const [error, setError] = useState<string | null>(null);
1212
const [loading, setLoading] = useState<boolean>(false);
1313

14+
const datasource = new JsonRpcDatasource({ network });
15+
1416
const getSafeBalance = async (): Promise<number> => {
1517
setLoading(true);
1618
try {
@@ -23,11 +25,11 @@ export function useBalance(): [() => Promise<number>, string | null, boolean] {
2325
network,
2426
addressNameToType[format.payments],
2527
)[0];
26-
const { spendableUTXOs } = await OrditApi.fetchUnspentUTXOs({
28+
29+
const { spendableUTXOs } = await datasource.getUnspents({
2730
address,
28-
network,
29-
sort: "desc",
3031
type: "spendable",
32+
decodeMetadata: false,
3133
});
3234

3335
const totalCardinalsAvailable = spendableUTXOs.reduce(

packages/ord-connect/src/hooks/useSend.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState } from "react";
2-
import { ordit, PSBTBuilder } from "@sadoprotocol/ordit-sdk";
2+
import { PSBTBuilder, JsonRpcDatasource } from "@sadoprotocol/ordit-sdk";
33
import { sendBtcTransaction } from "sats-connect";
44

55
import { useOrdContext, Wallet } from "../providers/OrdContext.tsx";
@@ -17,6 +17,8 @@ export function useSend(): [SendFunction, string | null, boolean] {
1717
const [error, setError] = useState<string | null>(null);
1818
const [loading, setLoading] = useState<boolean>(false);
1919

20+
const datasource = new JsonRpcDatasource({ network });
21+
2022
const safeSend: SendFunction = async (toAddress, satoshis, feeRate) => {
2123
setLoading(true);
2224
try {
@@ -46,10 +48,8 @@ export function useSend(): [SendFunction, string | null, boolean] {
4648
psbt: psbtBuilder.toPSBT(),
4749
});
4850

49-
const txId = await ordit.transactions.relayTransaction(
50-
signedPsbt.hex,
51-
network,
52-
);
51+
const txId = await datasource.relay({ hex: signedPsbt.hex });
52+
5353
setLoading(false);
5454
return txId;
5555
} catch (err: any) {

0 commit comments

Comments
 (0)