Migrated address.js file to TS#878
Conversation
|
Size Change: -331 B (-0.01%) Total Size: 3.54 MB
|
There was a problem hiding this comment.
Pull request overview
This PR migrates the address.js file to TypeScript as address.ts, including its test file and generating appropriate type declarations. The migration adds proper type annotations while preserving all existing functionality.
Changes:
- Migrated
src/address.jsto TypeScript with type annotations for all methods and properties - Converted test file to TypeScript using vitest framework instead of Mocha/Chai
- Generated type declaration file
type_validation/address.d.ts
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/address.ts | Migrated to TypeScript with proper type annotations, import path updates (.js extensions), and conversion of JSDoc comments to TypeScript types |
| type_validation/address.d.ts | New generated TypeScript declaration file defining the Address class interface |
| test/unit/address.test.ts | Migrated test file to TypeScript using vitest framework with updated assertion syntax (toBe, toEqual, toThrow) |
| test/unit/address_test.js | Deleted old JavaScript test file |
| type_validation/memo.d.ts | Minor alphabetical reordering of MemoType union (no functional change) |
Comments suppressed due to low confidence (1)
src/address.ts:187
- The original JavaScript code was future-proof for ClaimableBalanceId V1 by reading the version from the first byte of _key:
new xdr.ClaimableBalanceId(\claimableBalanceIdTypeV${this._key.at(0)}`, this._key.subarray(1))`. The new code hardcodes to V0.
While V1 doesn't exist yet in the XDR, this creates an asymmetry: fromScAddress preserves the version byte when parsing (line 126), but toScAddress now always outputs V0. Consider adding a comment explaining this trade-off or restoring the dynamic version handling if the TypeScript XDR types support it.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| xdr.ClaimableBalanceId.claimableBalanceIdTypeV0( | ||
| this._key.subarray(1), | ||
| ), |
address.js file to TS
No description provided.