Skip to content

Implement data migration/import-export (#46) and advanced security/audit trail (#47)#55

Merged
Baskarayelu merged 1 commit intoRemitwise-Org:mainfrom
Jagadeeshftw:data-mig
Jan 30, 2026
Merged

Implement data migration/import-export (#46) and advanced security/audit trail (#47)#55
Baskarayelu merged 1 commit intoRemitwise-Org:mainfrom
Jagadeeshftw:data-mig

Conversation

@Jagadeeshftw
Copy link
Contributor

Summary

Implements #46 Data Migration and Import/Export Utilities and #47 Advanced Security Features and Audit Trail, and ensures CI passes (build, test, clippy, fmt).


#46 – Data Migration and Import/Export

New crate: data_migration

  • Export formats: JSON (human-readable), binary (bincode), CSV (goals), base64 “encrypted” payload (caller encrypts/decrypts).
  • Checksum: SHA256 of payload; validated on import.
  • Version: SCHEMA_VERSION and MIN_SUPPORTED_VERSION; version compatibility checked on import.
  • API: export_to_json, export_to_binary, export_to_csv, export_to_encrypted_payload, import_from_json, import_from_binary, import_goals_from_csv, import_from_encrypted_payload, validate_for_import, check_version_compatibility.
  • Rollback: RollbackMetadata for migration scripts.

Contract changes

  • remittance_split: export_snapshot(env, caller), import_snapshot(env, caller, nonce, snapshot) with version and checksum validation (owner-only).
  • savings_goals: export_snapshot(env, caller), import_snapshot(env, caller, nonce, snapshot) for full goals backup/restore with validation.

#47 – Advanced Security and Audit Trail

remittance_split

  • Audit trail: AuditEntry (operation, caller, timestamp, success). All state-changing ops log success/failure; get_audit_log(env, from_index, limit) (capped at 100 entries).
  • Nonce & replay protection: get_nonce(env, address); state-changing functions require correct nonce: initialize_split, update_split, distribute_usdc.
  • Integer overflow: calculate_split uses checked_mul / checked_div / checked_sub.

savings_goals

  • Audit trail: Same pattern for create_goal, add_to_goal, withdraw_from_goal, lock_goal, unlock_goal; get_audit_log(env, from_index, limit).
  • Nonce: Used for import_snapshot replay protection; get_nonce(env, address).
  • Integer overflow: add_to_goal uses checked_add, withdraw_from_goal uses checked_sub.

(Workspace already has overflow-checks = true in release.)


Breaking API changes

  • remittance_split:
    • initialize_split(env, owner, nonce, spending_percent, ...)
    • update_split(env, caller, nonce, ...)
    • distribute_usdc(env, usdc_contract, from, nonce, accounts, total_amount)
  • Callers must pass the current nonce (from get_nonce) for these functions.

Testing & CI

  • New tests: data_migration (checksum, JSON/binary/CSV export-import, version checks), remittance_split export_import_snapshot_and_audit and replay_attack_rejected.
  • Existing tests updated for new nonce parameters.
  • CI: cargo build --release --target wasm32-unknown-unknown, cargo test --all-features, cargo clippy --all-targets --all-features -- -D warnings, cargo fmt --all -- --check all pass.

Closes #46
Closes #47

- Introduced a new `data_migration` module to handle data migration, including import/export utilities for Remitwise contracts.
- Supported formats include JSON, binary, and CSV, with checksum validation and version compatibility checks.
- Updated Cargo.toml to include the new module.
- Added comprehensive tests for various scenarios, including negative coverage and premium cases, to ensure robust contract behavior.
@Baskarayelu
Copy link
Contributor

Looks good to me @Jagadeeshftw

@Baskarayelu Baskarayelu merged commit 91ece80 into Remitwise-Org:main Jan 30, 2026
2 checks passed
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.

Implement Advanced Security Features and Audit Trail Implement Data Migration and Import/Export Utilities

2 participants