From ac8ea167484c8a694c5e72aa489d2e39852cb71c Mon Sep 17 00:00:00 2001 From: EVMlord <85406816+EVMlord@users.noreply.github.com> Date: Thu, 3 Apr 2025 14:42:06 -0700 Subject: [PATCH] Add 30s connectionTimeout to enhance UX --- lib/use-get-xrp.ts | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/lib/use-get-xrp.ts b/lib/use-get-xrp.ts index 700615b..a86fcf7 100644 --- a/lib/use-get-xrp.ts +++ b/lib/use-get-xrp.ts @@ -36,9 +36,16 @@ export const useGetXrp = (network: Network) => { const amount = json.amount - reserve - transferFee; - const tx = prepareBridgeTransaction(wallet.address, network, destination, amount); - - const client = new Client(networks[network].wsUrl); + const tx = prepareBridgeTransaction( + wallet.address, + network, + destination, + amount + ); + + const client = new Client(networks[network].wsUrl, { + connectionTimeout: 30000, + }); await client.connect(); const prepared = await client.autofill(tx); @@ -51,24 +58,39 @@ export const useGetXrp = (network: Network) => { }; }; -const prepareBridgeTransaction = (originAddress: string, destinationNetwork: Network, destinationAddress: string, amount: number) => { +const prepareBridgeTransaction = ( + originAddress: string, + destinationNetwork: Network, + destinationAddress: string, + amount: number +) => { const memos = [ { Memo: { - MemoData: Buffer.from("interchain_transfer").toString("hex").toUpperCase(), + MemoData: Buffer.from("interchain_transfer") + .toString("hex") + .toUpperCase(), MemoType: Buffer.from("type").toString("hex").toUpperCase(), }, }, { Memo: { - MemoData: Buffer.from(destinationAddress.slice(2)).toString("hex").toUpperCase(), - MemoType: Buffer.from("destination_address").toString("hex").toUpperCase(), + MemoData: Buffer.from(destinationAddress.slice(2)) + .toString("hex") + .toUpperCase(), + MemoType: Buffer.from("destination_address") + .toString("hex") + .toUpperCase(), }, }, { Memo: { - MemoData: Buffer.from(networks[destinationNetwork].bridgeNetwork).toString("hex").toUpperCase(), - MemoType: Buffer.from("destination_chain").toString("hex").toUpperCase(), + MemoData: Buffer.from(networks[destinationNetwork].bridgeNetwork) + .toString("hex") + .toUpperCase(), + MemoType: Buffer.from("destination_chain") + .toString("hex") + .toUpperCase(), }, }, {