diff --git a/packages/ord-connect/src/hooks/useBalance.tsx b/packages/ord-connect/src/hooks/useBalance.tsx index 92873b6b..2585e495 100644 --- a/packages/ord-connect/src/hooks/useBalance.tsx +++ b/packages/ord-connect/src/hooks/useBalance.tsx @@ -1,8 +1,8 @@ import { useState } from "react"; import { addressNameToType, - OrditApi, getAddressesFromPublicKey, + JsonRpcDatasource, } from "@sadoprotocol/ordit-sdk"; import { useOrdContext, Wallet } from "../providers/OrdContext.tsx"; @@ -11,6 +11,8 @@ export function useBalance(): [() => Promise, string | null, boolean] { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); + const datasource = new JsonRpcDatasource({ network }); + const getSafeBalance = async (): Promise => { setLoading(true); try { @@ -23,11 +25,11 @@ export function useBalance(): [() => Promise, string | null, boolean] { network, addressNameToType[format.payments], )[0]; - const { spendableUTXOs } = await OrditApi.fetchUnspentUTXOs({ + + const { spendableUTXOs } = await datasource.getUnspents({ address, - network, - sort: "desc", type: "spendable", + decodeMetadata: false, }); const totalCardinalsAvailable = spendableUTXOs.reduce( diff --git a/packages/ord-connect/src/hooks/useSend.tsx b/packages/ord-connect/src/hooks/useSend.tsx index 503b1d71..7ac8101b 100644 --- a/packages/ord-connect/src/hooks/useSend.tsx +++ b/packages/ord-connect/src/hooks/useSend.tsx @@ -1,5 +1,5 @@ import { useState } from "react"; -import { ordit, PSBTBuilder } from "@sadoprotocol/ordit-sdk"; +import { PSBTBuilder, JsonRpcDatasource } from "@sadoprotocol/ordit-sdk"; import { sendBtcTransaction } from "sats-connect"; import { useOrdContext, Wallet } from "../providers/OrdContext.tsx"; @@ -17,6 +17,8 @@ export function useSend(): [SendFunction, string | null, boolean] { const [error, setError] = useState(null); const [loading, setLoading] = useState(false); + const datasource = new JsonRpcDatasource({ network }); + const safeSend: SendFunction = async (toAddress, satoshis, feeRate) => { setLoading(true); try { @@ -46,10 +48,8 @@ export function useSend(): [SendFunction, string | null, boolean] { psbt: psbtBuilder.toPSBT(), }); - const txId = await ordit.transactions.relayTransaction( - signedPsbt.hex, - network, - ); + const txId = await datasource.relay({ hex: signedPsbt.hex }); + setLoading(false); return txId; } catch (err: any) {