Skip to content

P-934: SDK: Crossmint integration#26

Merged
keiloktql merged 2 commits into
mainfrom
keilok/crossmint-integration
May 19, 2026
Merged

P-934: SDK: Crossmint integration#26
keiloktql merged 2 commits into
mainfrom
keilok/crossmint-integration

Conversation

@keiloktql
Copy link
Copy Markdown
Member

@keiloktql keiloktql commented May 19, 2026

export-1779174674579.mp4

Summary

Adds with-crossmint — a Next.js 15 App Router example demonstrating the Formo Analytics SDK with Crossmint embedded wallets (P-934). Crossmint wallets are ERC-4337 smart contracts created via email/Google login — they expose no window.ethereum and no wagmi config, so Formo's autocapture hooks have nothing to latch onto. The example explicitly disables autocapture and wires every wallet event by hand, making it the canonical reference for integrating Formo with any embedded/smart-contract wallet.

Key Changes

New example (with-crossmint/):

  • Forked from Crossmint/wallets-quickstart; added @formo/analytics dependency and NEXT_PUBLIC_FORMO_WRITE_KEY env var — Crossmint key required, Formo key optional (app runs untracked without it)
  • app/providers.tsx — wraps the Crossmint provider tree with FormoAnalyticsProvider; autocapture: false and evm: false are set explicitly with comments explaining why (no EIP-1193 / wagmi)
  • lib/chain.ts — single source for CHAIN_NAME = "base-sepolia" and CHAIN_ID = 84532; both the Crossmint wallet config and all Formo event payloads derive from here

Formo instrumentation:

  • components/formo-bridge.tsx — render-null component mounted inside CrossmintWalletProvider; fires identify + connect once the wallet is ready (waits for user.id so the userId is never missing from the identity call), and disconnect on logout
  • components/transfer.tsx — wraps wallet.send() with TransactionStatus.STARTEDBROADCASTED (carrying txn.hash) and emits a crossmint_transfer custom track event on success; REJECTED is emitted only for AuthRejectedError (explicit user cancel) — operational failures are not labelled as user rejections
  • components/formo-event-tester.tsx — UI panel with "Sign message" (signature event via EVMWallet.from(wallet).signMessage()) and "Track custom event" buttons, covering the remaining event types

Fixes from post-implementation Codex review:

  • transfer.tsx: wallet.send() now receives amountInput (raw user-typed string) instead of amount.toString() — eliminates float-to-string rounding risk on small or high-precision values
  • providers.tsx: replaced as never chain cast with as "base-sepolia" plus a comment pointing to lib/chain.ts

Repo:

  • Root README.md — added with-crossmint entry under Wallet Integrations

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

@keiloktql keiloktql requested a review from yosriady May 19, 2026 07:12
@keiloktql keiloktql self-assigned this May 19, 2026
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 19, 2026

P-934

@yosriady
Copy link
Copy Markdown
Contributor

@codex review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new example project, with-crossmint, demonstrating the integration of Formo Analytics with Crossmint embedded wallets in a Next.js 15 environment. The implementation highlights manual event instrumentation for identification, connection, transactions, and signatures, which is necessary for smart wallets that do not expose standard providers. Reviewer feedback suggests improving type safety by defining interfaces for transfer objects, enhancing the user interface by replacing alert calls with more modern error handling, and implementing stricter validation for chain-related environment variables.

Comment thread with-crossmint/components/activity.tsx Outdated
) : transfers?.data && transfers.data.length > 0 ? (
<div className="flex-1 overflow-hidden">
<div className="max-h-[378px] overflow-y-auto space-y-3">
{transfers.data.map((tx: any, index: number) => {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Avoid using any for the tx object. Define an interface or type that reflects the structure of the transfer object to improve type safety and maintainability.

Comment thread with-crossmint/components/balance.tsx Outdated
setBalances(balances);
} catch (error) {
console.error("Error fetching wallet balances:", error);
alert("Error fetching wallet balances: " + error);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using alert for error handling is poor UX. Consider using a state-based error message or a toast notification to display errors to the user.

Comment thread with-crossmint/components/transfer.tsx Outdated
} else {
// Operational failure (network, sponsorship, validation) — not a user
// rejection. We don't emit REJECTED here so analytics stay accurate.
alert("Transfer: " + err);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Using alert for error handling is poor UX. Consider using a state-based error message or a toast notification to display errors to the user.

Comment thread with-crossmint/app/providers.tsx Outdated
// Cast to the Crossmint chain literal type. The matching numeric chain ID
// (84532) lives in lib/chain.ts and is used for Formo events — keep them in
// sync when changing chains.
const chain = (process.env.NEXT_PUBLIC_CHAIN ?? "base-sepolia") as "base-sepolia";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The type cast as 'base-sepolia' is unsafe if NEXT_PUBLIC_CHAIN is set to a different value. Validate the environment variable against a list of supported chains instead.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9b75cce95

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread with-crossmint/package.json Outdated
"@crossmint/client-sdk-react-ui": "4.2.0",
"@formo/analytics": "^1.30.0",
"clsx": "^2.1.1",
"next": "15.2.8",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Upgrade Next.js past the vulnerable 15.2.8 release

This new example pins next to 15.2.8, which is in the affected range for GHSA-c4j6-fc7j-m34r/CVE-2026-44578 (>=13.4.13 <15.5.16): when someone follows the README and self-hosts with pnpm build/pnpm start, the built-in Next.js Node server can be exposed to SSRF via crafted WebSocket upgrade requests, potentially reaching internal services or cloud metadata. Please bump to a patched 15.x release (the repo’s other examples are already on 15.5.18) and refresh the lockfile.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please address this before merging

@yosriady
Copy link
Copy Markdown
Contributor

Afterwards please add the new examples to https://docs.formo.so/sdks/web#code-examples

@keiloktql
Copy link
Copy Markdown
Member Author

Afterwards please add the new examples to https://docs.formo.so/sdks/web#code-examples

will follow up on this after angular SDK

@keiloktql keiloktql merged commit 85584d9 into main May 19, 2026
4 checks passed
@keiloktql keiloktql deleted the keilok/crossmint-integration branch May 19, 2026 08:03
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