@@ -53,7 +53,7 @@ export class ConnectionService {
5353 private readonly logger : Logger ,
5454 private configService : ConfigService ,
5555 @Inject ( LucidService ) private lucidService : LucidService ,
56- ) { }
56+ ) { }
5757 /**
5858 * Processes the connection open init tx.
5959 * @param data The message containing connection open initiation data.
@@ -139,19 +139,27 @@ export class ConnectionService {
139139 */
140140 async connectionOpenAck ( data : MsgConnectionOpenAck ) : Promise < MsgConnectionOpenAckResponse > {
141141 this . logger . log ( 'Connection Open Ack is processing' , 'connectionOpenAck' ) ;
142+ this . logger . log ( this . prettyPrint ( data ) , 'connectionOpenAck' ) ;
142143 try {
144+
143145 const { constructedAddress, connectionOpenAckOperator } = validateAndFormatConnectionOpenAckParams ( data ) ;
146+ this . logger . log ( this . prettyPrint ( connectionOpenAckOperator ) , 'connectionOpenAck - connectionOpenAckOperator:' ) ;
147+ this . logger . log ( this . prettyPrint ( constructedAddress ) , 'connectionOpenAck - constructedAddress:' ) ;
148+
144149 // Build and complete the unsigned transaction
145150 const unsignedConnectionOpenAckTx : TxBuilder = await this . buildUnsignedConnectionOpenAckTx (
146151 connectionOpenAckOperator ,
147152 constructedAddress ,
148153 ) ;
154+ this . logger . log ( this . prettyPrint ( unsignedConnectionOpenAckTx ) , unsignedConnectionOpenAckTx ) ;
149155 const unsignedConnectionOpenAckTxValidTo : TxBuilder = unsignedConnectionOpenAckTx . validTo ( Date . now ( ) + 100 * 1e3 ) ;
150156
157+ this . logger . log ( 'post unsignedConnectionOpenAckTxValidTo' , 'connectionOpenAck' ) ;
151158 // Todo: signing should be done by the relayer in the future
152159 const signedConnectionOpenAckTxCompleted = await ( await unsignedConnectionOpenAckTxValidTo . complete ( ) ) . sign
153160 . withWallet ( )
154161 . complete ( ) ;
162+ this . logger . log ( 'post signedConnectionOpenAckTxCompleted' , 'connectionOpenAck' ) ;
155163
156164 this . logger . log ( signedConnectionOpenAckTxCompleted . toHash ( ) , 'connection open ack - unsignedTX - hash' ) ;
157165 const response : MsgConnectionOpenAckResponse = {
@@ -390,12 +398,15 @@ export class ConnectionService {
390398 } ,
391399 } ;
392400
401+ this . logger . log ( this . prettyPrint ( spendConnectionRedeemer ) , 'buildUnsignedConnectionOpenAckTx - spendConnectionRedeemer:' )
402+
393403 const connectionDatum : ConnectionDatum = await this . lucidService . decodeDatum < ConnectionDatum > (
394404 connectionUtxo . datum ! ,
395405 'connection' ,
396406 ) ;
397407
398408 const clientSequence = parseClientSequence ( convertHex2String ( connectionDatum . state . client_id ) ) ;
409+ this . logger . log ( this . prettyPrint ( clientSequence ) , 'buildUnsignedConnectionOpenAckTx - clientSequence:' )
399410 const updatedConnectionDatum : ConnectionDatum = {
400411 ...connectionDatum ,
401412 state : {
@@ -407,6 +418,7 @@ export class ConnectionService {
407418 } ,
408419 } ,
409420 } ;
421+ this . logger . log ( this . prettyPrint ( updatedConnectionDatum ) , 'buildUnsignedConnectionOpenAckTx - updatedConnectionDatum:' )
410422 // Get the token unit associated with the client
411423 const clientTokenUnit = this . lucidService . getClientTokenUnit ( clientSequence ) ;
412424 const clientUtxo = await this . lucidService . findUtxoByUnit ( clientTokenUnit ) ;
@@ -446,14 +458,17 @@ export class ConnectionService {
446458 } ,
447459 delay_period : connectionDatum . state . delay_period ,
448460 } ;
461+ this . logger . log ( this . prettyPrint ( cardanoConnectionEnd ) , 'buildUnsignedConnectionOpenAckTx - cardanoConnectionEnd:' )
449462
450463 const mithrilClientState : MithrilClientState = getMithrilClientStateForVerifyProofRedeemer (
451464 connectionOpenAckOperator . counterpartyClientState ,
452465 ) ;
466+ this . logger . log ( this . prettyPrint ( mithrilClientState ) , 'buildUnsignedConnectionOpenAckTx - mithrilClientState:' )
453467 const mithrilClientStateAny : Any = {
454468 type_url : '/ibc.clients.mithril.v1.ClientState' ,
455469 value : MithrilClientState . encode ( mithrilClientState ) . finish ( ) ,
456470 } ;
471+ this . logger . log ( this . prettyPrint ( mithrilClientStateAny ) , 'buildUnsignedConnectionOpenAckTx - mithrilClientStateAny:' )
457472 const verifyProofRedeemer : VerifyProofRedeemer = {
458473 BatchVerifyMembership : [
459474 [
@@ -494,50 +509,17 @@ export class ConnectionService {
494509 ] ,
495510 ] ,
496511 } ;
512+ this . logger . log ( this . prettyPrint ( verifyProofRedeemer ) , 'buildUnsignedConnectionOpenAckTx - verifyProofRedeemer:' )
497513
498514 const encodedVerifyProofRedeemer : string = encodeVerifyProofRedeemer (
499515 verifyProofRedeemer ,
500516 this . lucidService . LucidImporter ,
501517 ) ;
518+ this . logger . log ( this . prettyPrint ( encodedVerifyProofRedeemer ) , 'buildUnsignedConnectionOpenAckTx - encodedVerifyProofRedeemer:' )
502519
503- function prettyPrint ( obj : any , indent = 2 ) : string {
504- const seen = new WeakSet ( ) ;
505-
506- function replacer ( key : string , value : any ) : any {
507- // Handle circular references
508- if ( typeof value === 'object' && value !== null ) {
509- if ( seen . has ( value ) ) {
510- return '[Circular Reference]' ;
511- }
512- seen . add ( value ) ;
513- }
514-
515- // Handle Map objects
516- if ( value instanceof Map ) {
517- const mapEntries : Record < string , any > = { } ;
518- value . forEach ( ( v , k ) => {
519- mapEntries [ String ( k ) ] = v ;
520- } ) ;
521- return { __type : 'Map' , entries : mapEntries } ;
522- }
523-
524- // Handle BigInt values
525- if ( typeof value === 'bigint' ) {
526- return { __type : 'BigInt' , value : value . toString ( ) } ;
527- }
528-
529- // Handle other special types as needed
530- // ...
531-
532- return value ;
533- }
534-
535- return JSON . stringify ( obj , replacer , indent ) ;
536- }
537-
538- console . log ( 'verifyProofRedeemer' , prettyPrint ( verifyProofRedeemer ) ) ;
539- console . log ( 'spentConnectionRedeemer' , prettyPrint ( spendConnectionRedeemer ) ) ;
540- console . log ( 'updatedConnectionDatum' , prettyPrint ( updatedConnectionDatum ) ) ;
520+ console . log ( 'verifyProofRedeemer' , this . prettyPrint ( verifyProofRedeemer ) ) ;
521+ console . log ( 'spentConnectionRedeemer' , this . prettyPrint ( spendConnectionRedeemer ) ) ;
522+ console . log ( 'updatedConnectionDatum' , this . prettyPrint ( updatedConnectionDatum ) ) ;
541523
542524 const unsignedConnectionOpenAckParams : UnsignedConnectionOpenAckDto = {
543525 connectionUtxo,
@@ -551,6 +533,7 @@ export class ConnectionService {
551533 verifyProofRefUTxO,
552534 encodedVerifyProofRedeemer,
553535 } ;
536+ console . log ( 'unsignedConnectionOpenAckParams' , this . prettyPrint ( unsignedConnectionOpenAckParams ) ) ;
554537 return this . lucidService . createUnsignedConnectionOpenAckTransaction ( unsignedConnectionOpenAckParams ) ;
555538 }
556539 /* istanbul ignore next */
@@ -606,4 +589,41 @@ export class ConnectionService {
606589 constructedAddress ,
607590 ) ;
608591 }
592+
593+
594+ private prettyPrint ( obj : any , indent = 2 ) : string {
595+ const seen = new WeakSet ( ) ;
596+
597+ function replacer ( key : string , value : any ) : any {
598+ // Handle circular references
599+ if ( typeof value === 'object' && value !== null ) {
600+ if ( seen . has ( value ) ) {
601+ return '[Circular Reference]' ;
602+ }
603+ seen . add ( value ) ;
604+ }
605+
606+ // Handle Map objects
607+ if ( value instanceof Map ) {
608+ const mapEntries : Record < string , any > = { } ;
609+ value . forEach ( ( v , k ) => {
610+ mapEntries [ String ( k ) ] = v ;
611+ } ) ;
612+ return { __type : 'Map' , entries : mapEntries } ;
613+ }
614+
615+ // Handle BigInt values
616+ if ( typeof value === 'bigint' ) {
617+ return { __type : 'BigInt' , value : value . toString ( ) } ;
618+ }
619+
620+ // Handle other special types as needed
621+ // ...
622+
623+ return value ;
624+ }
625+
626+ return JSON . stringify ( obj , replacer , indent ) ;
627+ }
628+
609629}
0 commit comments