Feat: Layerswap backend integration#701
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds backend support for a multichain deposit call-to-action (Layerswap-style flow) and a “wallet/deposit info” capability by introducing interactive WhatsApp messages (buttons + URL CTA) and new wallet-related endpoints.
Changes:
- Added new notification templates/enum entries to support wallet intro, deposit info intro, deposit CTA, and “next steps” buttons.
- Implemented Chatizalo interactive message sending and updated notification templating to include optional footer/button/buttons.
- Added wallet endpoints to send deposit info, multichain deposit CTA, and wallet next-steps messages.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/services/securityService.test.ts | Updates mocked notification template keys to include new wallet/deposit templates. |
| test/models/templateModel.test.ts | Extends template fixture to include new notification templates used by the new flows. |
| src/types/chatizaloType.ts | Adds types for Chatizalo interactive messages (buttons + URL CTA). |
| src/services/notificationService.ts | Extends template resolution and implements wallet/deposit interactive message sequences; adds persistNotification helper changes. |
| src/services/chatizalo/chatizaloService.ts | Adds sendInteractiveMessage and consolidates axios error handling/log redaction. |
| src/models/templateModel.ts | Adds new NotificationEnum values and schema support for footer/button/buttons. |
| src/controllers/walletController.ts | Adds new handlers to trigger deposit info / multichain deposit CTA / wallet next steps. |
| src/api/walletRoutes.ts | Registers new wallet-related routes. |
Comments suppressed due to low confidence (4)
src/services/notificationService.ts:375
depositUrlinterpolatesuser_wallet_proxydirectly into the query string. UseencodeURIComponent(user_wallet_proxy)(ornew URL()/URLSearchParams) to ensure the generated URL is always valid and cannot be broken by unexpected characters.
const { title, message, footer, button } = await getNotificationTemplate(
channel_user_id,
NotificationEnum.deposit_from_other_networks
);
const depositUrl = `${CHATTERPAY_DOMAIN}/deposit?address=${user_wallet_proxy}`;
await chatizaloService.sendInteractiveMessage({
src/services/notificationService.ts:385
- Fallback
button_textis hard-coded to Spanish ('Depositar Ahora'). If the template is missing a localizedbutton, this will produce the wrong language for many users; prefer an English default (e.g. 'Deposit now') or derive the fallback from the user's language similar to how titles/messages are resolved.
message: {
type: 'url_cta',
header_text: title,
body_text: message,
footer_text: footer,
button_text: button ?? 'Depositar Ahora',
url: depositUrl
}
src/controllers/walletController.ts:328
- This handler destructures
request.bodywithout checking it exists. If the client sends no JSON body, this will throw before you can return a 4xx. Add the sameif (!request.body) ...+if (!channel_user_id) ...validation pattern used elsewhere in this controller.
export const getMultichainDepositCta = async (
request: FastifyRequest<{ Body: { channel_user_id: string } }>,
reply: FastifyReply
): Promise<FastifyReply> => {
const { channel_user_id } = request.body;
const logKey = `[op:getMultichainDepositCta:${channel_user_id}]`;
src/controllers/walletController.ts:386
- This handler destructures
request.bodywithout checking it exists. If the client sends no JSON body, this will throw before you can return a 4xx. Add the sameif (!request.body) ...+if (!channel_user_id) ...validation pattern used elsewhere in this controller.
export const getWalletNextSteps = async (
request: FastifyRequest<{ Body: { channel_user_id: string } }>,
reply: FastifyReply
): Promise<FastifyReply> => {
const { channel_user_id } = request.body;
const logKey = `[op:getWalletNextSteps:${channel_user_id}]`;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
Author
Cambios Mongodb:ChatterPay Dev / Localdb.templates.updateOne(
{},
{
"$set": {
"notifications.deposit_from_other_networks": {
"title": { "en": "Deposit from other networks", "es": "Depositar desde otras redes", "pt": "Depositar de outras redes" },
"message": { "en": "Deposit from Ethereum, Bitcoin, Solana, Polygon, Arbitrum and more.", "es": "Depositá desde Ethereum, Bitcoin, Solana, Polygon, Arbitrum y más.", "pt": "Deposite de Ethereum, Bitcoin, Solana, Polygon, Arbitrum e mais." },
"footer": { "en": "ChatterPay", "es": "ChatterPay", "pt": "ChatterPay" },
"button": { "en": "Deposit Now", "es": "Depositar Ahora", "pt": "Depositar Agora" }
},
"notifications.deposit_info_intro": {
"title": { "en": "Deposit to your ChatterPay Wallet", "es": "Depositar a tu Billetera ChatterPay", "pt": "Depositar para sua Carteira ChatterPay" },
"message": { "en": "Here is your ChatterPay wallet information.\n\nYou can receive funds on [NETWORK_NAME].\n\n⚠️ Important: If you're depositing from another app (like a wallet or exchange), make sure to use the [NETWORK_NAME] network and verify the address carefully. Transactions cannot be reversed.\n\nYour address on [NETWORK_NAME]:", "es": "Aquí está la información de tu billetera ChatterPay.\n\nPodés recibir fondos en [NETWORK_NAME].\n\n⚠️ Importante: Si vas a depositar desde otra app (como un wallet o exchange), asegurate de usar la red [NETWORK_NAME] y verificar bien la dirección. Las transacciones no se pueden revertir.\n\nTu dirección en [NETWORK_NAME]:", "pt": "Aqui estão as informações da sua carteira ChatterPay.\n\nVocê pode receber fundos em [NETWORK_NAME].\n\n⚠️ Importante: Se você for depositar de outro app (como uma carteira ou exchange), certifique-se de usar a rede [NETWORK_NAME] e verificar bem o endereço. As transações não podem ser revertidas.\n\nSeu endereço em [NETWORK_NAME]:" }
},
"notifications.wallet_already_exists_intro": {
"title": { "en": "ChatterPay: Your Wallet", "es": "ChatterPay: Tu Billetera", "pt": "ChatterPay: Sua Carteira" },
"message": { "en": "Here is your ChatterPay wallet information.\n\nYou can receive funds on [NETWORK_NAME].\n\n⚠️ Important: If you're depositing from another app (like a wallet or exchange), make sure to use the [NETWORK_NAME] network and verify the address carefully. Transactions cannot be reversed.\n\nYour address on [NETWORK_NAME]:", "es": "Aquí está la información de tu billetera ChatterPay.\n\nPodés recibir fondos en [NETWORK_NAME].\n\n⚠️ Importante: Si vas a depositar desde otra app (como un wallet o exchange), asegurate de usar la red [NETWORK_NAME] y verificar bien la dirección. Las transacciones no se pueden revertir.\n\nTu dirección en [NETWORK_NAME]:", "pt": "Aqui estão as informações da sua carteira ChatterPay.\n\nVocê pode receber fundos em [NETWORK_NAME].\n\n⚠️ Importante: Se você for depositar de outro app (como uma carteira ou exchange), certifique-se de usar a rede [NETWORK_NAME] e verificar bem o endereço. As transações não podem ser revertidas.\n\nSeu endereço em [NETWORK_NAME]:" }
},
"notifications.wallet_creation_intro": {
"title": { "en": "ChatterPay: Wallet Created!", "es": "ChatterPay: ¡Billetera creada!", "pt": "ChatterPay: Carteira criada!" },
"message": { "en": "Here is your ChatterPay wallet information.\n\nYou can receive funds on [NETWORK_NAME].\n\n⚠️ Important: If you're depositing from another app (like a wallet or exchange), make sure to use the [NETWORK_NAME] network and verify the address carefully. Transactions cannot be reversed.\n\nYour address on [NETWORK_NAME]:", "es": "Aquí está la información de tu billetera ChatterPay.\n\nPodés recibir fondos en [NETWORK_NAME].\n\n⚠️ Importante: Si vas a depositar desde otra app (como un wallet o exchange), asegurate de usar la red [NETWORK_NAME] y verificar bien la dirección. Las transacciones no se pueden revertir.\n\nTu dirección en [NETWORK_NAME]:", "pt": "Aqui estão as informações da sua carteira ChatterPay.\n\nVocê pode receber fundos em [NETWORK_NAME].\n\n⚠️ Importante: Se você for depositar de outro app (como uma carteira ou exchange), certifique-se de usar a rede [NETWORK_NAME] e verificar bem o endereço. As transações não podem ser revertidas.\n\nSeu endereço em [NETWORK_NAME]:" }
},
"notifications.wallet_next_steps": {
"title": { "en": "What would you like to do?", "es": "¿Qué querés hacer?", "pt": "O que você gostaria de fazer?" },
"message": { "en": "Your [NETWORK_NAME] wallet is all set. What would you like to do next?", "es": "Tu billetera en [NETWORK_NAME] está lista. ¿Qué te gustaría hacer ahora?", "pt": "Sua carteira na rede [NETWORK_NAME] está pronta. O que você gostaria de fazer agora?" },
"footer": { "en": "ChatterPay", "es": "ChatterPay", "pt": "ChatterPay" },
"buttons": [
{ "id": "opt_deposit_other_networks", "title": { "en": "Quick deposit", "es": "Depósito rápido", "pt": "Depósito rápido" } },
{ "id": "opt_buy_crypto", "title": { "en": "Buy crypto", "es": "Comprar crypto", "pt": "Comprar crypto" } },
{ "id": "opt_get_balance", "title": { "en": "My balance", "es": "Mi saldo", "pt": "Meu saldo" } }
]
}
}
}
) |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…mes/ChatterPay-Backend into feat/layerswap-integration
Collaborator
|
@TomasDmArg revisa linter |
Collaborator
Author
|
listo @dappsar |
dappsar
approved these changes
May 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Related To
New endpoints
POST /deposit_info/→ 3-message sequence: intro text + wallet address +url_ctabutton to/deposit?address=<wallet>.POST /multichain_deposit_cta/→ just theurl_cta(no intro, no wallet echo).POST /wallet_next_steps/→ 1buttonmessage with quick-reply options(
opt_deposit_other_networks,opt_buy_crypto,opt_get_balance).All three accept
{ channel_user_id: string }.Templates updates (mongodb)
Required keys with
title+message(+ optionalfooter/button/buttons):wallet_creation_intro,wallet_already_exists_introdeposit_info_intro,deposit_from_other_networks(needsfooter,button)wallet_next_steps(needsfooter,buttons[]with idsopt_deposit_other_networks,opt_buy_crypto,opt_get_balance)Manual test
A. Wallet creation flow (new user)
channel_user_id(e.g., via/create_wallet/).wallet_creation_introlocalized text, (2) the raw wallet address (copy-friendly), (3) interactive button message with 3 quick-replies.esandptto verify language fallback. Each language should NOT show English default labels.B. Wallet creation flow (returning user)
/create_wallet/with achannel_user_idthat already has a wallet.wallet_already_exists_intro(different copy), but the address + buttons are the same.C. Deposit info intent
POST /deposit_info/with an existing user.deposit_info_intro, wallet address,url_ctabutton labeled per templatebuttonfield (es: "Depositar Ahora", etc.), pointing to${CHATTERPAY_DOMAIN}/deposit?address=<wallet>.channel_user_id(no wallet yet) → confirm wallet is lazily created and the same flow runs.D. Standalone multichain CTA
POST /multichain_deposit_cta/→ only the URL CTA arrives (no intro, no address echo).E. Wallet next-steps quick-replies
Quick deposit,Buy crypto,My balance) → confirm Chatizalo routes each to the expected downstream flow.F. Multichain deposit on Layerswap page (end-to-end)
[Mainnet]