Skip to content

Conversation

@samholmes
Copy link
Contributor

@samholmes samholmes commented Dec 4, 2025

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Description

none

Note

Deletes empty transaction metadata files during load and switches repo syncing to edge-sync-client’s syncRepo with deletion markers and tests.

  • Wallet metadata:
    • Add isEmptyMetadata and isEmptyTxFile; detect and delete empty transaction/*.json files during loadTxFiles.
    • New action CURRENCY_WALLET_FILE_DELETED; update files and fileNames reducers to remove deleted entries.
    • Unit tests for metadata emptiness and file deletion behavior.
  • Sync / storage:
    • Replace custom repo sync with syncClient.syncRepo; persist updated status.json.
    • Enhance encryptDisklet to support deletedDisklet for sync-aware deletions; add deletedDisklet to makeRepoPaths.
    • Update internal API syncRepo signature and imports to use edge-sync-client SyncResult.
    • Bump edge-sync-client dependency (local path) and update lockfile.
  • Docs:
    • Update CHANGELOG.md with new behavior and sync change.

Written by Cursor Bugbot for commit 840ad5a. This will update automatically on new commits. Configure here.


"currency-codes": "^1.5.1",
"disklet": "^0.5.2",
"edge-sync-client": "^0.2.8",
"edge-sync-client": "../edge-sync-client",
Copy link

Choose a reason for hiding this comment

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

Bug: Local path dependency will break npm package

The edge-sync-client dependency is set to a local filesystem path "../edge-sync-client" instead of an npm version. This is development code that will break when the package is published to npm, as the relative path won't exist on consumer machines. The previous version ^0.2.8 was replaced with this local path.

Fix in Cursor Fix in Web

// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete out[txidHash]
}
}
Copy link

Choose a reason for hiding this comment

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

Bug: Empty legacy files deleted at wrong path

The empty file detection and deletion logic assumes all transaction files in out are from the new transaction/ directory. However, out may contain legacy files loaded from Transactions/ directory (if no new-format file exists for that txidHash). When such a legacy file is detected as empty, the code tries to delete from transaction/${fileName} which is incorrect - the file actually exists at Transactions/${fileName}. This results in a failed deletion attempt, but the state dispatch CURRENCY_WALLET_FILE_DELETED still removes the entry from fileNames, causing state/disk inconsistency.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this looks like a legitimate path mix-up that Cursor caught.

if (file.feeRateRequested != null) return false

// Check currencies map for non-empty metadata:
for (const asset of file.currencies.values()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We generally avoid Object.values in the core for historical reasons. It's OK if a currency plugin can't load, but if the core itself can't load, this is extremely very bad. So this would become for (const currencyCode of Object.keys(file.currencies) { const asset = file.currencies[currencyCode]; ... }. This keeps things clean on really bad Androids.

}

// Check tokens map for non-empty metadata:
for (const asset of file.tokens.values()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. for (const tokenId of Object.keys(file.tokens) { const asset = file.tokens[tokenId]; ... }

// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete out[txidHash]
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this looks like a legitimate path mix-up that Cursor caught.

Comment on lines +20 to +21
/** Provide when this disklet is synchronized with edge-sync-client's syncRepo */
deletedDisklet?: Disklet
Copy link
Contributor

Choose a reason for hiding this comment

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

This deletion logic needs to live in the edge-sync-client, as part of the wrapped disklet. The edge-sync-client needs abstract all the sync stuff (adds / changes / deletions / etc.) behind the simple Disklet API, managing the deletions folder internally.

import { TransactionFile } from '../../../../src/core/currency/wallet/currency-wallet-cleaners'
import { isEmptyTxFile } from '../../../../src/core/currency/wallet/currency-wallet-files'

describe('currency wallet files', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like there are too many tests here. You've already covered this logic e2e style in the currency-wallet test, so I would delete these detailed tests. More tests is not more betterer - we don't need extra slop clogging the context window of both humans and machines.

The biggest danger with this new file-deletion logic happens if we add a new field to the transaction file, and forget to add it to one of the isEmpty* functions. Then users with only that field will have their data randomly disappear. However, your tests don't cover this case (and I'm not sure how you test non-existent future code), which means we are getting a lot of false confidence from these tests (wow! so detailed!) while not actually covering the really dangerous case. So yeah, please delete them.

).equals(true)
})

it('returns false for metadata with name', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. I feel like these could be deleted.

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.

3 participants