Skip to content

Feat: Layerswap backend integration#701

Merged
dappsar merged 15 commits into
developfrom
feat/layerswap-integration
May 31, 2026
Merged

Feat: Layerswap backend integration#701
dappsar merged 15 commits into
developfrom
feat/layerswap-integration

Conversation

@TomasDmArg
Copy link
Copy Markdown
Collaborator

@TomasDmArg TomasDmArg commented May 13, 2026

Changes

  • A multichain deposit call-to-action was added so users could deposit to Scroll from other networks via Layerswap, expanding supported source networks to 74+ (including non-EVM and major EVM chains).
  • A new “deposit/wallet info” capability was added so users could request their wallet details and receive the same deposit guidance flow when they ask things like “I’d like to deposit”, “show my wallet”, or “how can I top up?”.

Related To

New endpoints

  • POST /deposit_info/ → 3-message sequence: intro text + wallet address + url_cta button to
    /deposit?address=<wallet>.
  • POST /multichain_deposit_cta/ → just the url_cta (no intro, no wallet echo).
  • POST /wallet_next_steps/ → 1 button message 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 (+ optional footer/button/buttons):

  • wallet_creation_intro, wallet_already_exists_intro
  • deposit_info_intro, deposit_from_other_networks (needs footer, button)
  • wallet_next_steps (needs footer, buttons[] with ids opt_deposit_other_networks, opt_buy_crypto, opt_get_balance)

Manual test

A. Wallet creation flow (new user)

  • Trigger wallet creation for a brand-new channel_user_id (e.g., via /create_wallet/).
  • Confirm WhatsApp receives 3 messages in order: (1) wallet_creation_intro localized text, (2) the raw wallet address (copy-friendly), (3) interactive button message with 3 quick-replies.
  • Repeat in es and pt to verify language fallback. Each language should NOT show English default labels.

B. Wallet creation flow (returning user)

  • Call /create_wallet/ with a channel_user_id that already has a wallet.
  • Confirm intro message uses wallet_already_exists_intro (different copy), but the address + buttons are the same.

C. Deposit info intent

  • Send POST /deposit_info/ with an existing user.
  • Confirm 3 messages: intro from deposit_info_intro, wallet address, url_cta button labeled per template button field (es: "Depositar Ahora", etc.), pointing to ${CHATTERPAY_DOMAIN}/deposit?address=<wallet>.
  • Tap the CTA on a real WhatsApp client → confirm browser opens the multichain deposit page and the address pre-fills.
  • Repeat with a brand-new 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).
  • Verify only 1 message lands in WhatsApp.

E. Wallet next-steps quick-replies

  • Tap each quick-reply (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]

  • From the CTA, deposit a small amount from a non-EVM source (Bitcoin or Solana) to the user's Scroll address.
  • Deposit from an EVM source (Polygon, Arbitrum, or Ethereum).
  • Confirm funds land in the user's Scroll wallet.

Copilot AI review requested due to automatic review settings May 13, 2026 11:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • depositUrl interpolates user_wallet_proxy directly into the query string. Use encodeURIComponent(user_wallet_proxy) (or new 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_text is hard-coded to Spanish ('Depositar Ahora'). If the template is missing a localized button, 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.body without checking it exists. If the client sends no JSON body, this will throw before you can return a 4xx. Add the same if (!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.body without checking it exists. If the client sends no JSON body, this will throw before you can return a 4xx. Add the same if (!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.

Comment thread src/services/notificationService.ts
Comment thread src/services/notificationService.ts Outdated
Comment thread src/services/notificationService.ts Outdated
Comment thread src/services/notificationService.ts Outdated
Comment thread src/controllers/walletController.ts
@TomasDmArg TomasDmArg marked this pull request as draft May 13, 2026 11:54
@TomasDmArg
Copy link
Copy Markdown
Collaborator Author

TomasDmArg commented May 13, 2026

Cambios Mongodb:

ChatterPay Dev / Local

db.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" } }
        ]
      }
    }
  }
)

TomasDmArg and others added 4 commits May 13, 2026 19:34
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>
@TomasDmArg TomasDmArg marked this pull request as ready for review May 13, 2026 22:49
@TomasDmArg TomasDmArg requested a review from dappsar May 13, 2026 22:49
@dappsar
Copy link
Copy Markdown
Collaborator

dappsar commented May 27, 2026

@TomasDmArg revisa linter

@TomasDmArg
Copy link
Copy Markdown
Collaborator Author

listo @dappsar

@dappsar dappsar merged commit 4119aa5 into develop May 31, 2026
6 checks passed
@dappsar dappsar deleted the feat/layerswap-integration branch May 31, 2026 13:08
@dappsar dappsar added the enhancement New feature or request label May 31, 2026
@dappsar dappsar linked an issue May 31, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement multichain deposits via Layerswap integration

3 participants