Conversation
TypeScript and Rust examples showing rent top-up sponsorship where a fee payer covers rent-exemption so users hold no SOL. Fix dead-code crash in setup.ts (module-scope createRpc() call that fired on import before the symbol was available).
| "dependencies": { | ||
| "@lightprotocol/compressed-token": "^0.23.0-beta.9", | ||
| "@lightprotocol/stateless.js": "^0.23.0-beta.9" | ||
| } |
There was a problem hiding this comment.
🔴 Missing workspace entry causes unresolvable dependencies at install time
The new toolkits/sponsor-rent-top-ups/typescript package is not added to the root package.json workspaces array, unlike every other toolkit (e.g. toolkits/payments-and-wallets, toolkits/sign-with-privy/*). This means npm install from the repo root will not link this package into the workspace and will not hoist shared dependencies to it.
Root cause and impact
The root package.json lists shared dependencies (dotenv, @solana/web3.js, @solana/spl-token) and devDependencies (tsx) that all workspace toolkits rely on via hoisting. The existing toolkits/payments-and-wallets works because it's listed in workspaces and inherits these.
The new toolkit's own package.json only declares @lightprotocol/compressed-token and @lightprotocol/stateless.js, but the code imports:
dotenv/config(sponsor-top-ups.ts:1)@solana/web3.js(sponsor-top-ups.ts:2,setup.ts:6)@solana/spl-token(setup.ts:14-18)
And the npm script uses tsx (package.json:7).
Without the workspace entry, running npm install at the root won't set up this package, and running cd typescript && npm install standalone will only install the two declared @lightprotocol packages. The import "dotenv/config" at sponsor-top-ups.ts:1 will crash immediately with ERR_MODULE_NOT_FOUND, and npm run sponsor-top-ups will fail with tsx: command not found.
Impact: The toolkit is broken out of the box for anyone following the README instructions (cd typescript && npm install && npm run sponsor-top-ups).
Prompt for agents
Two changes are needed to fix this:
1. In the root package.json, add the new toolkit to the workspaces array. Around line 6, add "toolkits/sponsor-rent-top-ups/typescript" to the workspaces list, e.g.:
"workspaces": [
"typescript-client",
"toolkits/payments-and-wallets",
"toolkits/sign-with-privy/react",
"toolkits/sign-with-privy/nodejs",
"toolkits/sign-with-privy/scripts",
"toolkits/sponsor-rent-top-ups/typescript"
]
This matches the pattern used by all other toolkits and ensures hoisted dependencies (dotenv, tsx, @solana/web3.js, @solana/spl-token) are available.
Alternatively, if standalone usage is intended, add the missing dependencies to toolkits/sponsor-rent-top-ups/typescript/package.json:
"dependencies": {
"@lightprotocol/compressed-token": "^0.23.0-beta.9",
"@lightprotocol/stateless.js": "^0.23.0-beta.9",
"@solana/web3.js": "1.98.4",
"@solana/spl-token": "^0.4.13",
"dotenv": "^16.5.0"
},
"devDependencies": {
"tsx": "^4.7.0"
}
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
setup.ts— module-scopecreateRpc()call fired on import before the symbol was availabletoolkits/README.mdTest plan
npm run sponsor-top-upspasses (light test-validatorwithout--skip-system-accounts)