Skip to content

PRB Feedback for TypeScript#203

Merged
andreivladbrg merged 16 commits intomainfrom
prb-feedback
Jul 28, 2025
Merged

PRB Feedback for TypeScript#203
andreivladbrg merged 16 commits intomainfrom
prb-feedback

Conversation

@PaulRBerg PaulRBerg requested review from IaroslavMazur and andreivladbrg and removed request for andreivladbrg July 25, 2025 08:24
@PaulRBerg
Copy link
Copy Markdown
Member Author

fixing the conflicts now

@PaulRBerg PaulRBerg force-pushed the prb-feedback branch 2 times, most recently from 817f39d to 20e8307 Compare July 25, 2025 09:33
@PaulRBerg PaulRBerg force-pushed the prb-feedback branch 5 times, most recently from 3e94dc9 to f1636f7 Compare July 25, 2025 14:46
- Add codegen error codes
- Use namespaces for test defaults
- Use helpers to convert to and from BN
- Fixed versions for Solana and Anchor CLI
- Add constants, e.g., ZERO
- Move shared TypeScript logic to "lib" directory
- Setup husky and lint-staged
- Switch to BUSL license
- Migrate from mocha to vitest
- Use only bn.js for big numbers
- Format files with biome
- Major refactoring improvements
ci: skip build and tests if cache is identical
ci: suppress annoying anchor build logs
@andreivladbrg
Copy link
Copy Markdown
Member

@PaulRBerg in order to move faster with the review process, i'll leave questions sequentially

i hope it works for you

Comment thread justfile Outdated
Comment thread .prettierignore
Comment thread CONTRIBUTING.md Outdated
Comment thread CONTRIBUTING.md Outdated
Comment thread LICENSE.md
Comment thread justfile Outdated
Comment thread justfile Outdated
Comment thread CONTRIBUTING.md
Copy link
Copy Markdown
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

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

left a few more comments

btw, as always, you're very good with structural changes 🫡 - it's much better organized (i suppose the SDK work made you a pro at TS 😆)

Comment thread lib/types.ts
Comment thread scripts/ts/codegen-errors.ts
Comment thread programs/merkle_instant/Cargo.toml
Comment thread tests/common/assertions.ts
Comment thread tests/common/context.ts
Comment thread tests/common/context.ts
Comment thread vitest.config.ts
Copy link
Copy Markdown
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

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

just had a look at the new .test files

they seem to be the same tests, just refactored to the context pattern + vitest - the removal of try/catch makes the code considerably more readable

gj again👌

Comment thread tests/lockup/utils/defaults.ts
Comment thread tests/lockup/utils/types.ts
@PaulRBerg
Copy link
Copy Markdown
Member Author

Thanks @andreivladbrg for your feedback - glad you like the new structure!

style: indenting for even-better-toml
@PaulRBerg
Copy link
Copy Markdown
Member Author

nice one with d076eb2, @andreivladbrg!

refactor: dry codegen script utils
@PaulRBerg
Copy link
Copy Markdown
Member Author

Alright, we now also have auto-generated struct types. Can you plz review @andreivladbrg @IaroslavMazur?

Copy link
Copy Markdown
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

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

left few more comments on the new codegen scripts

Comment thread scripts/ts/common/codegen-utils.ts Outdated
Comment thread scripts/ts/common/codegen-utils.ts
Comment thread scripts/ts/common/codegen-utils.ts Outdated
Comment thread scripts/ts/common/codegen-utils.ts Outdated
Comment thread scripts/ts/codegen-structs.ts
Comment thread scripts/ts/common/codegen-utils.ts Outdated
Comment thread scripts/ts/common/codegen-utils.ts Outdated
Comment thread scripts/ts/codegen-structs.ts
Copy link
Copy Markdown
Member

@IaroslavMazur IaroslavMazur left a comment

Choose a reason for hiding this comment

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

Great stuff, @PaulRBerg! 👏 Appreciate the numerous optimisations and simplifications! 💪

Pushed some small changes in 2492604 - and leaving the rest of my feedback below.

Comment thread tests/common/assertions.ts Outdated
Comment thread tests/common/assertions.ts Outdated
Comment thread tests/common/assertions.ts
Comment thread lib/constants.ts Outdated
Comment thread tests/lockup/unit/collectFees.test.ts Outdated
Comment thread README.md Outdated
Comment thread scripts/ts/codegen-errors.ts
Comment thread tests/merkle-instant/unit/initialize.test.ts Outdated
import { PublicKey } from "@solana/web3.js";
import { type PublicKey } from "@solana/web3.js";
import type BN from "bn.js";
import keccak256 from "keccak256";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Getting the following TS warning for keccak256, as well as BN:

Module '"/Users/iaros/Desktop/Projects/solsab/node_modules/keccak256/dist/keccak256"' can only be default-imported using the 'esModuleInterop' flagts(1259)

keccak256.d.ts(5, 1): This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

We used to have "esModuleInterop": true in tsconfig.json, but it has been removed in this PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We're still using esModuleInterop because we're extending the shared TSConfig from the devkit.

I don't know why you get that warning. Do you get it in VSCode? If yes, can you confirm you are using the node_modules-installed TypeScript?

Otherwise, can you confirm you are using Node.js v23 or later?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you get it in VSCode?

Yes.

If yes, can you confirm you are using the node_modules-installed TypeScript?

Nope, it appears that I'm running a "global" TypeScript, as which tsc returns /Users/iaros/.nvm/versions/node/v23.8.0/bin/tsc.

This is weird, because SolSab's package.json contains "typescript": "5.8.3" inside devDependencies{} 🤔

Comment thread tests/merkle-instant/unit/createCampaign.test.ts
Comment thread scripts/ts/codegen-errors.ts Outdated
refactor: remove unused types
refactor: import types from anchor package
test: rename params in assertion helpers
Copy link
Copy Markdown
Member

@andreivladbrg andreivladbrg left a comment

Choose a reason for hiding this comment

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

looks good to me, just one small comment

Comment thread scripts/ts/common/codegen-utils.ts
@andreivladbrg andreivladbrg merged commit 407d9db into main Jul 28, 2025
1 check passed
@andreivladbrg andreivladbrg deleted the prb-feedback branch July 28, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment