Skip to content

Conversation

@cecam
Copy link
Contributor

@cecam cecam commented May 9, 2025

Summary by CodeRabbit

  • New Features
    • Added support for multisignature (multisig) wallets, enabling transactions and allowance checks to work seamlessly in multisig environments.
  • Chores
    • Updated the package version to 0.1.20-beta.1 and added a new dependency for Safe Apps SDK.
    • Updated the changelog with new version entries.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 9, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Órale, aquí te va: Se añadieron nuevas funciones y lógica pa’ soportar carteras multisig (multifirma) en el flujo de transacciones. Ahora, varias funciones detectan si el usuario está en un entorno multisig y, si sí, usan el Safe Apps SDK pa’ mandar transacciones en vez de hacerlo directo. También se actualizó el changelog, el package y se agregó un nuevo módulo utilitario pa’ Safe.

Changes

Files / Paths Change Summary
CHANGELOG.md, package.json Se agregaron nuevas versiones beta al changelog y se subió la versión del package. Se añadió dependencia de Safe Apps SDK.
src/utils/safeFunctions.ts Nuevo módulo utilitario pa’ detectar multisig y mandar transacciones vía Safe Apps SDK.
src/hooks/useTransactionHelpers.ts Se modificaron helpers pa’ detectar multisig y rutear transacciones por Safe Apps SDK cuando aplica.
src/utils/checkAllowance.ts Ahora detecta multisig y usa la dirección del Safe pa’ checar allowance si aplica.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant SafeSDK
    participant Contract

    User->>App: Initiate transaction (approve/send)
    App->>SafeSDK: detectMultisig()
    SafeSDK-->>App: true/false
    alt Multisig detected
        App->>SafeSDK: sendViaSafe({to, abi, functionName, args})
        SafeSDK->>Contract: execute transaction via Safe
        Contract-->>SafeSDK: result
        SafeSDK-->>App: {success: true}
    else Not multisig
        App->>Contract: writeContract({to, abi, functionName, args})
        Contract-->>App: result
    end
    App-->>User: Transaction status/result
Loading

Suggested reviewers

  • luisgj

Poem

🚗💨
Multisig llegó pa’ quedarse,
con Safe SDK ahora se hace,
las transas ya no se atrasan,
puro flow de barrio, no se pasan.
Changelog y dependencias al tiro,
¡Pura vida, compa! Así respiro.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (1)
src/hooks/useTransactionHelpers.ts (1)

142-155: 🛠️ Refactor suggestion

Chequeo de allowance anda adelantado pa’ multisig – se va a quedar esperando
Con Safe la aprobación queda pendiente hasta que los owners firmen y ejecuten la tx; llamar checkAllowance inmediatamente va a fallar (el allowance sigue igual). Bríncalo o agrega polling para multisig:

-    const approveResult = await approveERC20(/* … */);
-    if (!approveResult) {
-      throw new Error("Failed to approve tokens");
-    }
-
-    updateStep({ message: "form.status.validateAllowance", type: "loading" });
-
-    await checkAllowance(/* … */);
+    const approveResult = await approveERC20(/* … */);
+    if (!approveResult) {
+      throw new Error("Failed to approve tokens");
+    }
+
+    if (!isMultisig) {
+      updateStep({ message: "form.status.validateAllowance", type: "loading" });
+      await checkAllowance(/* … */);
+      updateStep({
+        message: "form.status.validateAllowanceCompleted",
+        type: "completed",
+      });
+    }

Así evitas bloqueos falsos cuando la wallet es multisig.

🧹 Nitpick comments (3)
CHANGELOG.md (1)

5-8: Need to fix el formato de los headings, carnal

Los headings en el CHANGELOG deberían seguir una estructura jerárquica correcta. Según markdownlint, los headings solo deberían incrementar en un nivel a la vez. Deberías usar ## en lugar de ### para mantener la jerarquía adecuada.

También estaría firme agregar una descripción breve de los cambios relacionados con el soporte multisig.

-### [0.1.20-beta.1](https://github.com/bandohq/widget/compare/v0.1.20-beta.0...v0.1.20-beta.1) (2025-05-09)
+## [0.1.20-beta.1](https://github.com/bandohq/widget/compare/v0.1.20-beta.0...v0.1.20-beta.1) (2025-05-09)
+
+### Features
+
+* Added Safe Apps SDK integration for multisig support

-### [0.1.20-beta.0](https://github.com/bandohq/widget/compare/v0.1.19...v0.1.20-beta.0) (2025-05-09)
+## [0.1.20-beta.0](https://github.com/bandohq/widget/compare/v0.1.19...v0.1.20-beta.0) (2025-05-09)
+
+### Features
+
+* Initial implementation of multisig wallet support
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

src/utils/safeFunctions.ts (1)

18-30: La función sendViaSafe funciona bien pero podría tener mejor typing

La función hace su jale correctamente, pero podría beneficiarse de types explícitos de TypeScript para evitar errores. También recomendaría agregar manejo de errores más específico.

-export const sendViaSafe = async ({ to, abi, functionName, args }) => {
+interface SafeTxParams {
+  to: string;
+  abi: any[];
+  functionName: string;
+  args: any[];
+}
+
+export const sendViaSafe = async ({ to, abi, functionName, args }: SafeTxParams) => {
  const data = encodeFunctionData({
    abi,
    functionName,
    args,
  });

-  await sdk.txs.send({
-    txs: [{ to, value: "0", data }],
-  });
-
-  return { success: true };
+  try {
+    await sdk.txs.send({
+      txs: [{ to, value: "0", data }],
+    });
+    return { success: true };
+  } catch (error) {
+    console.error("Error sending transaction via Safe:", error);
+    return { success: false, error };
+  }
}
src/hooks/useTransactionHelpers.ts (1)

32-32: Estás detectando multisig varias veces – cachea el resultado
detectMultisig hace una llamada RPC (300 ms timeout). La ejecutas en cada helper; durante un mismo flujo el status no cambia. Guarda el resultado en un useRef o en contexto para evitar latencia extra.

Ejemplo rápido:

const multisigRef = useRef<Promise<boolean>>();
const isMultisig = async () => {
  if (!multisigRef.current) multisigRef.current = detectMultisig();
  return multisigRef.current;
};

Also applies to: 71-71, 129-129

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5962013 and bc61537.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • package.json (2 hunks)
  • src/hooks/useTransactionHelpers.ts (9 hunks)
  • src/utils/checkAllowance.ts (2 hunks)
  • src/utils/safeFunctions.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/utils/checkAllowance.ts (2)
src/utils/safeFunctions.ts (2)
  • detectMultisig (6-16)
  • sdk (4-4)
src/utils/abis.ts (1)
  • ERC20AllowanceABI (13-24)
src/hooks/useTransactionHelpers.ts (2)
src/utils/safeFunctions.ts (3)
  • detectMultisig (6-16)
  • sendViaSafe (18-30)
  • sdk (4-4)
src/utils/abis.ts (1)
  • ERC20ApproveABI (26-37)
🪛 markdownlint-cli2 (0.17.2)
CHANGELOG.md

5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🔇 Additional comments (6)
package.json (2)

3-3: Veo que bumpearon la versión pa' un beta release, ¡qué chido!

Esta versión beta refleja la adición de las nuevas multisig capabilities. Todo looks good.


54-54: ¡Firme! Agregaste el Safe Apps SDK pa' los multisig wallets

La adición del Safe Global SDK es crucial para implementar el soporte de carteras multifirma que se ha introducido en este PR.

src/utils/checkAllowance.ts (2)

3-3: Órale, buena onda importando las multisig functions

La integración del módulo de Safe y la detección de multisig está bien implementada aquí. Detectas el multisig environment una sola vez antes del loop, lo cual es más eficiente que hacerlo en cada intento.

Also applies to: 17-17


23-40: La lógica condicional para multisig está al cien, ese

El código maneja correctamente ambos escenarios:

  1. Para wallets multisig, usa la safe address como owner
  2. Para wallets regulares, usa la account address como antes

Este approach es sólido y permite que el mismo código funcione en ambos contextos sin problemas.

src/utils/safeFunctions.ts (2)

1-4: ¡Qué chingón! Nuevo módulo pa' Safe Apps SDK

La inicialización del SDK está bien implementada como un singleton que se puede reutilizar en toda la app.


6-16: La función detectMultisig es bien smart, carnalito

Me gusta cómo usas Promise.race con un timeout para evitar que se quede hanging cuando no estás en un Safe environment. El timeout de 300ms es un buen balance entre esperar lo suficiente y no afectar la experiencia del usuario.

@cecam cecam marked this pull request as draft May 9, 2025 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants