/** * Gas-Free Result Types * * Result types for gas-free transfer operations * * @module features/gas-free/types/GasFreeResult */ /** * Request parameters for submitting a signed PSBT */ export interface SubmitPSBTRequest { /** Quote ID from fee quote generation (UUID format) */ quoteId: string; /** Base64-encoded PSBT from the user's wallet */ psbtBase64: string; /** Base64-encoded RGB consignment file (.rgbc) */ consignmentBase64: string; } /** * Request parameters for verifying a transfer */ export interface VerifyTransferRequest { /** Quote ID (UUID format) */ quoteId: string; /** Boolean indicating if SDK successfully broadcast */ transferSuccess: boolean; /** Base64-encoded fully-signed PSBT (required when transferSuccess=true) */ signedPsbtBase64?: string; /** Transaction ID (required when transferSuccess=true) */ txid?: string; /** Optional reason for failure (when transferSuccess=false) */ failureReason?: string; } /** * Status of a gas-free transfer */ export enum GasFreeTransferStatus { /** Quote generated, awaiting PSBT construction */ QUOTE_GENERATED = 'quote_generated', /** PSBT constructed and signed by user */ PSBT_SIGNED = 'psbt_signed', /** PSBT submitted to backend */ SUBMITTED = 'submitted', /** Backend signed mining inputs */ BACKEND_SIGNED = 'backend_signed', /** Transaction broadcasted to network */ BROADCASTED = 'broadcasted', /** Transaction confirmed on blockchain */ CONFIRMED = 'confirmed', /** Transfer failed */ FAILED = 'failed', } /** * Result of a gas-free transfer */ export interface GasFreeResult { /** Transfer status */ status: GasFreeTransferStatus; /** Transaction ID (once broadcasted) */ txid?: string; /** RGB consignment data (hex or base64) */ consignment?: string; /** Quote ID used for this transfer */ quoteId: string; /** Total fee paid (satoshis) */ totalFeeSats: number; /** Mining fee paid (satoshis) */ miningFeeSats: number; /** Service fee paid (satoshis) */ serviceFeeSats: number; /** RGB amount transferred */ rgbAmount: string; /** Asset ID transferred */ assetId: string; /** Recipient blinded UTXO */ recipient: string; /** Timestamp when transfer was initiated */ initiatedAt: number; /** Timestamp when transfer was completed */ completedAt?: number; /** Error message (if failed) */ error?: string; /** Additional metadata */ metadata?: { /** Number of confirmations (if confirmed) */ confirmations?: number; /** Block height (if confirmed) */ blockHeight?: number; /** Raw transaction (hex) */ rawTx?: string; [key: string]: unknown; }; } /** * Check if transfer is complete * * @param result - Transfer result * @returns True if transfer is in a final state */ export function isTransferComplete(result: GasFreeResult): boolean { return ( result.status === GasFreeTransferStatus.CONFIRMED || result.status === GasFreeTransferStatus.FAILED ); } /** * Check if transfer was successful * * @param result - Transfer result * @returns True if transfer succeeded */ export function isTransferSuccessful(result: GasFreeResult): boolean { return ( result.status === GasFreeTransferStatus.BROADCASTED || result.status === GasFreeTransferStatus.CONFIRMED ); } /** * Get transfer duration (in milliseconds) * * @param result - Transfer result * @returns Duration in milliseconds (0 if not completed) */ export function getTransferDuration(result: GasFreeResult): number { if (!result.completedAt) { return 0; } return result.completedAt - result.initiatedAt; } /** * Submission result from backend */ export interface SubmitResult { /** Quote ID used */ quoteId: string; /** Base64-encoded signed PSBT with backend signatures */ signedPsbtBase64: string; /** Transaction ID */ transactionId: string; /** Estimated transaction size in vBytes */ estimatedTxSize: number; /** Mining UTXO transaction ID */ miningUtxoTxid: string; /** Mining UTXO output index */ miningUtxoVout: number; /** Timestamp when signed */ signedAt: string; } /** * Verification result from backend */ export interface VerificationResult { /** Quote ID */ quoteId: string; /** Transaction ID (empty string if failed/errored) */ transactionId: string; /** Verification status */ status: 'verified' | 'pending_verification' | 'failed' | 'errored'; /** Message describing the result */ message: string; /** Whether transaction is in mempool */ inMempool: boolean; /** Timestamp when verified */ verifiedAt: string; }