Description
The release_funds() loop currently iterates recipients in the order returned by soroban_sdk::Map, which is key-hash ordered and opaque to callers, making event logs non-deterministic and complicating any future partial-failure rollback logic. A canonical, reproducible payout ordering — sorted by recipient Address byte representation — must be enforced and reflected in event emissions.
Technical Context
contracts/split/src/lib.rs — release_funds() loop body that calls token::Client::transfer() per recipient; contracts/split/src/storage.rs — load_recipients() returns Vec<RecipientShare> iterated from a soroban_sdk::Map; add sort_recipients(recipients: &mut Vec<RecipientShare>) in contracts/split/src/math.rs using sort_by on the Address byte slice via recipient.to_string().as_bytes(); contracts/split/src/events.rs — payout_initiated(invoice_id, index, recipient, amount) event should include the 0-based position index.
Acceptance Criteria
Description
The
release_funds()loop currently iterates recipients in the order returned bysoroban_sdk::Map, which is key-hash ordered and opaque to callers, making event logs non-deterministic and complicating any future partial-failure rollback logic. A canonical, reproducible payout ordering — sorted by recipientAddressbyte representation — must be enforced and reflected in event emissions.Technical Context
contracts/split/src/lib.rs—release_funds()loop body that callstoken::Client::transfer()per recipient;contracts/split/src/storage.rs—load_recipients()returnsVec<RecipientShare>iterated from asoroban_sdk::Map; addsort_recipients(recipients: &mut Vec<RecipientShare>)incontracts/split/src/math.rsusingsort_byon theAddressbyte slice viarecipient.to_string().as_bytes();contracts/split/src/events.rs—payout_initiated(invoice_id, index, recipient, amount)event should include the 0-based position index.Acceptance Criteria
load_recipients()returns aVec<RecipientShare>sorted byAddressbyte representation in ascending lexicographic order before the payout loop beginspayout_initiatedevent includes the recipient's 0-based position index in the sorted orderMapread and introduces no additional storage readscontracts/split/src/tests/ordering_tests.rsinserts 5 recipients in reverse-alphabetical order and asserts that events are emitted in alphabetical order