Skip to content

Commit 5d2dea6

Browse files
committed
chore: logs
1 parent eb673df commit 5d2dea6

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

cardano/gateway/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ OGMIOS_ENDPOINT=http://127.0.0.1:1337
1212
CARDANO_CHAIN_HOST=127.0.0.1
1313
CARDANO_CHAIN_PORT=3001
1414
CARDANO_NETWORK_MAGIC=42
15-
CARDANO_EPOCH_NONCE_GENESIS="3eff1dbf5ab72bb3cf730c0e208468c7299c56bec8fd9871c3e876b67d2d3180"
15+
CARDANO_EPOCH_NONCE_GENESIS="897c557a39889c62541732376e52c3174b87ee4572671d2e9e45baceda18b6b0"
1616

1717
MITHRIL_ENDPOINT=http://127.0.0.1:8080/aggregator
1818
MITHRIL_GENESIS_VERIFICATION_KEY=5b33322c3235332c3138362c3230312c3137372c31312c3131372c3133352c3138372c3136372c3138312c3138382c32322c35392c3230362c3130352c3233312c3135302c3231352c33302c37382c3231322c37362c31362c3235322c3138302c37322c3133342c3133372c3234372c3136312c36385d

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +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);
175176
try {
176177
switch (type) {
177178
case 'client':
@@ -193,6 +194,7 @@ export class LucidService {
193194
}
194195
// The main encode function
195196
public async encode<T>(data: T, type: CodecType): Promise<string> {
197+
console.log("encode data: " + type + ": " + this.prettyPrint(data));
196198
try {
197199
switch (type) {
198200
case 'client':
@@ -1390,4 +1392,42 @@ export class LucidService {
13901392
}
13911393
return this.lucid.newTx();
13921394
}
1395+
1396+
private prettyPrint(obj: any, indent = 2): string {
1397+
const seen = new WeakSet();
1398+
1399+
function replacer(key: string, value: any): any {
1400+
// Handle circular references
1401+
if (typeof value === 'object' && value !== null) {
1402+
if (seen.has(value)) {
1403+
return '[Circular Reference]';
1404+
}
1405+
seen.add(value);
1406+
}
1407+
1408+
// Handle Map objects
1409+
if (value instanceof Map) {
1410+
const mapEntries: Record<string, any> = {};
1411+
value.forEach((v, k) => {
1412+
mapEntries[String(k)] = v;
1413+
});
1414+
return { __type: 'Map', entries: mapEntries };
1415+
}
1416+
1417+
// Handle BigInt values
1418+
if (typeof value === 'bigint') {
1419+
return { __type: 'BigInt', value: value.toString() };
1420+
}
1421+
1422+
// Handle other special types as needed
1423+
// ...
1424+
1425+
return value;
1426+
}
1427+
1428+
return JSON.stringify(obj, replacer, indent);
1429+
}
1430+
1431+
1432+
13931433
}

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,11 @@ export class ClientService {
317317
constructedAddress: string,
318318
): Promise<{ unsignedTx: TxBuilder; clientId: bigint }> {
319319
const handlerUtxo: UTxO = await this.lucidService.findUtxoAtHandlerAuthToken();
320+
321+
this.logger.log('handlerUtxo: ' + this.prettyPrint(handlerUtxo), "buildUnsignedCreateClientTx");
320322
// Decode the handler datum from the handler UTXO
321323
const handlerDatum: HandlerDatum = await this.lucidService.decodeDatum<HandlerDatum>(handlerUtxo.datum!, 'handler');
324+
this.logger.log('handlerDatum: ' + this.prettyPrint(handlerDatum), "buildUnsignedCreateClientTx");
322325
// Create an updated handler datum with an incremented client sequence
323326
const updatedHandlerDatum: HandlerDatum = {
324327
...handlerDatum,
@@ -387,4 +390,41 @@ export class ClientService {
387390
},
388391
};
389392
}
393+
394+
private prettyPrint(obj: any, indent = 2): string {
395+
const seen = new WeakSet();
396+
397+
function replacer(key: string, value: any): any {
398+
// Handle circular references
399+
if (typeof value === 'object' && value !== null) {
400+
if (seen.has(value)) {
401+
return '[Circular Reference]';
402+
}
403+
seen.add(value);
404+
}
405+
406+
// Handle Map objects
407+
if (value instanceof Map) {
408+
const mapEntries: Record<string, any> = {};
409+
value.forEach((v, k) => {
410+
mapEntries[String(k)] = v;
411+
});
412+
return { __type: 'Map', entries: mapEntries };
413+
}
414+
415+
// Handle BigInt values
416+
if (typeof value === 'bigint') {
417+
return { __type: 'BigInt', value: value.toString() };
418+
}
419+
420+
// Handle other special types as needed
421+
// ...
422+
423+
return value;
424+
}
425+
426+
return JSON.stringify(obj, replacer, indent);
427+
}
428+
429+
390430
}

0 commit comments

Comments
 (0)