diff --git a/server/handlers/transferHandler.spec.js b/server/handlers/transferHandler.spec.js index 1b192e1c..f627c712 100644 --- a/server/handlers/transferHandler.spec.js +++ b/server/handlers/transferHandler.spec.js @@ -146,6 +146,7 @@ describe('transferRouter', () => { tokens: ['1'], sender_wallet: 'wallet1', receiver_wallet: 'wallet2', + claim: false, }, authenticatedWalletId, ), diff --git a/server/handlers/transferHandler/index.js b/server/handlers/transferHandler/index.js index 6edcc0f9..8d412637 100644 --- a/server/handlers/transferHandler/index.js +++ b/server/handlers/transferHandler/index.js @@ -8,11 +8,11 @@ const { } = require('./schemas'); const transferPost = async (req, res) => { - await transferPostSchema.validateAsync(req.body, { abortEarly: false }); + const validatedData = await transferPostSchema.validateAsync(req.body, { abortEarly: false }); const transferService = new TransferService(); const { result, status } = await transferService.initiateTransfer( - req.body, + validatedData, req.wallet_id, ); diff --git a/server/handlers/transferHandler/schemas.js b/server/handlers/transferHandler/schemas.js index affd107d..67a4a274 100644 --- a/server/handlers/transferHandler/schemas.js +++ b/server/handlers/transferHandler/schemas.js @@ -12,8 +12,7 @@ const transferPostSchema = Joi.alternatives() tokens: Joi.array().items(Joi.string()).required().unique(), sender_wallet: Joi.alternatives().try(Joi.string()).required(), receiver_wallet: Joi.alternatives().try(Joi.string()).required(), - // TODO: add boolean for claim, but default to false. - claim: Joi.boolean(), + claim: Joi.boolean().default(false), }), otherwise: Joi.object({ bundle: Joi.object({ @@ -21,7 +20,7 @@ const transferPostSchema = Joi.alternatives() }).required(), sender_wallet: Joi.string().required(), receiver_wallet: Joi.string().required(), - claim: Joi.boolean().required(), + claim: Joi.boolean().default(false), }), }, );