diff --git a/frontend/apps/battleship/src/features/game/components/game-process/game-process.tsx b/frontend/apps/battleship/src/features/game/components/game-process/game-process.tsx index 93590aae6..fc8886ae3 100644 --- a/frontend/apps/battleship/src/features/game/components/game-process/game-process.tsx +++ b/frontend/apps/battleship/src/features/game/components/game-process/game-process.tsx @@ -70,29 +70,34 @@ export default function GameProcess() { } }, [gameState]); + const onClickCellFinally = () => { + setDisabledCell(false); + }; + const onClickCell = async (indexCell: number) => { const gasLimit = 120000000000; if (!gasless.isLoading) { setDisabledCell(true); - checkBalance(gasLimit, () => - message({ - payload: { Turn: { step: indexCell } }, - onInBlock: (messageId) => { - if (messageId) { - setDisabledCell(false); - } - }, - gasLimit, - voucherId: gasless.voucherId, - onSuccess: () => { - setPending(false); - }, - onError: () => { - setDisabledCell(false); - }, - }), + checkBalance( + gasLimit, + () => + message({ + payload: { Turn: { step: indexCell } }, + onInBlock: (messageId) => { + if (messageId) { + onClickCellFinally(); + } + }, + gasLimit, + voucherId: gasless.voucherId, + onSuccess: () => { + setPending(false); + }, + onError: onClickCellFinally, + }), + onClickCellFinally, ); } }; @@ -164,7 +169,7 @@ export default function GameProcess() { sizeBlock={86} onClickCell={onClickCell} shipStatusArray={enemiesShips} - isDisabledCell={isDisabledCell || gasless.isLoading} + isDisabledCell={isDisabledCell || gasless.isLoading || gameState.gameOver} /> diff --git a/frontend/apps/battleship/src/features/game/components/map/mapEnemy.tsx b/frontend/apps/battleship/src/features/game/components/map/mapEnemy.tsx index cc6c6a4a9..e60f7392e 100644 --- a/frontend/apps/battleship/src/features/game/components/map/mapEnemy.tsx +++ b/frontend/apps/battleship/src/features/game/components/map/mapEnemy.tsx @@ -39,7 +39,7 @@ export default function MapEnemy({ sizeBlock = 64, shipStatusArray, onClickCell, }; const handleCellClick = (cellIndex: number) => { - if (!isDisabledCell) { + if (!isDisabledCell && !['Boom', 'BoomShip', 'DeadShip'].includes(shipStatusArray[cellIndex])) { onClickCell(cellIndex); } }; diff --git a/frontend/packages/ez-transactions/src/components/ez-gasless-transactions/ez-gasless-transactions.tsx b/frontend/packages/ez-transactions/src/components/ez-gasless-transactions/ez-gasless-transactions.tsx index 11ff411c9..9fb5a763d 100644 --- a/frontend/packages/ez-transactions/src/components/ez-gasless-transactions/ez-gasless-transactions.tsx +++ b/frontend/packages/ez-transactions/src/components/ez-gasless-transactions/ez-gasless-transactions.tsx @@ -3,13 +3,12 @@ import { useEzTransactions } from '../../context'; type Props = { disabled?: boolean; - disabledTurnOn?: boolean; }; -function EzGaslessTransactions({ disabled, disabledTurnOn }: Props) { +function EzGaslessTransactions({ disabled }: Props) { const { signless } = useEzTransactions(); - return ; + return ; } export { EzGaslessTransactions }; diff --git a/frontend/packages/gasless-transactions/src/components/enable-gasless-session/enable-gasless-session.tsx b/frontend/packages/gasless-transactions/src/components/enable-gasless-session/enable-gasless-session.tsx index 7b7e05392..b34e75aa3 100644 --- a/frontend/packages/gasless-transactions/src/components/enable-gasless-session/enable-gasless-session.tsx +++ b/frontend/packages/gasless-transactions/src/components/enable-gasless-session/enable-gasless-session.tsx @@ -9,11 +9,10 @@ import { ChangeEvent } from 'react'; type Props = { type: 'button' | 'switcher'; disabled?: boolean; - disabledTurnOn?: boolean; message?: string; }; -function EnableGaslessSession({ type, disabled, disabledTurnOn, message }: Props) { +function EnableGaslessSession({ type, disabled, message }: Props) { const { account } = useAccount(); const { isAvailable, isLoading, isEnabled, setIsEnabled } = useGaslessTransactions(); @@ -21,7 +20,7 @@ function EnableGaslessSession({ type, disabled, disabledTurnOn, message }: Props const handleEnableButtonClick = () => setIsEnabled(true); const handleDisableButtonClick = () => setIsEnabled(false); - console.log('disabledTurnOn', disabledTurnOn); + return account ? ( <> {type === 'button' && ( @@ -40,7 +39,7 @@ function EnableGaslessSession({ type, disabled, disabledTurnOn, message }: Props icon={GaslessSVG} color="transparent" text="Enable gasless transactions" - disabled={disabled || !isAvailable || isLoading || disabledTurnOn} + disabled={disabled || !isAvailable || isLoading} className={styles.enableButton} onClick={handleEnableButtonClick} /> @@ -54,7 +53,7 @@ function EnableGaslessSession({ type, disabled, disabledTurnOn, message }: Props diff --git a/frontend/packages/gasless-transactions/src/components/gasless-transactions/gasless-transactions.tsx b/frontend/packages/gasless-transactions/src/components/gasless-transactions/gasless-transactions.tsx index 4ce3f87ff..2c0412632 100644 --- a/frontend/packages/gasless-transactions/src/components/gasless-transactions/gasless-transactions.tsx +++ b/frontend/packages/gasless-transactions/src/components/gasless-transactions/gasless-transactions.tsx @@ -6,10 +6,9 @@ import { ReactComponent as GaslessSVG } from '../../assets/icons/gas-station-lin type Props = { disabled?: boolean; - disabledTurnOn?: boolean; }; -function GaslessTransactions({ disabled, disabledTurnOn }: Props) { +function GaslessTransactions({ disabled }: Props) { const { account } = useAccount(); const { isEnabled, isActive } = useGaslessTransactions(); @@ -27,7 +26,7 @@ function GaslessTransactions({ disabled, disabledTurnOn }: Props) { )} - {!isEnabled && } + {!isEnabled && } ) : null; } diff --git a/frontend/packages/signless-transactions/src/hooks/use-create-session.ts b/frontend/packages/signless-transactions/src/hooks/use-create-session.ts index 820e4ad86..1ae20d24d 100644 --- a/frontend/packages/signless-transactions/src/hooks/use-create-session.ts +++ b/frontend/packages/signless-transactions/src/hooks/use-create-session.ts @@ -165,7 +165,7 @@ function useCreateSession(programId: HexString, metadata: ProgramMetadata | unde if (!isExpired) { const declineExtrinsic = api.voucher.call(voucher.id, { DeclineVoucher: null }); - await sendTransaction(declineExtrinsic, pair, ['VoucherDeclined'], { ...options, onError }); + await sendTransaction(declineExtrinsic, pair, ['VoucherDeclined']); } if (isOwner) {