diff --git a/packages/features/src/send/hooks/use-transaction-confirmation.tsx b/packages/features/src/send/hooks/use-transaction-confirmation.tsx index 893d1f4e..4ed2868e 100644 --- a/packages/features/src/send/hooks/use-transaction-confirmation.tsx +++ b/packages/features/src/send/hooks/use-transaction-confirmation.tsx @@ -2,10 +2,6 @@ import type { ChainOperationArgs } from "@palladxyz/key-management" import { Mina } from "@palladxyz/mina-core" import { useVault } from "@palladxyz/vault" import dayjs from "dayjs" -import type { - Payment, - SignedLegacy, -} from "mina-signer/dist/node/mina-signer/src/TSTypes" import type { SubmitHandler, UseFormReturn } from "react-hook-form" import { useMixpanel } from "react-mixpanel-browser" import { useNavigate } from "react-router-dom" @@ -29,14 +25,11 @@ export const useTransactionConfirmation = ({ }: UseTransactionConfirmationProps) => { const mixpanel = useMixpanel() const navigate = useNavigate() - // can use - // const request = useVault((state) => state.request) for signing const sign = useVault((state) => state.sign) const submitTx = useVault((state) => state.submitTx) const constructTx = useVault((state) => state.constructTx) const syncWallet = useVault((state) => state._syncWallet) const currentNetworkName = useVault((state) => state.currentNetworkName) - //const currentWallet = useVault((state) => state.getCurrentWallet()) const { publicKey, data: accountProperties } = useAccount() const outgoingTransaction = useTransactionStore( (state) => state.outgoingTransaction, @@ -48,7 +41,7 @@ export const useTransactionConfirmation = ({ const rawFee = outgoingTransaction.fee || 0.001 const amount = BigInt(rawAmount * 1_000_000_000).toString() const fee = BigInt(rawFee * 1_000_000_000).toString() - const rawTransaction: Mina.TransactionBody = { + const rawTransaction = { to: outgoingTransaction.to, from: publicKey, memo: outgoingTransaction.memo, @@ -56,19 +49,11 @@ export const useTransactionConfirmation = ({ fee, amount, nonce: accountProperties?.inferredNonce ?? 0, // need a util for this whole `onSubmit` to remove Mina dependency - type, - } - const constructTransaction = () => { - const constructTxArgs = { - transaction: rawTransaction, - transactionType: type, - } - return constructTx(constructTxArgs) } const submitTransaction: SubmitHandler = async ( data, ) => { - const constructedTx = await constructTransaction() + const constructedTx = constructTx({ transaction: rawTransaction }) const getPassphrase = () => utf8ToBytes(data.spendingPassword) let signedTx // TODO: make chain agnostic depending on the currentWallet chain and it's corresponding operation e.g. 'eth_signTransaction' vs 'mina_signTransaction' @@ -78,7 +63,11 @@ export const useTransactionConfirmation = ({ networkType: currentNetworkName === "Mainnet" ? "mainnet" : "testnet", } try { - signedTx = await sign(constructedTx as any, operationArgs, getPassphrase) + signedTx = await sign( + { transaction: constructedTx }, + operationArgs, + getPassphrase, + ) } catch (error: unknown) { if (error instanceof Error) { if (error.name === "AuthenticationError") @@ -88,9 +77,8 @@ export const useTransactionConfirmation = ({ }) } } - // TODO: Make a util for this const submitTxArgs = { - signedTransaction: signedTx as unknown as SignedLegacy, + signedTransaction: signedTx as never, type, transactionDetails: { fee: rawTransaction.fee, @@ -102,7 +90,7 @@ export const useTransactionConfirmation = ({ validUntil: rawTransaction.validUntil, }, } - const submittedTx = (await submitTx(submitTxArgs as any)) as any + const submittedTx = (await submitTx(submitTxArgs)) as any const hash = submittedTx?.sendPayment?.payment?.hash ?? submittedTx?.sendDelegation?.delegation?.hash