The get_by_account function in contracts/invoice/src/lib.rs was previously returning an empty vector as a stub. This was misleading for off-chain or indexer queries attempting to fetch an account's invoices. Additionally, cargo test in the invoice contract was failing on the main branch due to type errors in recent SDK upgrades (e.g. Option<BytesN<32>> causing ScVal TryFrom bound errors, and incorrect tuple hashing with sha256).
- Restore and Implement
get_by_account: Implementedget_by_accountwhich combines thelist_by_creatorandlist_by_recipientindexes to return a deduplicated list of resolvedInvoicestructs. - Fix
mainbranch compilation in tests:- Fixed
env.crypto().sha256hashing logic by properly serializing tuple fields to XDR format viasoroban_sdk::xdr::ToXdr. - Fixed
Option<BytesN<32>>conversion errors by changingpayment_txtoOption<soroban_sdk::Bytes>inside theInvoicestruct, which restores compilation undertestutils. - Fixed outdated
&i128reference requirements and.unwrap()panics in the existing tests.
- Fixed
- Add Tests: Added
test_get_by_accountunit test to verify that the endpoint correctly fetches and deduplicates creator and recipient invoices for a given account.
closes #1113