Skip to content

feat(storage): Add exportContractsAsJson snapshot helper for future export feature#167

Open
dreamgenies wants to merge 1 commit into
Tx-wat:mainfrom
dreamgenies:feat/70-export-contracts-json
Open

feat(storage): Add exportContractsAsJson snapshot helper for future export feature#167
dreamgenies wants to merge 1 commit into
Tx-wat:mainfrom
dreamgenies:feat/70-export-contracts-json

Conversation

@dreamgenies
Copy link
Copy Markdown

Summary

Exposes a serializable snapshot of all stored contracts, enabling a future Export/Import feature in the dashboard. The API is deliberately minimal — consumers call one function and get clean, portable JSON.

Changes

  • lib/exportStorage.ts:
    • buildContractSnapshot(): typed snapshot with version, exportedAt, count, contracts
    • exportContractsAsJson(): pretty-printed JSON string
    • exportContractsAsBlob(): Blob for browser <a download> links
    • parseContractSnapshot(): validates imports with descriptive error messages
  • lib/__tests__/exportStorage.test.ts: 9 tests covering all export and parse paths

Future integration

// Download button handler
const url = URL.createObjectURL(exportContractsAsBlob());
const a = document.createElement('a');
a.href = url; a.download = 'txwatch-contracts.json'; a.click();

Closes #70

…xport feature (Tx-wat#70)

- buildContractSnapshot(): returns typed { version, exportedAt, count, contracts }
- exportContractsAsJson(): pretty-printed JSON string for clipboard/download
- exportContractsAsBlob(): Blob for <a download> links
- parseContractSnapshot(): validates + parses import JSON with descriptive errors
- Tests: version, count, empty fallback, ISO timestamp, round-trip, parse errors

Closes Tx-wat#70
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 30, 2026

@dreamgenies Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Add helper to export stored contracts as JSON

1 participant