diff --git a/src/components/Recovery.tsx b/src/components/Recovery.tsx index 8e351f3a9..127d86c23 100644 --- a/src/components/Recovery.tsx +++ b/src/components/Recovery.tsx @@ -73,7 +73,6 @@ import { COLORS } from "../muiTheme"; import { setRecoveryVaa as setRecoveryNFTVaa } from "../store/nftSlice"; import { setRecoveryVaa } from "../store/transferSlice"; import { - ALGORAND_HOST, ALGORAND_TOKEN_BRIDGE_ID, CHAINS, CHAINS_BY_ID, @@ -91,6 +90,7 @@ import { XPLA_LCD_CLIENT_CONFIG, getWalletAddressNative, CLUSTER, + ALGORAND_INDEXER, } from "../utils/consts"; import { getSignedVAAWithRetry } from "../utils/getSignedVAAWithRetry"; import { @@ -200,28 +200,40 @@ function handleError(e: any, enqueueSnackbar: any) { async function algo(tx: string, enqueueSnackbar: any) { try { - const algodClient = new algosdk.Algodv2( - ALGORAND_HOST.algodToken, - ALGORAND_HOST.algodServer, - ALGORAND_HOST.algodPort + const algoIndexer = new algosdk.Indexer( + ALGORAND_INDEXER.token, + ALGORAND_INDEXER.server, + ALGORAND_INDEXER.port ); - const pendingInfo = await algodClient - .pendingTransactionInformation(tx) - .do(); + const txnInfo = await algoIndexer.lookupTransactionByID(tx).do(); let confirmedTxInfo: Record | undefined = undefined; // This is the code from waitForConfirmation - if (pendingInfo !== undefined) { + if (txnInfo?.transaction !== undefined) { if ( - pendingInfo["confirmed-round"] !== null && - pendingInfo["confirmed-round"] > 0 + txnInfo?.transaction["confirmed-round"] !== null && + txnInfo?.transaction["confirmed-round"] > 0 ) { //Got the completed Transaction - confirmedTxInfo = pendingInfo; + confirmedTxInfo = txnInfo.transaction; } } if (!confirmedTxInfo) { throw new Error("Transaction not found or not confirmed"); } + if (!confirmedTxInfo["inner-txns"]) { + throw new Error("Source Tx does not refer to a valid bridge transaction"); + } + // transform the object to match the format expected by parseSequenceFromLogAlgorand + confirmedTxInfo["inner-txns"] = confirmedTxInfo["inner-txns"].map( + (innerTxn: any) => { + return { + ...innerTxn, + logs: innerTxn["logs"]?.[0] + ? [Buffer.from(innerTxn["logs"][0], "base64")] + : undefined, + }; + } + ); const sequence = parseSequenceFromLogAlgorand(confirmedTxInfo); if (!sequence) { throw new Error("Sequence not found"); diff --git a/src/utils/consts.ts b/src/utils/consts.ts index a3cb2d388..a36943a0e 100644 --- a/src/utils/consts.ts +++ b/src/utils/consts.ts @@ -784,6 +784,25 @@ export const ALGORAND_HOST = algodServer: "http://localhost", algodPort: "4001", }; +export const ALGORAND_INDEXER = + CLUSTER === "mainnet" + ? { + token: "", + server: "https://mainnet-idx.algonode.cloud", + port: "443", + } + : CLUSTER === "testnet" + ? { + token: "", + server: "https://testnet-idx.algonode.cloud", + port: "443", + } + : { + token: + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + server: "http://localhost", + port: "8980", + }; export const KARURA_HOST = CLUSTER === "mainnet" ? "https://eth-rpc-karura.aca-api.network/"