"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.auditLogger=exports.AuditLogger=void 0;const console_1=require("@b/utils/console");class AuditLogger{constructor(){}static getInstance(){AuditLogger.instance||(AuditLogger.instance=new AuditLogger);return AuditLogger.instance}async log(e){try{console_1.logger.info("WALLET_AUDIT",JSON.stringify({timestamp:(new Date).toISOString(),...e}))}catch(e){console_1.logger.error("WALLET_AUDIT",`Failed to write audit log: ${e.message}`)}}async logWalletCreated(e,a,t,o,n){await this.log({operation:"WALLET_CREATED",walletId:e,userId:a,amount:0,transactionId:e,idempotencyKey:`create_${t}_${a}_${o}`,metadata:{type:t,currency:o,chains:n}})}async logCredit(e,a,t,o,n,r,i,s){await this.log({operation:"CREDIT",walletId:e,userId:a,amount:t,previousBalance:o,newBalance:n,transactionId:r,idempotencyKey:i,metadata:s})}async logDebit(e,a,t,o,n,r,i,s){await this.log({operation:"DEBIT",walletId:e,userId:a,amount:t,previousBalance:o,newBalance:n,transactionId:r,idempotencyKey:i,metadata:s})}async logHold(e,a,t,o,n,r,i,s,d,l){await this.log({operation:"HOLD",walletId:e,userId:a,amount:t,previousBalance:o,newBalance:n,previousInOrder:r,newInOrder:i,transactionId:s,idempotencyKey:d,metadata:l})}async logRelease(e,a,t,o,n,r,i,s,d,l){await this.log({operation:"RELEASE",walletId:e,userId:a,amount:t,previousBalance:o,newBalance:n,previousInOrder:r,newInOrder:i,transactionId:s,idempotencyKey:d,metadata:l})}async logTransferOut(e,a,t,o,n,r,i,s,d,l){await this.log({operation:"TRANSFER_OUT",walletId:e,userId:a,amount:t,previousBalance:o,newBalance:n,transactionId:r,idempotencyKey:i,metadata:{...l,toWalletId:s,fee:d}})}async logTransferIn(e,a,t,o,n,r,i,s,d){await this.log({operation:"TRANSFER_IN",walletId:e,userId:a,amount:t,previousBalance:o,newBalance:n,transactionId:r,idempotencyKey:i,metadata:{...d,fromWalletId:s}})}async logExecuteFromHold(e,a,t,o,n,r,i,s){await this.log({operation:"EXECUTE_FROM_HOLD",walletId:e,userId:a,amount:t,previousInOrder:o,newInOrder:n,transactionId:r,idempotencyKey:i,metadata:s})}}exports.AuditLogger=AuditLogger;exports.auditLogger=AuditLogger.getInstance();