Skip to content

refactor(sdk): remove as unknown as cast on freighterApi in base.ts - #483

Open
VeronicDev wants to merge 4 commits into
TrusTrove:mainfrom
VeronicDev:refactor/issue-311-remove-as-unknown-cast
Open

refactor(sdk): remove as unknown as cast on freighterApi in base.ts#483
VeronicDev wants to merge 4 commits into
TrusTrove:mainfrom
VeronicDev:refactor/issue-311-remove-as-unknown-cast

Conversation

@VeronicDev

Copy link
Copy Markdown
Contributor

Description

This refactor removes the double as unknown as cast pattern on freighterApi and uses the real types from @stellar/freighter-api v2 via direct import.

Before

The SDK used a complex pattern with as unknown as double casts:

import * as freighterApi from "@stellar/freighter-api";
const signTransactionFn = (freighterApi as unknown as { signTransaction?: ... }).signTransaction || ...

After

The SDK now uses direct import from the upstream package:

import { signTransaction } from "@stellar/freighter-api";

This approach relies on the real types from the upstream package, making the code more maintainable and catching breaking changes at compile time.

Related Issue

Closes #311

Closes TrusTrove#267

This fix addresses the runtime ReferenceError when users sign in by:
1. Adding initApiClientWithToken function to lib/api.ts that caches the token
2. Importing initApiClientWithToken in useAuth.ts
3. Calling initApiClientWithToken after setToken in login (success case)
4. Calling initApiClientWithToken after setToken in login (error case)
5. Calling initApiClientWithToken in logout function

Co-authored-by: openhands <openhands@all-hands.dev>
Closes TrusTrove#311

This refactor removes the double 'as unknown as' cast pattern on freighterApi
and uses the real types from @stellar/freighter-api v2 via direct import.

The SDK now uses:
  import { signTransaction } from '@stellar/freighter-api';

This approach relies on the real types from the upstream package, making
the code more maintainable and catching breaking changes at compile time
rather than masking them with made-up interfaces.

Co-authored-by: openhands <openhands@all-hands.dev>
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@openhands-agent is attempting to deploy a commit to the K1NGD4VID Team on Vercel.

A member of the Team first needs to authorize it.

@K1NGD4VID

Copy link
Copy Markdown
Contributor

This PR has merge conflicts with the base branch. CI is passing, but the branch can't be merged as-is. Please rebase or merge the base branch locally and push the update - this won't be resolved automatically.

@K1NGD4VID K1NGD4VID left a comment

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.

Auto-approved: CI passed.

@K1NGD4VID

Copy link
Copy Markdown
Contributor

Automated merge failed and a retry also failed. This needs manual investigation.

Details: Merge failed on first attempt; retry (if attempted) also failed.

@fadesany

fadesany commented Aug 1, 2026

Copy link
Copy Markdown

This PR has merge conflicts with the base branch. CI is passing, but the branch can't be merged as-is. Please rebase or merge the base branch locally and push the update - this won't be resolved automatically.

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.

[Easy] refactor(sdk): remove as unknown as cast on freighterApi in base.ts

4 participants