Skip to content

[Backend] sorobanService.simulateContractCall: extract STALE_THRESHOLD_MS / fee / placeholder source magic - #740

Merged
ogazboiz merged 6 commits into
LabsCrypt:mainfrom
EbukaMoses:sorobanService.simulate
Jul 1, 2026
Merged

[Backend] sorobanService.simulateContractCall: extract STALE_THRESHOLD_MS / fee / placeholder source magic#740
ogazboiz merged 6 commits into
LabsCrypt:mainfrom
EbukaMoses:sorobanService.simulate

Conversation

@EbukaMoses

@EbukaMoses EbukaMoses commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

close #640
close #791
close #793

Type of Change

  • 🐛 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 not work as expected)
  • 📚 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or update

Related Issues

Closes #

Changes Made

Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed

Test Steps

Breaking Changes

Breaking Changes:

Migration Guide:

Screenshots/Demo

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked for breaking changes and documented them if applicable

Additional Notes

@ogazboiz

ogazboiz commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

hey, main now has stricter TypeScript (#735 just merged) which exposes a real type issue:

src/services/sorobanService.ts: error TS2352:
  Conversion of type 'Hash' to type 'Uint8Array' may be a mistake
  because neither type sufficiently overlaps with the other.

addr.contractId() returns Hash (a soroban-sdk type), not Uint8Array directly. The fix is to double-cast through unknown:

new Uint8Array(addr.contractId() as unknown as ArrayBufferLike)

or use Buffer.from(addr.contractId()) if Hash has a toJSON / [Symbol.iterator]. Same change needed in both src/services/sorobanService.ts and src/workers/soroban-event-worker.ts.

once that's fixed plus a rebase on main, CI should clear.

@ogazboiz

ogazboiz commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

two distinct build failures here:

  1. src/services/sorobanService.ts:74Account (and TransactionBuilder, Networks) is now undeclared. you dropped the const { TransactionBuilder, Account, Networks } = await import(...) but the function still uses all three. either add a top-level static import:

    import { TransactionBuilder, Account, Networks } from '@stellar/stellar-sdk';

    or keep the dynamic import.

  2. src/services/sorobanService.ts:57 and src/workers/soroban-event-worker.ts:55hash as Uint8Array is still flagged because Hash and Uint8Array don't overlap structurally in TS. the cast needs to bridge through unknown:

    return StrKey.encodeContract(Buffer.from(hash as unknown as Uint8Array));

    or if Hash exposes a .value() getter that returns the buffer, use that directly: Buffer.from(hash.value()).

once those build, this PR's scope (the constant extraction) is fine to land.

if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

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

clean readability refactor, the magic literals (fees 100/1000, the 30s timeout, the simulation placeholder account) are pulled into named, documented constants with no behavior change, and the STALE_THRESHOLD_MS doc is a nice touch. ci is green. merging.

@ogazboiz
ogazboiz merged commit 9a89583 into LabsCrypt:main Jul 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants