Skip to content

Conversation

@Ryang-21
Copy link
Contributor

  • Migrates the rest of the util files
  • Converted javascript testing to typescript
  • Added unit testing on previously untested functions

Comment on lines +1 to +9
import xdr from "../xdr.js";
/**
* Converts a Stellar address (in G... or M... form) to an `xdr.MuxedAccount`
* structure, using the ed25519 representation when possible.
*
* This supports full muxed accounts, where an `M...` address will resolve to
* both its underlying `G...` address and an integer ID.
*
* @param address G... or M... address to encode into XDR
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only this file is contained in the manually written type declarations

@github-actions
Copy link

github-actions bot commented Feb 10, 2026

Size Change: +5.2 kB (+0.15%)

Total Size: 3.51 MB

Filename Size Change
dist/stellar-base.js 2.59 MB +3.79 kB (+0.15%)
dist/stellar-base.min.js 921 kB +1.41 kB (+0.15%)

compressed-size-action

@@ -0,0 +1,38 @@
export class StrKey {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is temporary and will be removed once the Strkey src file has been migrated

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR continues the util-to-TypeScript migration, adds/updates declaration files, and ports several util unit tests from the older JS/Mocha style to TypeScript/Vitest.

Changes:

  • Added/updated TypeScript sources and declaration outputs for util helpers and XDR re-exports.
  • Added new Vitest-based TypeScript unit tests for util modules (and removed the old JS test).
  • Added generated XDR .d.ts link files and updated formatting/config docs (changelog + prettier ignore).

Reviewed changes

Copilot reviewed 14 out of 22 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
type_validation/xdr.d.ts Adds declaration output for xdr re-export (currently has unresolved import path in type_validation).
type_validation/util/util.d.ts Adds trimEnd declaration (return type could better preserve input/output relationship).
type_validation/util/decode_encode_muxed_account.d.ts Adds declarations for muxed account helpers (currently imports a non-existent ../xdr.js within type_validation).
type_validation/util/continued_fraction.d.ts Adds best_r declaration (missing BigNumber import/type).
type_validation/util/bignumber.d.ts Adds BigNumber declaration (currently relies on globalThis.BigNumber, likely incorrect).
test/unit/util/util.test.ts Adds Vitest coverage for trimEnd (imports .js specifier that likely won’t resolve to .ts in Vitest).
test/unit/util/decode_encode_muxed_account.test.ts Adds Vitest coverage for muxed account helpers (imports .js specifiers including removed src/xdr.js).
test/unit/util/continued_fraction.test.ts Ports continued fraction tests to Vitest (imports .js specifier likely not resolvable).
test/unit/util/checksum.test.ts Updates checksum test import to .js (likely not resolvable by Vitest without extension aliasing).
test/unit/util/bignumber_test.js Removes legacy JS test.
test/unit/util/bignumber.test.ts Adds Vitest TS replacement test (imports .js specifier likely not resolvable).
src/xdr.ts Introduces TS xdr entry point; removal of src/xdr.js requires consistent resolver/shim behavior across toolchains.
src/xdr.js Removes previous JS xdr entry point.
src/util/util.ts Adds TS types to trimEnd signature (could use overloads/generic for better typing).
src/util/decode_encode_muxed_account.ts Adds TS annotations + .js-style specifiers for TS/ESM compatibility.
src/util/continued_fraction.ts Adds TS annotations and safer indexing (but BigNumber typing needs correction).
src/util/bignumber.ts Attempts to export a BigNumber type but currently does so incorrectly.
src/strkey.d.ts Adds StrKey type declarations.
src/generated/next_generated.d.ts Links generated JS XDR to types/next typings.
src/generated/curr_generated.d.ts Links generated JS XDR to types/curr typings.
config/.prettierignore Ignores CHANGELOG.md.
CHANGELOG.md Documents a breaking type change, but published types still appear to include supportMuxing.
Comments suppressed due to low confidence (4)

test/unit/util/continued_fraction.test.ts:2

  • This Vitest test imports best_r from src/util/continued_fraction.js, but the source file is src/util/continued_fraction.ts (no .js file in src). Unless Vitest is configured to resolve .js specifiers to .ts, this will fail with module-not-found. Update the test import approach or add a resolver to Vitest/Vite similar to the webpack extensionAlias setup.
    src/util/continued_fraction.ts:14
  • rawNumber: BigNumber | number | string is using the imported BigNumber value as a type. That refers to the constructor type (or will error) rather than a BigNumber instance/value type accepted by the constructor. Use an explicit BigNumber instance/value type (e.g., BigNumber.Value from bignumber.js types, or InstanceType<typeof BigNumber>), and ensure the exported BigNumber types from ./bignumber.js are correct.
    src/util/util.ts:4
  • trimEnd’s signature returns number | string, which loses the relationship between input and output types (even though the implementation returns the same kind as the input). Consider using overloads or a generic (<T extends number | string>(input: T, ...) => T) so TypeScript callers don’t need casts and get accurate return typing.
    src/util/bignumber.ts:8
  • export type { BigNumber }; is exporting a type from a value-only const BigNumber (the cloned constructor). This is not a valid type export and will fail TypeScript compilation. Define and export an explicit type alias (e.g., for the instance or constructor) or re-export the appropriate type from bignumber.js, then use that in other modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@quietbits quietbits linked an issue Feb 11, 2026 that may be closed by this pull request
5 tasks
@Ryang-21 Ryang-21 force-pushed the addition-config-changes branch from 987facb to 0b16894 Compare February 11, 2026 19:27
@Ryang-21 Ryang-21 force-pushed the finish-util-migration branch from 88ed639 to ee15c39 Compare February 11, 2026 19:32
Base automatically changed from addition-config-changes to typescript-migration February 11, 2026 19:36
@Ryang-21 Ryang-21 force-pushed the finish-util-migration branch from 731ad2b to 5046632 Compare February 11, 2026 19:39
@Ryang-21 Ryang-21 requested a review from quietbits February 11, 2026 21:42
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.

Migrate /utils files to TS

2 participants