Skip to content

Commit 315d027

Browse files
committed
chore: cleanup debug messages
1 parent 16d7695 commit 315d027

File tree

2 files changed

+3
-76
lines changed

2 files changed

+3
-76
lines changed

cardano/gateway/src/shared/modules/lucid/lucid.service.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class LucidService {
172172
});
173173
}
174174
public async decodeDatum<T>(encodedDatum: string, type: CodecType): Promise<T> {
175-
console.log("decodeDatum encodedDatum: " + type + ": " + encodedDatum);
175+
console.log('decodeDatum encodedDatum: ' + type + ': ' + encodedDatum);
176176
try {
177177
switch (type) {
178178
case 'client':
@@ -194,7 +194,7 @@ export class LucidService {
194194
}
195195
// The main encode function
196196
public async encode<T>(data: T, type: CodecType): Promise<string> {
197-
console.log("encode data: " + type + ": " + this.prettyPrint(data));
197+
console.log('encode data: ' + type + ': ' + this.prettyPrint(data));
198198
try {
199199
switch (type) {
200200
case 'client':
@@ -382,16 +382,6 @@ export class LucidService {
382382
const deploymentConfig = this.configService.get('deployment');
383383
const tx: TxBuilder = this.txFromWallet(dto.constructedAddress);
384384

385-
console.log('Building transaction for ConnectionOpenAck');
386-
console.log('readFrom', [
387-
deploymentConfig.validators.spendConnection.refUtxo,
388-
dto.verifyProofRefUTxO,
389-
dto.clientUtxo,
390-
]);
391-
console.log('collectFrom', [dto.connectionUtxo]);
392-
console.log('pay.ToContract', 'dto.connectionTokenUnit', dto.connectionTokenUnit);
393-
console.log('mintAssets', 'dto.verifyProofPolicyId', dto.verifyProofPolicyId);
394-
395385
tx.readFrom([deploymentConfig.validators.spendConnection.refUtxo, dto.verifyProofRefUTxO])
396386
.collectFrom([dto.connectionUtxo], dto.encodedSpendConnectionRedeemer)
397387
.readFrom([dto.clientUtxo])
@@ -1427,7 +1417,4 @@ export class LucidService {
14271417

14281418
return JSON.stringify(obj, replacer, indent);
14291419
}
1430-
1431-
1432-
14331420
}

cardano/gateway/src/tx/connection.service.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -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,27 +139,18 @@ 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');
143142
try {
144-
145143
const { constructedAddress, connectionOpenAckOperator } = validateAndFormatConnectionOpenAckParams(data);
146-
this.logger.log(this.prettyPrint(connectionOpenAckOperator), 'connectionOpenAck - connectionOpenAckOperator:');
147-
this.logger.log(this.prettyPrint(constructedAddress), 'connectionOpenAck - constructedAddress:');
148-
149144
// Build and complete the unsigned transaction
150145
const unsignedConnectionOpenAckTx: TxBuilder = await this.buildUnsignedConnectionOpenAckTx(
151146
connectionOpenAckOperator,
152147
constructedAddress,
153148
);
154-
this.logger.log(this.prettyPrint(unsignedConnectionOpenAckTx), unsignedConnectionOpenAckTx);
155149
const unsignedConnectionOpenAckTxValidTo: TxBuilder = unsignedConnectionOpenAckTx.validTo(Date.now() + 100 * 1e3);
156-
157-
this.logger.log('post unsignedConnectionOpenAckTxValidTo', 'connectionOpenAck');
158150
// Todo: signing should be done by the relayer in the future
159151
const signedConnectionOpenAckTxCompleted = await (await unsignedConnectionOpenAckTxValidTo.complete()).sign
160152
.withWallet()
161153
.complete();
162-
this.logger.log('post signedConnectionOpenAckTxCompleted', 'connectionOpenAck');
163154

164155
this.logger.log(signedConnectionOpenAckTxCompleted.toHash(), 'connection open ack - unsignedTX - hash');
165156
const response: MsgConnectionOpenAckResponse = {
@@ -398,15 +389,12 @@ export class ConnectionService {
398389
},
399390
};
400391

401-
this.logger.log(this.prettyPrint(spendConnectionRedeemer), 'buildUnsignedConnectionOpenAckTx - spendConnectionRedeemer:')
402-
403392
const connectionDatum: ConnectionDatum = await this.lucidService.decodeDatum<ConnectionDatum>(
404393
connectionUtxo.datum!,
405394
'connection',
406395
);
407396

408397
const clientSequence = parseClientSequence(convertHex2String(connectionDatum.state.client_id));
409-
this.logger.log(this.prettyPrint(clientSequence), 'buildUnsignedConnectionOpenAckTx - clientSequence:')
410398
const updatedConnectionDatum: ConnectionDatum = {
411399
...connectionDatum,
412400
state: {
@@ -418,7 +406,6 @@ export class ConnectionService {
418406
},
419407
},
420408
};
421-
this.logger.log(this.prettyPrint(updatedConnectionDatum), 'buildUnsignedConnectionOpenAckTx - updatedConnectionDatum:')
422409
// Get the token unit associated with the client
423410
const clientTokenUnit = this.lucidService.getClientTokenUnit(clientSequence);
424411
const clientUtxo = await this.lucidService.findUtxoByUnit(clientTokenUnit);
@@ -458,17 +445,14 @@ export class ConnectionService {
458445
},
459446
delay_period: connectionDatum.state.delay_period,
460447
};
461-
this.logger.log(this.prettyPrint(cardanoConnectionEnd), 'buildUnsignedConnectionOpenAckTx - cardanoConnectionEnd:')
462448

463449
const mithrilClientState: MithrilClientState = getMithrilClientStateForVerifyProofRedeemer(
464450
connectionOpenAckOperator.counterpartyClientState,
465451
);
466-
this.logger.log(this.prettyPrint(mithrilClientState), 'buildUnsignedConnectionOpenAckTx - mithrilClientState:')
467452
const mithrilClientStateAny: Any = {
468453
type_url: '/ibc.clients.mithril.v1.ClientState',
469454
value: MithrilClientState.encode(mithrilClientState).finish(),
470455
};
471-
this.logger.log(this.prettyPrint(mithrilClientStateAny), 'buildUnsignedConnectionOpenAckTx - mithrilClientStateAny:')
472456
const verifyProofRedeemer: VerifyProofRedeemer = {
473457
BatchVerifyMembership: [
474458
[
@@ -509,17 +493,11 @@ export class ConnectionService {
509493
],
510494
],
511495
};
512-
this.logger.log(this.prettyPrint(verifyProofRedeemer), 'buildUnsignedConnectionOpenAckTx - verifyProofRedeemer:')
513496

514497
const encodedVerifyProofRedeemer: string = encodeVerifyProofRedeemer(
515498
verifyProofRedeemer,
516499
this.lucidService.LucidImporter,
517500
);
518-
this.logger.log(this.prettyPrint(encodedVerifyProofRedeemer), 'buildUnsignedConnectionOpenAckTx - encodedVerifyProofRedeemer:')
519-
520-
console.log('verifyProofRedeemer', this.prettyPrint(verifyProofRedeemer));
521-
console.log('spentConnectionRedeemer', this.prettyPrint(spendConnectionRedeemer));
522-
console.log('updatedConnectionDatum', this.prettyPrint(updatedConnectionDatum));
523501

524502
const unsignedConnectionOpenAckParams: UnsignedConnectionOpenAckDto = {
525503
connectionUtxo,
@@ -533,7 +511,6 @@ export class ConnectionService {
533511
verifyProofRefUTxO,
534512
encodedVerifyProofRedeemer,
535513
};
536-
console.log('unsignedConnectionOpenAckParams', this.prettyPrint(unsignedConnectionOpenAckParams));
537514
return this.lucidService.createUnsignedConnectionOpenAckTransaction(unsignedConnectionOpenAckParams);
538515
}
539516
/* istanbul ignore next */
@@ -589,41 +566,4 @@ export class ConnectionService {
589566
constructedAddress,
590567
);
591568
}
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-
629569
}

0 commit comments

Comments
 (0)