From a15f96dcfd2f62357842fddf64045c0839b00699 Mon Sep 17 00:00:00 2001 From: Kacper Szarkiewicz Date: Mon, 23 Dec 2024 19:28:57 +0100 Subject: [PATCH 1/3] fix swap page conflicts --- src/pages/swap/index.tsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/pages/swap/index.tsx b/src/pages/swap/index.tsx index 836992ee..1e5a1983 100644 --- a/src/pages/swap/index.tsx +++ b/src/pages/swap/index.tsx @@ -1,8 +1,6 @@ import { ArrowDownIcon } from '@heroicons/react/20/solid'; import Big from 'big.js'; -import { Fragment } from 'preact'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; - import { ApiPromise } from '@polkadot/api'; import { calculateTotalReceive, FeeCollapse } from '../../components/FeeCollapse'; @@ -18,6 +16,7 @@ import { LabeledInput } from '../../components/LabeledInput'; import { UserBalance } from '../../components/UserBalance'; import { SigningBox } from '../../components/SigningBox'; import { SignInModal } from '../../components/SignIn'; +import { PoweredBy } from '../../components/PoweredBy'; import { getInputTokenDetailsOrDefault, @@ -39,6 +38,9 @@ import { showToast, ToastMessage } from '../../helpers/notifications'; import { useInputTokenBalance } from '../../hooks/useInputTokenBalance'; import { useTokenOutAmount } from '../../hooks/nabla/useTokenAmountOut'; import { useMainProcess } from '../../hooks/offramp/useMainProcess'; +import { useTermsAndConditions } from '../../hooks/useTermsAndConditions'; +import { useVortexAccount } from '../../hooks/useVortexAccount'; +import { useSwapUrlParams } from './useSwapUrlParams'; import { initialChecks } from '../../services/initialChecks'; @@ -47,10 +49,6 @@ import { ProgressPage } from '../progress'; import { FailurePage } from '../failure'; import { SuccessPage } from '../success'; import { swapConfirm } from './helpers/swapConfirm'; -import { useTermsAndConditions } from '../../hooks/useTermsAndConditions'; -import { useVortexAccount } from '../../hooks/useVortexAccount'; -import { useSwapUrlParams } from './useSwapUrlParams'; -import { PoweredBy } from '../../components/PoweredBy'; const Arrow = () => (
From e373c91653199936ede489a6dad2fc72e83ea745 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 23 Dec 2024 15:50:23 -0300 Subject: [PATCH 2/3] use specific validator for transaction store request --- .../src/api/middlewares/validators.js | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/signer-service/src/api/middlewares/validators.js b/signer-service/src/api/middlewares/validators.js index 3199ffb4..092d89a0 100644 --- a/signer-service/src/api/middlewares/validators.js +++ b/signer-service/src/api/middlewares/validators.js @@ -67,27 +67,7 @@ const validateQuoteInput = (req, res, next) => { next(); }; -const validateChangeOpInput = (req, res, next) => { - const { accountId, sequence, paymentData, maxTime, assetCode, baseFee } = req.body; - if (!accountId || !sequence || !paymentData || !maxTime) { - return res.status(400).json({ error: 'Missing required parameters' }); - } - - if (!assetCode) { - return res.status(400).json({ error: 'Missing assetCode parameter' }); - } - - if (!baseFee) { - return res.status(400).json({ error: 'Missing baseFee parameter' }); - } - - if (typeof sequence !== 'string' || typeof maxTime !== 'number') { - return res.status(400).json({ error: 'Invalid input types' }); - } - next(); -}; - -const validateRequestBodyValues = () => (req, res, next) => { +const validateRequestBodyValuesForTransactionStore = () => (req, res, next) => { const data = req.body; const offramperAddress = data.offramperAddress; if (!offramperAddress) { @@ -98,6 +78,12 @@ const validateRequestBodyValues = () => (req, res, next) => { ? DUMP_SHEET_HEADER_VALUES_EVM : DUMP_SHEET_HEADER_VALUES_ASSETHUB; + validateRequestBodyValues(requiredRequestBodyKeys)(req, res, next); +}; + +const validateRequestBodyValues = (requiredRequestBodyKeys) => (req, res, next) => { + const data = req.body; + if (!requiredRequestBodyKeys.every((key) => data[key])) { const missingItems = requiredRequestBodyKeys.filter((key) => !data[key]); const errorMessage = 'Request body data does not match schema. Missing items: ' + missingItems.join(', '); @@ -108,7 +94,7 @@ const validateRequestBodyValues = () => (req, res, next) => { next(); }; -const validateStorageInput = validateRequestBodyValues(); +const validateStorageInput = validateRequestBodyValuesForTransactionStore(); const validateEmailInput = validateRequestBodyValues(EMAIL_SHEET_HEADER_VALUES); const validateRatingInput = validateRequestBodyValues(RATING_SHEET_HEADER_VALUES); const validateExecuteXCM = validateRequestBodyValues(['id', 'payload']); From 62410fdfefce39d3f2f2b73c4b524de198b1a7e2 Mon Sep 17 00:00:00 2001 From: Gianfranco Date: Mon, 23 Dec 2024 15:54:07 -0300 Subject: [PATCH 3/3] fix previous commit --- .../src/api/middlewares/validators.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/signer-service/src/api/middlewares/validators.js b/signer-service/src/api/middlewares/validators.js index 092d89a0..51d876a7 100644 --- a/signer-service/src/api/middlewares/validators.js +++ b/signer-service/src/api/middlewares/validators.js @@ -67,6 +67,26 @@ const validateQuoteInput = (req, res, next) => { next(); }; +const validateChangeOpInput = (req, res, next) => { + const { accountId, sequence, paymentData, maxTime, assetCode, baseFee } = req.body; + if (!accountId || !sequence || !paymentData || !maxTime) { + return res.status(400).json({ error: 'Missing required parameters' }); + } + + if (!assetCode) { + return res.status(400).json({ error: 'Missing assetCode parameter' }); + } + + if (!baseFee) { + return res.status(400).json({ error: 'Missing baseFee parameter' }); + } + + if (typeof sequence !== 'string' || typeof maxTime !== 'number') { + return res.status(400).json({ error: 'Invalid input types' }); + } + next(); +}; + const validateRequestBodyValuesForTransactionStore = () => (req, res, next) => { const data = req.body; const offramperAddress = data.offramperAddress;