Skip to content

Add SDK appeal, batch submission, and LP fund-queue methods - #511

Merged
Levi-Ojukwu merged 3 commits into
Invoice-Liquidity-Network:mainfrom
circleboyslimited:fix/issues-462-463-466-467
Jul 25, 2026
Merged

Add SDK appeal, batch submission, and LP fund-queue methods#511
Levi-Ojukwu merged 3 commits into
Invoice-Liquidity-Network:mainfrom
circleboyslimited:fix/issues-462-463-466-467

Conversation

@circleboyslimited

@circleboyslimited circleboyslimited commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

#462/#463 — appeal flow. appealInvoice(client, invoiceId, evidenceHash) wraps appeal_default, validating the invoice is currently Defaulted client-side (via getInvoice) before submitting. resolveAppeal(client, invoiceId, upheld) wraps resolve_appeal. Both map AlreadyAppealed/AppealWindowClosed/NotDefaulted/etc. through the existing ILNError.fromError — these are invoice_liquidity ContractError codes, the same contract ILNError is already scoped to, so no collision like the governance/insurance contracts hit in earlier batches.

** resolve_appeal's doc comment says "Access: Admin only", but contracts/invoice_liquidity/src/lib.rs:1891 never actually calls require_admin or any other auth check — any account can currently call resolve_appeal and manipulate a payer's reputation score. This is a pre-existing contract-level access-control bug, out of scope for this SDK-wrapper issue (fixing a live contract's auth needs its own careful review/redeploy plan), so I'm surfacing it here and in the code's JSDoc rather than silently working around it or fabricating a client-side restriction that wouldn't actually be enforceable.

#467 — batch submission. submitInvoicesBatch(client, invoices[]) wraps submit_invoices_batch, validating batch size (1-10) client-side and returning the new invoice IDs. Each item is hand-encoded as the contract's InvoiceParams struct (alphabetically-sorted ScVal map) — same technique submitInvoice.ts already uses for the ReferralCode enum. Scope note: the contract requires require_auth() from every distinct freelancer in the batch, but this method signs with a single client.signer, so it only supports batches where every item's freelancer matches that signer (the "high-volume freelancer submits their own batch" case the issue calls out) — documented in the file header.

#466 — LP fund queue. joinFundQueue(client, lpAddress, invoiceId) and resolveFundQueue(client, invoiceId) wrap join_fund_queue/resolve_fund_queue, mapping AlreadyInQueue/NotApprovedFunder.

Closes #462
Closes #463
Closes #466
Closes #467

Test plan

  • npx vitest run in sdk/: 18 new tests pass across appeal.test.ts/submitInvoicesBatch.test.ts/fundQueue.test.ts, covering happy paths, client-side validation (appeal status, batch size), and error-code mapping; 11 pre-existing unrelated failures (getTokenDecimals.test.ts, nft.test.ts) confirmed to already exist on main
  • npx tsc --noEmit in sdk/: zero new errors; one pre-existing unrelated error in xdrDecoder.ts

(closes Invoice-Liquidity-Network#462)
(closes Invoice-Liquidity-Network#463)

appealInvoice(client, invoiceId, evidenceHash) wraps appeal_default.
Validates the invoice is currently Defaulted client-side (via getInvoice)
before submitting, and maps AlreadyAppealed/AppealWindowClosed/
NotDefaulted through the existing ILNError.fromError (these are
invoice_liquidity ContractError codes, same contract ILNError is already
scoped to — no collision, unlike the governance/insurance contracts in
prior batches).

resolveAppeal(client, invoiceId, upheld) wraps resolve_appeal.

Security note called out in the JSDoc: despite resolve_appeal's doc
comment ("Access: Admin only"), the current contract
(contracts/invoice_liquidity/src/lib.rs:1891) never actually calls
require_admin or any other auth check on this function — any account can
currently call it and manipulate a payer's reputation score. This is a
pre-existing contract-level bug, out of scope for this SDK-wrapper issue
(fixing it would mean changing a live contract's access control, which
needs its own careful review), so it's flagged rather than silently
worked around.

Adds tests for both, including the appeal-window/status validation paths
and the error-code mapping.
(closes Invoice-Liquidity-Network#467)

submitInvoicesBatch(client, invoices[]) wraps submit_invoices_batch,
validating batch size (1-10) client-side and returning the new invoice
IDs in submission order.

Encodes each item as the contract's InvoiceParams struct by hand-building
an alphabetically-key-sorted ScVal map (amount, discount_rate, due_date,
freelancer, payer, referral_code, token) — matching soroban_sdk's
#[contracttype] struct wire encoding, same approach submitInvoice.ts
already uses for the ReferralCode enum.

Scope note (documented in the file header): the contract requires
require_auth() from every distinct freelancer address in the batch. This
method signs with a single client.signer, so it only supports batches
where every item's freelancer matches that signer — the "high-volume
freelancer submits their own batch" case the issue calls out. Batches
spanning multiple freelancers would need multiple signers on the same
transaction, out of scope here.

Adds tests covering the happy path, batch-too-large/empty-batch
validation, and error-code mapping.
(closes Invoice-Liquidity-Network#466)

joinFundQueue(client, lpAddress, invoiceId) wraps join_fund_queue,
requiring the LP's own signature. resolveFundQueue(client, invoiceId)
wraps resolve_fund_queue (callable by anyone per the contract) and
returns the approved LP's address.

Maps AlreadyInQueue/NotApprovedFunder through the existing
ILNError.fromError (invoice_liquidity ContractError codes, no collision).

Adds tests covering both happy paths and the two error codes.
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@circleboyslimited 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

@Levi-Ojukwu
Levi-Ojukwu merged commit 21bdac1 into Invoice-Liquidity-Network:main Jul 25, 2026
4 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

2 participants