Skip to content

Invoice Creator Migration #560

Description

@Kingsman-99

Description

When a creator account is compromised or an invoice is transferred as part of a business handover, there is no on-chain path to reassign the creator role, forcing the original account to remain the sole authorized administrator indefinitely. The contract needs a two-step creator migration — nomination by the current creator followed by explicit acceptance by the successor — to prevent accidental or coerced transfers.

Technical Context

contracts/split/src/lib.rs — add nominate_new_creator(invoice_id: u64, successor: Address) and accept_creator_role(invoice_id: u64) #[contractimpl] entry points; contracts/split/src/storage.rs — add DataKey::PendingCreator(u64) to hold the nominated address until acceptance; contracts/split/src/auth.rsenv.require_auth(&current_creator) in nominate_new_creator, env.require_auth(&pending_creator) in accept_creator_role; contracts/split/src/events.rs — emit creator_nominated(invoice_id, successor) and creator_migrated(invoice_id, old, new).

Acceptance Criteria

  • nominate_new_creator() writes successor to DataKey::PendingCreator(invoice_id) and requires auth from the current Invoice.creator
  • accept_creator_role() overwrites Invoice.creator with the pending address, deletes DataKey::PendingCreator, and requires auth from the nominated successor
  • A third address calling accept_creator_role() is rejected by the require_auth check without mutating state
  • The current creator can cancel or replace a pending nomination by calling nominate_new_creator() again with a different address
  • Tests in contracts/split/src/tests/creator_migration_tests.rs cover: successful two-step migration, unauthorized acceptance, nomination override, and acceptance on a deleted invoice (must return Error::InvoiceNotFound)
  • All CI checks (cargo build --target wasm32-unknown-unknown, cargo test, cargo clippy) pass and the branch has no merge conflicts

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsintegration

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions