Skip to content

Commit a880668

Browse files
authored
Merge pull request #598 from Ebuka042-pixel/feature/549-escrow-vault-manager
feat(#549): add EscrowVaultManager for escrow vault payment lifecycle
2 parents 797a8fb + a553650 commit a880668

3 files changed

Lines changed: 793 additions & 0 deletions

File tree

src/client.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6745,6 +6745,49 @@ export class StellarSplitClient extends TypedEventEmitter<SplitClientEventMap> {
67456745

67466746
return { txHash };
67476747
}
6748+
6749+
// ---------------------------------------------------------------------------
6750+
// Escrow Vault integration (#549)
6751+
// ---------------------------------------------------------------------------
6752+
6753+
/**
6754+
* Confirm delivery for an invoice, triggering escrow release when an
6755+
* {@link EscrowVaultManager} is provided via the config.
6756+
*
6757+
* This method updates the invoice status to "Released" and, if the client
6758+
* was constructed with an `escrowVaultManager` and the invoice has an
6759+
* associated `escrowVaultId`, also calls `EscrowVaultManager.release()` to
6760+
* claim the locked funds on behalf of the recipient.
6761+
*
6762+
* @param invoiceId - The invoice to confirm delivery for.
6763+
* @param recipientId - The recipient who should receive the escrowed funds.
6764+
* @param escrowVaultId - The vault ID to release (optional).
6765+
* @param signerSecret - Secret key for signing the claim transaction.
6766+
* @returns Object with `{ invoiceId, txHash? }`.
6767+
*/
6768+
async confirmDelivery(
6769+
invoiceId: string,
6770+
recipientId: string,
6771+
escrowVaultId?: string,
6772+
signerSecret?: string,
6773+
): Promise<{ invoiceId: string; txHash?: string }> {
6774+
// Update invoice status to Released
6775+
await this.updateInvoiceStatus(invoiceId, "Released");
6776+
6777+
let txHash: string | undefined;
6778+
6779+
// Release the escrow vault if provided
6780+
const escrowManager = (this.config as Record<string, unknown>)["escrowVaultManager"] as
6781+
| import("./escrowVaultManager.js").EscrowVaultManager
6782+
| undefined;
6783+
6784+
if (escrowManager && escrowVaultId && signerSecret) {
6785+
const result = await escrowManager.release(escrowVaultId, recipientId, signerSecret);
6786+
txHash = result.txHash;
6787+
}
6788+
6789+
return { invoiceId, txHash };
6790+
}
67486791
}
67496792

67506793
/** Coerce a native-decoded scalar (bigint | number | string) into a bigint, defaulting to 0n. */

0 commit comments

Comments
 (0)