diff --git a/src/components/views/CallContractsView.tsx b/src/components/views/CallContractsView.tsx index 175ec56..abfa620 100644 --- a/src/components/views/CallContractsView.tsx +++ b/src/components/views/CallContractsView.tsx @@ -2,6 +2,7 @@ import { Box, Text, Button, TextInput, Spinner } from "@0xsequence/design-system" import { SetStateAction, useState } from "react" import { sequence } from "../../main" +import { isSentTransactionResponse } from "@0xsequence/waas" export function CallContractsView() { const [contractAddress, setContractAddress] = useState('') @@ -10,10 +11,13 @@ export function CallContractsView() { const [contractMethodArgs, setContractMethodArgs] = useState('') const [transactionHash, setTransactionHash] = useState() const [inProgress, setInProgress] = useState(false) + const [sendTransactionError, setSendTransactionError] = useState() const callContract = async () => { try { + setSendTransactionError(undefined) setInProgress(true) + const tx = await sequence.callContract({ to: contractAddress, abi: contractAbi, @@ -22,7 +26,12 @@ export function CallContractsView() { value: 0 }) - setTransactionHash(tx.data.txHash) + if (isSentTransactionResponse(tx)) { + setTransactionHash(tx.data.txHash) + } else { + setSendTransactionError(tx.data.error) + } + setInProgress(false) } catch (e) { console.error(e) @@ -89,6 +98,11 @@ export function CallContractsView() { data-id="nativeTokenSendAmount" /> + {sendTransactionError && ( + + Transaction failed: {sendTransactionError} + + )} {!inProgress ? (