Skip to content

Comments

intent-sdk upgrade to alpha.9#385

Merged
nikhilkumar1612 merged 1 commit intostagingfrom
intent-sdk-update
Aug 14, 2025
Merged

intent-sdk upgrade to alpha.9#385
nikhilkumar1612 merged 1 commit intostagingfrom
intent-sdk-update

Conversation

@nikhilkumar1612
Copy link
Member

@nikhilkumar1612 nikhilkumar1612 commented Aug 14, 2025

Description

  • upgrade to intent-sdk

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • Bug Fixes

    • Normalized token addresses to checksummed format to prevent address-related issues during buy flow.
    • Improved Buy button behavior: now disables correctly on errors and when no bids are available, reducing confusion and mis-clicks.
    • Enhanced reliability of intent creation in the buy experience.
  • Chores

    • Updated intent SDK dependency to the latest alpha version for improved compatibility and stability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 14, 2025

Walkthrough

Dependency updated for @etherspot/intent-sdk. Address normalization via viem’s getAddress applied to asset fields. UserIntent shape changed: removed constraints.maxGas/permittedChains and core.permittedAccounts; added top-level account. BuyButton now accepts an error object in expressIntentResponse and adjusts disabled logic accordingly.

Changes

Cohort / File(s) Summary of changes
Dependency bump
package.json
Bumped @etherspot/intent-sdk from ^1.0.0-alpha.8 to ^1.0.0-alpha.9.
Intent address normalization & schema updates
src/apps/pulse/components/Buy/Buy.tsx, src/apps/pulse/utils/intent.ts
Used getAddress(...) as Hex for asset addresses. In Buy.tsx, removed constraints.maxGas, constraints.permittedChains, and core.permittedAccounts; added top-level account: accountAddress as Hex. Other constraints unchanged.
Buy button error-aware typing/logic
src/apps/pulse/components/Buy/BuyButton.tsx
expressIntentResponse prop expanded to `ExpressIntentResponse

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

I twitch my whiskers at version nine,
Checksum glitter on addresses fine.
Intent reshaped, accounts up top,
No gas cap here—hop, don’t stop!
If errors appear, the button will wait—
Then thump-thump-thump, we ship it straight. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch intent-sdk-update

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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

🧹 Nitpick comments (2)
package.json (1)

23-23: Bump to intent-sdk alpha.9 looks good, but consider pinning pre-release versions.

Caret ranges on pre-releases can float to newer alpha builds unexpectedly. If you want deterministic builds, prefer an exact version for alpha releases.

Apply this diff if you want to pin the version:

-    "@etherspot/intent-sdk": "^1.0.0-alpha.9",
+    "@etherspot/intent-sdk": "1.0.0-alpha.9",
src/apps/pulse/components/Buy/BuyButton.tsx (1)

52-52: Prop type widened to include error object — ensure the parent actually passes it.

BuyButton now accepts { error: string }, but in Buy.tsx the state is still ExpressIntentResponse | null and errors are only logged. If you intend to use this branch, propagate the error up so the disabled logic and UX benefit from it.

I can provide a follow-up diff in Buy.tsx to widen the state and set the error on failure if you confirm that’s desired.

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these settings in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between beb84e1 and 4a7b943.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • package.json (1 hunks)
  • src/apps/pulse/components/Buy/Buy.tsx (3 hunks)
  • src/apps/pulse/components/Buy/BuyButton.tsx (2 hunks)
  • src/apps/pulse/utils/intent.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-12T07:42:24.646Z
Learnt from: IAmKio
PR: pillarwallet/x#351
File: src/apps/pulse/utils/intent.ts:44-53
Timestamp: 2025-08-12T07:42:24.646Z
Learning: In the Pulse app's intent utilities (src/apps/pulse/utils/intent.ts), the team has chosen to use floating-point arithmetic for token amount calculations despite potential precision issues, accepting JavaScript's decimal place limitations as a valid trade-off for their use case.

Applied to files:

  • src/apps/pulse/utils/intent.ts
🔇 Additional comments (1)
src/apps/pulse/components/Buy/Buy.tsx (1)

7-7: Normalize addresses safely and confirm the UserIntent field name (account vs accountAddress)

getAddress throws on invalid input — guard with isAddress to avoid crashes. Also confirm the top-level UserIntent field name is account for alpha.9 (not accountAddress). I couldn't verify SDK/types from the provided snippet; please confirm or I can run a repo grep.

Files to check

  • src/apps/pulse/components/Buy/Buy.tsx — import (line 7) and the asset/account assignments
  • Also applies to: lines 138 and 153

Apply these minimal diffs:

-import { Hex, getAddress } from 'viem';
+import { Hex, getAddress, isAddress } from 'viem';
-                asset: getAddress(token.address) as Hex,
+                asset: (isAddress(token.address)
+                  ? getAddress(token.address)
+                  : (token.address as Hex)) as Hex,
-          account: accountAddress as Hex,
+          account: (isAddress(accountAddress)
+            ? (getAddress(accountAddress) as Hex)
+            : (accountAddress as Hex)),

Follow-up (make BuyButton error-aware so disabled state can act on expressIntent failures):

-  const [expressIntentResponse, setExpressIntentResponse] =
-    useState<ExpressIntentResponse | null>(null);
+  type IntentResult = ExpressIntentResponse | { error: string } | null;
+  const [expressIntentResponse, setExpressIntentResponse] =
+    useState<IntentResult>(null);
-        } catch (error) {
-          console.error('express intent failed:: ', error);
+        } catch (error) {
+          const message =
+            error instanceof Error ? error.message : 'Unknown error';
+          setExpressIntentResponse({ error: message });

Rendering hint for warnings (surface errors alongside "Not enough liquidity"):

const hasError =
  expressIntentResponse &&
  typeof expressIntentResponse === 'object' &&
  'error' in expressIntentResponse;

{(notEnoughLiquidity ||
  (!isLoading &&
    expressIntentResponse &&
    !hasError &&
    (expressIntentResponse as ExpressIntentResponse).bids?.length === 0) ||
  hasError) && (
  // render "Not enough liquidity" or an error message accordingly
)}

Please confirm the SDK UserIntent field name (account vs accountAddress). I can run a repo-wide grep or inspect SDK types if you want me to verify.

Comment on lines +84 to 86
!!(expressIntentResponse as { error: string }).error ||
(expressIntentResponse as ExpressIntentResponse)?.bids?.length === 0 ||
notEnoughLiquidity
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Safer error detection without type assertion.

The current check uses a forced cast which can mask mistakes. Use an in-operator guard to avoid misreads and keep type safety.

Apply this diff:

-      !!(expressIntentResponse as { error: string }).error ||
-      (expressIntentResponse as ExpressIntentResponse)?.bids?.length === 0 ||
+      (expressIntentResponse !== null &&
+        typeof expressIntentResponse === 'object' &&
+        'error' in expressIntentResponse) ||
+      (expressIntentResponse as ExpressIntentResponse)?.bids?.length === 0 ||
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
!!(expressIntentResponse as { error: string }).error ||
(expressIntentResponse as ExpressIntentResponse)?.bids?.length === 0 ||
notEnoughLiquidity
(expressIntentResponse !== null &&
typeof expressIntentResponse === 'object' &&
'error' in expressIntentResponse) ||
(expressIntentResponse as ExpressIntentResponse)?.bids?.length === 0 ||
notEnoughLiquidity
🤖 Prompt for AI Agents
In src/apps/pulse/components/Buy/BuyButton.tsx around lines 84-86, the
expression uses a forced cast (expressIntentResponse as { error: string }).error
which can mask incorrect types; replace this with a safe type-guard using the in
operator to check for the error property before reading it (e.g., ensure
expressIntentResponse is an object and 'error' in expressIntentResponse, then
coerce/check its truthiness), or extract a small type-guard helper that returns
boolean if the response has an error property, and then keep the rest of the OR
conditions unchanged.

/* eslint-disable no-restricted-syntax */
import { DispensableAsset } from '@etherspot/intent-sdk/dist/cjs/sdk/types/user-intent-types';
import { Hex } from 'viem';
import { getAddress, Hex } from 'viem';
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Guard getAddress to avoid runtime throws on invalid addresses.

viem’s getAddress throws on invalid input. Since this runs during effects, an invalid address would crash the component. Guard with isAddress to keep this path resilient.

Apply this minimal diff:

-import { getAddress, Hex } from 'viem';
+import { getAddress, isAddress, Hex } from 'viem';
-              asset: getAddress(tokenItem.address) as Hex,
+              asset: (isAddress(tokenItem.address)
+                ? getAddress(tokenItem.address)
+                : (tokenItem.address as Hex)) as Hex,

Optionally, if you prefer to skip invalid assets entirely (recommended), I can provide a slightly larger refactor that continues the loop when the address is invalid.

Also applies to: 49-49

🤖 Prompt for AI Agents
In src/apps/pulse/utils/intent.ts around lines 3 and 49, calling viem's
getAddress directly can throw on invalid input; guard calls with viem's
isAddress before invoking getAddress (or skip/continue when invalid) to prevent
runtime exceptions during effects — check isAddress(address) first, only call
getAddress(address) if true, and handle the invalid case by logging/ignoring
that asset or continuing the loop so the component does not crash.

@nikhilkumar1612 nikhilkumar1612 merged commit a39772d into staging Aug 14, 2025
6 checks passed
This was referenced Oct 23, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 14, 2025
3 tasks
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