Skip to content

Additional config changes#849

Closed
Ryang-21 wants to merge 6 commits intomasterfrom
addition-config-changes
Closed

Additional config changes#849
Ryang-21 wants to merge 6 commits intomasterfrom
addition-config-changes

Conversation

@Ryang-21
Copy link
Contributor

  • Forces typescript src files to use .js extension on relative imports. This ensures imports will be esm compatible.

Ryang-21 and others added 6 commits February 5, 2026 13:37
* add tsconfigs

* update typescript version and transpile cjs build with tsc

* update testing frameworks to handle typescript

* fix type testing to check for Buffer<ArrayBufferLike>

* fix browser export and add exports field

* switch to double quotes in prettier config
* update eslint to v9 and use simplified config

* remove unused eslint disables

* replace yarn with pnpm

* update git workflows to use pnpm

* update docs to reflect pnpm usage
* Configure Vitest

* Remove Vitest globals

* Use latest Vitest
* Add test globals to ESLint configuration

* migrate util/checksum.js and add typescript testing

* add vitest testing to CI
Copilot AI review requested due to automatic review settings February 10, 2026 18:48
@Ryang-21 Ryang-21 closed this Feb 10, 2026
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 modernizes the repo’s tooling/configuration (TypeScript, linting, package manager, and test runners) and applies broad formatting/import updates across source and tests.

Changes:

  • Add TypeScript configs and a Vitest setup (including a new checksum unit test).
  • Migrate project tooling from Yarn to pnpm, update CI workflows accordingly, and switch to ESLint v9 flat config.
  • Apply widespread import/quote normalization across src/, tests, examples, and config files.

Reviewed changes

Copilot reviewed 129 out of 134 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
vitest.config.mts Adds Vitest configuration for TS test discovery.
types/test.ts Updates DTSLint expectations for Buffer generic typing.
types/.eslintrc.js Quote/style normalization for types lint config.
type_validation/util/checksum.d.ts Adds TS declaration for checksum verification utility.
tsconfig.json Root TS config for IDE/type-checking (noEmit).
tsconfig.cjs.json Adds TS build config intended for CJS compilation and declarations.
tsconfig.base.json Introduces shared strict TS compiler options.
test/unit/util/continued_fraction_test.js Quote/import normalization in Mocha unit test.
test/unit/util/checksum.test.ts Adds Vitest coverage for verifyChecksum.
test/unit/util/bignumber_test.js Quote/import normalization in Mocha unit test.
test/unit/transaction_envelope_test.js Quote normalization in Mocha unit test.
test/unit/sorobandata_builder_test.js Quote normalization in Mocha unit test.
test/unit/soroban_test.js Quote normalization in Mocha unit test.
test/unit/signing_test.js Quote normalization in Mocha unit test.
test/unit/signerkey_test.js Quote normalization in Mocha unit test.
test/unit/scint_test.js Quote normalization in Mocha unit test.
test/unit/operations/invoke_host_function_test.js Quote normalization in Mocha unit test.
test/unit/operations/extend_restore_test.js Quote normalization in Mocha unit test.
test/unit/muxed_account_test.js Quote normalization in Mocha unit test.
test/unit/memo_test.js Quote normalization in Mocha unit test.
test/unit/liquidity_pool_id_test.js Quote normalization in Mocha unit test.
test/unit/keypair_test.js Quote normalization in Mocha unit test.
test/unit/invocation_test.js Quote normalization in Mocha unit test.
test/unit/i256_test.js Quote normalization in Mocha unit test.
test/unit/hashing_test.js Quote normalization in Mocha unit test.
test/unit/events_test.js Quote normalization in Mocha unit test.
test/unit/crypto_test.js Quote normalization in Mocha unit test.
test/unit/contract_test.js Quote/import normalization in Mocha unit test.
test/unit/claimant_test.js Quote normalization in Mocha unit test.
test/unit/auth_test.js Quote normalization in Mocha unit test.
test/unit/account_test.js Quote normalization in Mocha unit test.
test/test-helper.js Replaces Babel test bootstrap with ts-node + a .js.ts resolver patch.
test/test-helper-browser.js Adds browser-only chai-as-promised wiring for Karma.
test/.eslintrc.js Quote/style normalization for test eslint config.
src/xdr.js Quote normalization for import path.
src/util/util.js Quote normalization in utility function.
src/util/decode_encode_muxed_account.js Quote normalization for imports/errors; adjusts raw encoding call quoting.
src/util/continued_fraction.js Quote normalization; removes eslint suppression comments.
src/util/checksum.ts Adds TypeScript types to verifyChecksum.
src/util/bignumber.js Quote normalization for dependency import.
src/transaction_builder.js Quote normalization across imports/constants/errors.
src/transaction_base.js Quote normalization across imports/errors; base64/hex string quoting changes.
src/transaction.js Quote normalization across imports/errors; base64/raw string quoting changes.
src/sorobandata_builder.js Quote normalization; string checks updated to double quotes.
src/soroban.js Quote normalization; token amount parsing/formatting string handling updated.
src/signing.js Quote normalization for noble import.
src/signerkey.js Quote normalization; switch arm strings updated.
src/scval.js Quote normalization; typeof and option discriminator strings updated.
src/operations/set_trustline_flags.js Quote normalization for imports/errors.
src/operations/set_options.js Quote normalization for imports/errors; removes some eslint suppression comments.
src/operations/revoke_sponsorship.js Quote normalization for imports/errors and XDR decoding encoding strings.
src/operations/restore_footprint.js Quote normalization for import.
src/operations/payment.js Quote normalization for imports/errors.
src/operations/path_payment_strict_send.js Quote normalization for imports/errors.
src/operations/path_payment_strict_receive.js Quote normalization for imports/errors.
src/operations/manage_sell_offer.js Quote normalization for imports/errors/default offerId.
src/operations/manage_data.js Quote normalization for imports/errors and string checks.
src/operations/manage_buy_offer.js Quote normalization for imports/errors/default offerId.
src/operations/liquidity_pool_withdraw.js Quote normalization; XDR fromXDR encoding string updated.
src/operations/liquidity_pool_deposit.js Quote normalization; XDR fromXDR encoding string updated.
src/operations/invoke_host_function.js Quote normalization; address type checks and asset parsing delimiter updated.
src/operations/inflation.js Quote normalization for import.
src/operations/index.js Quote normalization for operation exports.
src/operations/extend_footprint_ttl.js Quote normalization for import/error message.
src/operations/end_sponsoring_future_reserves.js Quote normalization for import.
src/operations/create_passive_sell_offer.js Quote normalization for import/errors.
src/operations/create_claimable_balance.js Quote normalization for import/errors.
src/operations/create_account.js Quote normalization for imports/errors.
src/operations/clawback_claimable_balance.js Quote normalization for imports and XDR encoding string.
src/operations/clawback.js Quote normalization for imports/errors.
src/operations/claim_claimable_balance.js Quote normalization for import/errors and XDR encoding string.
src/operations/change_trust.js Quote normalization for imports/errors/constants.
src/operations/bump_sequence.js Quote normalization for imports/errors; removes eslint suppression comment.
src/operations/begin_sponsoring_future_reserves.js Quote normalization for imports/errors.
src/operations/allow_trust.js Quote normalization; assetCode padding string updated.
src/operations/account_merge.js Quote normalization for imports/errors.
src/numbers/xdr_large_int.js Quote normalization for imports and type discriminator strings.
src/numbers/uint256.js Quote normalization for js-xdr import.
src/numbers/uint128.js Quote normalization for js-xdr import.
src/numbers/sc_int.js Quote normalization for import and type discriminator strings.
src/numbers/int256.js Quote normalization for js-xdr import.
src/numbers/int128.js Quote normalization for js-xdr import.
src/numbers/index.js Quote normalization for imports and scv switch string cases.
src/network.js Quote normalization for network passphrases.
src/muxed_account.js Quote normalization for imports/errors and id type check.
src/memo.js Quote normalization for imports/constants/errors and arm string cases.
src/liquidity_pool_id.js Quote normalization for import/errors; XDR encoding string updated.
src/liquidity_pool_asset.js Quote normalization for imports/errors and LP type strings.
src/keypair.js Quote normalization for imports/errors/type strings.
src/jsxdr.js Quote normalization for js-xdr import.
src/invocation.js Quote normalization for imports and output type strings.
src/index.js Quote normalization for imports/exports.
src/hashing.js Quote normalization; sha.js update encoding string updated.
src/get_liquidity_pool_id.js Quote normalization for imports/errors and LP type string.
src/fee_bump_transaction.js Quote normalization; base64 buffer creation quoting updated.
src/events.js Quote normalization for imports and typeof checks.
src/contract.js Quote normalization for imports.
src/claimant.js Quote normalization for imports/errors/immutability strings.
src/auth.js Quote normalization for imports; signer typeof check and TS schema strings updated.
src/asset.js Quote normalization for imports/errors; XLM/native strings and padding updated.
src/address.js Quote normalization for imports; address type discriminator strings updated.
src/account.js Quote normalization for imports/errors and sequence type check.
package.json Switches to pnpm scripts, adds exports map, changes main path, updates tooling deps, adds Vitest.
mocharc.tsnode.json Adds Mocha config file referencing the new test helper.
examples/signing-data.js Quote/import normalization in example script.
config/webpack.config.browser.js Updates webpack to support .ts entry/compilation and extension aliasing.
config/prettier.config.cjs Switches Prettier to singleQuote: false; removes explicit parser.
config/karma.conf.js Updates Karma config for pnpm-friendly explicit plugin requires; switches helper for browser.
config/eslint.config.cjs Introduces ESLint v9 flat config with TS support and ignore handling.
config/.eslintrc.js Removes legacy ESLint config file.
README.md Updates docs from Yarn to pnpm and reflows long paragraphs.
CONTRIBUTING.md Updates release instructions and formatting; updates commands to pnpm.
.vscode/settings.json Adds editor config to point ESLint/Prettier at new config files.
.github/workflows/tests.yml Updates CI to use pnpm and adds a Vitest run.
.github/workflows/npm_publish.yml Updates publish workflow to pnpm.
.github/workflows/gh_pages.yml Updates docs workflow to pnpm.
.github/workflows/format.yml Updates formatting workflow to pnpm and narrows diff check scope.
.github/workflows/bundle_size.yml Updates bundle size workflow to pnpm.
.github/ISSUE_TEMPLATE/bug_report.md Updates lockfile reference from yarn.lock to pnpm-lock.yaml.
.eslintignore Removes legacy eslintignore (replaced by flat-config ignores).

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

Comment on lines +5 to +13
"main": "./lib/cjs/index.js",
"browser": "./dist/stellar-base.min.js",
"types": "./types/index.d.ts",
"packageManager": "pnpm@9.15.3",
"exports": {
".": {
"browser": "./dist/stellar-base.min.js",
"require": "./lib/cjs/index.js",
"default": "./lib/cjs/index.js"
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

package.json now points main/exports to ./lib/cjs/index.js, but the new build:cjs uses tsc with allowJs: false (inherited from tsconfig.base.json) and there is no src/index.ts, so lib/cjs/index.js will not be emitted. This would make the published package entrypoint missing/broken. Either switch main/exports back to the Babel output location, or update the TypeScript build to actually emit an index.js entry (e.g., add a TS entrypoint or enable allowJs and compile the JS sources).

Suggested change
"main": "./lib/cjs/index.js",
"browser": "./dist/stellar-base.min.js",
"types": "./types/index.d.ts",
"packageManager": "pnpm@9.15.3",
"exports": {
".": {
"browser": "./dist/stellar-base.min.js",
"require": "./lib/cjs/index.js",
"default": "./lib/cjs/index.js"
"main": "./lib/index.js",
"browser": "./dist/stellar-base.min.js",
"types": "./types/index.d.ts",
"packageManager": "pnpm@9.15.3",
"exports": {
".": {
"browser": "./dist/stellar-base.min.js",
"require": "./lib/index.js",
"default": "./lib/index.js"

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +29
"build": "pnpm run build:cjs && pnpm run build:browser",
"build:cjs": "tsc -p tsconfig.cjs.json",
"build:node": "babel --out-dir ./lib/ ./src/",
"build:browser": "webpack -c ./config/webpack.config.browser.js",
"build:node:prod": "cross-env NODE_ENV=production yarn build",
"build:browser:prod": "cross-env NODE_ENV=production yarn build:browser",
"build:prod": "cross-env NODE_ENV=production yarn build",
"test": "yarn build && yarn test:node && yarn test:browser",
"test:node": "NODE_OPTIONS=--no-experimental-detect-module yarn _nyc mocha",
"build:node:prod": "cross-env NODE_ENV=production pnpm run build",
"build:browser:prod": "cross-env NODE_ENV=production pnpm run build:browser",
"build:prod": "cross-env NODE_ENV=production pnpm run build",
"test": "pnpm run build && pnpm run test:node && pnpm run test:browser",
"test:node": "NODE_OPTIONS=--no-experimental-detect-module pnpm run _nyc -- mocha --config ./mocharc.tsnode.json",
"test:browser": "karma start ./config/karma.conf.js",
"test:vitest": "vitest",
"test:vitest:ui": "vitest --ui",
"test:vitest:coverage": "vitest --coverage",
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

PR description says it “forces typescript src files to use .js extension on relative imports”, but this PR also migrates to pnpm, changes package entrypoints/exports, introduces new tsconfigs, adds Vitest, and replaces the ESLint configuration. Please update the PR description/scope (or split into smaller PRs) so reviewers can reason about the intended behavior and risk.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +25
if (typeof window === "undefined") {
require("ts-node").register({
project: "tsconfig.cjs.json",
files: true,
transpileOnly: true
});
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

ts-node is registered with project: "tsconfig.cjs.json", but that config inherits "allowJs": false. Since the Node tests (and src/) are .js files using import syntax, they won't be transpiled and Mocha will likely fail with syntax errors. Consider enabling allowJs (and possibly checkJs: false) for the test/runtime ts-node config, or keep the previous Babel register approach until the source is converted to TS.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +16
Module._resolveFilename = function (request, parent, ...args) {
try {
return originalResolveFilename.call(this, request, parent, ...args);
} catch (err) {
if (request.endsWith(".js")) {
return originalResolveFilename.call(
this,
request.replace(/\.js$/, ".ts"),
parent,
...args
);
}
throw err;
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

The Module._resolveFilename monkey-patch retries any .js request as .ts on any resolution error. This can mask non-MODULE_NOT_FOUND errors and make failures harder to diagnose. Consider guarding on err.code === "MODULE_NOT_FOUND" (and/or only rewriting relative paths) before retrying.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +16
{
// This file is used to compile for cjs It should exclude all test files.
"extends": "./tsconfig.base.json",
"include": ["src"],
"exclude": ["test"],

"compilerOptions": {
"outDir": "./lib/cjs",
"sourceMap": true,
"rootDir": "./src",
"module": "commonjs",
"moduleResolution": "node10",
"esModuleInterop": true,
"declaration": true,
"declarationDir": "./type_validation"
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

tsconfig.cjs.json extends the base config which sets "allowJs": false, but include is "src" and the codebase is still primarily .js. As a result, tsc -p tsconfig.cjs.json will only emit outputs for the small subset of .ts files (currently just src/util/checksum.ts), not a complete CJS build. Either enable allowJs for this build or switch the build back to Babel until the TS migration is complete.

Copilot uses AI. Check for mistakes.
Comment on lines 22 to 23
while (true) {
if (number.gt(MAX_INT)) {
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

while (true) will be flagged by ESLint's no-constant-condition rule under @eslint/js recommended rules. If the intention is an intentional infinite loop with breaks, consider rewriting as for (;;) { ... } or restoring a targeted eslint disable for this line.

Copilot uses AI. Check for mistakes.

if (preimage.length > 64) {
throw new Error('preimage cannnot be longer than 64 bytes');
throw new Error("preimage cannnot be longer than 64 bytes");
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Typo in error message: "preimage cannnot be longer than 64 bytes" (three n’s). This is user-facing and makes searching/logging harder; please correct to "cannot".

Copilot uses AI. Check for mistakes.

// handle bigints when serializing to JSON
const biHandler = (_, v) => (typeof v === 'bigint' ? v.toString() : v);
const biHandler = (_, v) => (typeof v === "bigint" ? v.toString() : v);
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Unused variable biHandler.

Copilot uses AI. Check for mistakes.
@@ -1,16 +1,16 @@
import { UnsignedHyper } from '@stellar/js-xdr';
import randomBytes from 'randombytes';
import { UnsignedHyper } from "@stellar/js-xdr";
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Unused import UnsignedHyper.

Copilot uses AI. Check for mistakes.
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