Description
Build a full cloneInvoice SDK feature that includes: submitting the clone contract call, optimistic local state update, automatic rollback on failure, and a resolveCloneChain method that fetches the full lineage of cloned invoices.
Acceptance Criteria
Context
- Contract call pattern is in
src/client.ts — follow pay() as reference for retry + submission
src/types.ts needs CloneOverrides and updated InvoiceExt with parentInvoiceId and cloneDepth
- Cache rollback pattern should follow any existing cache invalidation in
src/cache.ts
Description
Build a full
cloneInvoiceSDK feature that includes: submitting the clone contract call, optimistic local state update, automatic rollback on failure, and aresolveCloneChainmethod that fetches the full lineage of cloned invoices.Acceptance Criteria
StellarSplitClient.cloneInvoice(sourceId: string, overrides: CloneOverrides): Promise<string>— submits theclone_invoicecontract call and returns the new invoice IDCloneOverridesTypeScript type mirrors the contract struct:newDeadline?: number,newAmounts?: bigint[],newRecipients?: string[],newOverflowBehavior?: OverflowBehaviorresolveCloneChain(invoiceId: string): Promise<Invoice[]>— recursively fetches parent invoices viaparent_invoice_idfromget_invoice_extuntil root is reached; returns array ordered root→leafresolveCloneChainmust handle cycles defensively (max depth 10, throws"clone chain depth exceeded")src/index.tswith full TypeScript typescloneInvoiceuses the existing retry logic fromsrc/client.tsContext
src/client.ts— followpay()as reference for retry + submissionsrc/types.tsneedsCloneOverridesand updatedInvoiceExtwithparentInvoiceIdandcloneDepthsrc/cache.ts