Fix various small bugs#4150
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses several small bugs across the monorepo, including read-only wallet handling in bitcore-cli, stability fixes in Insight’s block details UI, and dependency/version alignment (TypeScript at the repo root and bitcore-lib packages in Insight).
Changes:
bitcore-cli: Improve handling of read-only wallets during load/save/import.insight: Prevent Block Details “Transactions” section from crashing when the tx list is missing; align@bitpay-labs/bitcore-lib*versions.- Root: Bump TypeScript to 5.7.3 (plus lockfile updates).
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insight/src/components/block-details.tsx | Avoids runtime crash when transactionList is undefined by guarding length access. |
| packages/insight/package.json | Updates Insight’s @bitpay-labs/bitcore-lib* dependency versions. |
| packages/insight/package-lock.json | Lockfile updates reflecting the Insight dependency version changes. |
| packages/bitcore-cli/src/wallet.ts | Adjusts wallet load/save/import paths to support read-only wallets (no key). |
| package.json | Updates root TypeScript version to 5.7.3. |
| package-lock.json | Lockfile updates reflecting the TypeScript bump (and nested dependency resolution). |
Files not reviewed (1)
- packages/insight/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)
packages/bitcore-cli/src/wallet.ts:280
save()now serializes wallets wherethis.#walletData.keycan be undefined (read-only wallets). Howeverexport()still assumesthis.#walletData.keyis always present and calls.toObj()unconditionally, which will throw at runtime if a user loads/imports a read-only wallet and then runsexport. Updateexport()to either (a) support exporting read-only wallets by omittingkey, or (b) fail fast with a clear message whenkeyis missing.
let data: WalletData | EncryptionTypes.IEncrypted = { key: this.#walletData.key?.toObj(), credentials: this.#walletData.credentials.toObj() };
if (encryptAll) {
const password = await getPassword('Enter password to encrypt:', { minLength: 6 });
await prompt.password({
message: 'Confirm password:',
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <copilot@github.com>
| } | ||
|
|
||
| let key; | ||
| if (this.#walletData.key instanceof TssKey.TssKey) { |
There was a problem hiding this comment.
Wrap prior if/else in if (!readonly) {}
| throw new Error('No wallet data to save. Wallet not created or loaded'); | ||
| } | ||
|
|
||
| let key; |
There was a problem hiding this comment.
It would be nice to explicitly type key:
let key: TssKey.TssKey | Key | undefined
The downside being that the conditional below (get pw & decrypt) would have to get bumped into each conditional branch (but then could be cleaned up below)
let key: TssKey.TssKey | Key | undefined;
if (this.#walletData.key instanceof TssKey.TssKey) {
key = new TssKey.TssKey(this.#walletData.key.toObj());
const walletPassword = await getPassword('Wallet password:');
key.decrypt(walletPassword);
} else if (!readOnly) {
key = new Key({ seedType: 'object', seedData: this.#walletData.key.toObj() });
const walletPassword = await getPassword('Wallet password:');
key.decrypt(walletPassword);
}
Description
This fixes various small bugs I found while digging into various issues recently
Changelog
@bitpay-labsdepdendenciesTesting Notes
Checklist