Skip to content

Dp502/throw stellar account non activated error#375

Open
depressedPlumber502 wants to merge 9 commits into
mainfrom
dp502/throw-stellar-account-non-activated-error
Open

Dp502/throw stellar account non activated error#375
depressedPlumber502 wants to merge 9 commits into
mainfrom
dp502/throw-stellar-account-non-activated-error

Conversation

@depressedPlumber502
Copy link
Copy Markdown
Contributor

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

This PR introduces validation for non-activated Stellar accounts in the Hot Bridge withdrawal flow. When a destination account isn't activated, the SDK now throws StellarAccountNotActivatedError before attempting trustline validation. Changes include error class definition, validation logic, documentation updates, and test coverage.

Changes

Cohort / File(s) Summary
Error Definition & Exports
packages/intents-sdk/src/bridges/hot-bridge/error.ts, packages/intents-sdk/index.ts
Added new StellarAccountNotActivatedError class and type alias, exported from main index for public use. Error accepts destinationAddress and assetId parameters and includes detailed error messaging.
Validation Implementation
packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts
Added async account existence check in validateWithdrawal before trustline validation. Throws StellarAccountNotActivatedError if Stellar destination account does not exist; trustline check is now conditional on successful account validation. Updated JSDoc to document new error.
Documentation
packages/intents-sdk/README.md, .changeset/honest-worlds-obey.md
Renamed "Trustline Validation" section to "Account Validation" and expanded to cover both account activation and trustline checks. Updated examples to show handling for non-activated accounts. Added changeset entry documenting minor version bump.
Test Coverage
packages/intents-sdk/src/sdk.test.ts
Added new test case for estimateWithdrawalFee() rejection when account is not activated. Includes beforeEach hook with vi.resetModules() for proper test isolation and uses dynamic imports to work with runtime mocking.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

  • feat: check Stellar trustline #61 — Both PRs enhance Hot Bridge Stellar validation; this PR adds account activation checking while the referenced PR introduced trustline validation with TrustlineNotFoundError.

Suggested reviewers

  • cawabunga-bytes

Poem

🐰 A Stellar account must awake and arise,
Before tokens can flow through our bridge so wise.
We check if it's active, no trustline yet needed,
New validation paths now carefully heeded!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose, motivation, and scope of the changes related to Stellar account activation validation.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: throwing a new error for non-activated Stellar accounts, which is the central feature across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dp502/throw-stellar-account-non-activated-error

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

🦋 Changeset detected

Latest commit: 654e366

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@defuse-protocol/intents-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts`:
- Around line 279-305: The current logic calls
this.hotSdk.stellar.isTrustlineExists with token="native", which is wrong for
XLM: change the flow in the Stellar validation block so native XLM skips
trustline validation entirely — detect isXlm first; if isXlm, call an
account-existence check (e.g. this.hotSdk.stellar.isAccountExists or
fetchAccount equivalent) and on NotFoundError throw
StellarAccountNotActivatedError(args.destinationAddress, args.assetId,
assetInfo.blockchain); otherwise (non-native) call
this.hotSdk.stellar.isTrustlineExists(args.destinationAddress, token) and if it
returns false throw TrustlineNotFoundError(args.destinationAddress,
args.assetId, assetInfo.blockchain, token); preserve rethrow of unexpected
errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1dfdd291-0897-4765-8671-7fcd6ef6f23f

📥 Commits

Reviewing files that changed from the base of the PR and between fdbb764 and f5c4318.

📒 Files selected for processing (2)
  • packages/intents-sdk/index.ts
  • packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts

Comment thread packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts Outdated
Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts (1)

279-292: ⚠️ Potential issue | 🟠 Major

Handle native XLM separately from trustline boolean checks.

For native XLM, trustlines are not a meaningful requirement. If isTrustlineExists(address, "native") returns false for an activated account, this branch throws TrustlineNotFoundError incorrectly. Keep NotFoundError -> StellarAccountNotActivatedError, but avoid hasTrustline === false handling for native assets.

Suggested fix
 		if (assetInfo.blockchain === Chains.Stellar) {
 			try {
-				const token = "native" in assetInfo ? "native" : assetInfo.address;
-				const hasTrustline = await this.hotSdk.stellar.isTrustlineExists(
-					args.destinationAddress,
-					token,
-				);
-
-				if (!hasTrustline) {
-					throw new TrustlineNotFoundError(
-						args.destinationAddress,
-						args.assetId,
-						assetInfo.blockchain,
-						token,
-					);
-				}
+				if ("native" in assetInfo) {
+					// Native XLM: only verify account activation via SDK error path.
+					await this.hotSdk.stellar.isTrustlineExists(
+						args.destinationAddress,
+						"native",
+					);
+				} else {
+					const token = assetInfo.address;
+					const hasTrustline = await this.hotSdk.stellar.isTrustlineExists(
+						args.destinationAddress,
+						token,
+					);
+					if (!hasTrustline) {
+						throw new TrustlineNotFoundError(
+							args.destinationAddress,
+							args.assetId,
+							assetInfo.blockchain,
+							token,
+						);
+					}
+				}
 			} catch (error) {
 				if (error instanceof NotFoundError) {
 					throw new StellarAccountNotActivatedError(
On Stellar, are trustlines required for the native XLM asset, or only for issued assets?
#!/bin/bash
# Verify whether native-XLM behavior is explicitly tested in this repo.
rg -nP --type=ts -C3 'StellarAccountNotActivatedError|TrustlineNotFoundError|isTrustlineExists\(|native' \
  packages/intents-sdk/src/sdk.test.ts \
  packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts` around lines 279 -
292, The current check throws TrustlineNotFoundError when isTrustlineExists
returns false even for native XLM; update the logic in the block using token
(computed from "native" in assetInfo) and this.hotSdk.stellar.isTrustlineExists
so that if token === "native" you skip the trustline boolean branch (do not
throw TrustlineNotFoundError) while still mapping not-found/account errors to
StellarAccountNotActivatedError where appropriate; modify the code around
isTrustlineExists, TrustlineNotFoundError, and StellarAccountNotActivatedError
to treat native assets as exempt from trustline validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts`:
- Around line 279-292: The current check throws TrustlineNotFoundError when
isTrustlineExists returns false even for native XLM; update the logic in the
block using token (computed from "native" in assetInfo) and
this.hotSdk.stellar.isTrustlineExists so that if token === "native" you skip the
trustline boolean branch (do not throw TrustlineNotFoundError) while still
mapping not-found/account errors to StellarAccountNotActivatedError where
appropriate; modify the code around isTrustlineExists, TrustlineNotFoundError,
and StellarAccountNotActivatedError to treat native assets as exempt from
trustline validation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1a1d9f98-31d7-4284-b2f1-47d76ee6c7ba

📥 Commits

Reviewing files that changed from the base of the PR and between f5c4318 and 44f938e.

📒 Files selected for processing (2)
  • packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts
  • packages/intents-sdk/src/sdk.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/intents-sdk/src/sdk.test.ts

Copy link
Copy Markdown

@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.

♻️ Duplicate comments (1)
packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts (1)

279-293: ⚠️ Potential issue | 🟠 Major

Skip trustline validation for native XLM.

Line 280 still routes native Stellar assets through isTrustlineExists(..., "native"). Trustlines only exist for issued assets, so this can still reject an activated XLM destination with TrustlineNotFoundError before the new activation error path helps. Split this branch so native XLM only checks account existence, and keep isTrustlineExists for issued assets.

On Stellar, do trustlines apply to the native XLM asset, or only to issued assets?
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts` around lines 279 -
293, The current branch treats native Stellar as token "native" and calls
this.hotSdk.stellar.isTrustlineExists, which incorrectly rejects native XLM;
update the try block so that when assetInfo has "native" you call the Stellar
account-existence check for args.destinationAddress (use the SDK/account helper
method your project exposes, e.g., isAccountExists) instead of
isTrustlineExists, and only call this.hotSdk.stellar.isTrustlineExists for
issued assets; keep throwing TrustlineNotFoundError for missing issued-asset
trustlines and use the appropriate activation/error path when the native account
does not exist.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts`:
- Around line 279-293: The current branch treats native Stellar as token
"native" and calls this.hotSdk.stellar.isTrustlineExists, which incorrectly
rejects native XLM; update the try block so that when assetInfo has "native" you
call the Stellar account-existence check for args.destinationAddress (use the
SDK/account helper method your project exposes, e.g., isAccountExists) instead
of isTrustlineExists, and only call this.hotSdk.stellar.isTrustlineExists for
issued assets; keep throwing TrustlineNotFoundError for missing issued-asset
trustlines and use the appropriate activation/error path when the native account
does not exist.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d135dd8a-bd24-424e-a49e-1286bbc9f15a

📥 Commits

Reviewing files that changed from the base of the PR and between 44f938e and e216d36.

📒 Files selected for processing (4)
  • packages/intents-sdk/index.ts
  • packages/intents-sdk/src/bridges/hot-bridge/error.ts
  • packages/intents-sdk/src/bridges/hot-bridge/hot-bridge.ts
  • packages/intents-sdk/src/sdk.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/intents-sdk/index.ts
  • packages/intents-sdk/src/sdk.test.ts

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.

1 participant