@distrohelena/canton-explorer 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,6 +28,7 @@ const CANTON_COIN_TOKEN_ID = 'canton-coin';
28
28
  const CANTON_COIN_TOKEN_NAME = 'Canton Coin';
29
29
  const CANTON_COIN_TRANSFER_TEMPLATE_ID = 'Splice.AmuletTransferInstruction:AmuletTransferInstruction';
30
30
  const CANTON_COIN_AMULET_TEMPLATE_ID = 'Splice.Amulet:Amulet';
31
+ const NATIVE_AMULET_INTRINSIC_ID = 'Amulet';
31
32
  const CIP56_HOLDING_TEMPLATE_ID = 'Splice.Api.Token.HoldingV1:Holding';
32
33
  const CIP56_TRANSFER_TEMPLATE_ID = 'Splice.Api.Token.TransferInstructionV1:Transfer';
33
34
  const CIP112_TEMPLATE_ID_LIKE_PATTERN = '%.CIP112:%';
@@ -1205,12 +1206,19 @@ let PqsSummaryService = class PqsSummaryService {
1205
1206
  const rawMetaRows = await this.queryRecentUpdateMetaRows(node, query, normalizedLimit, before, after, parties, templates, partyMode, hideSplice);
1206
1207
  const hasMoreInQuery = rawMetaRows.length > normalizedLimit;
1207
1208
  const trimmedMetaRows = rawMetaRows.slice(0, normalizedLimit);
1208
- const orderedUpdates = (useAfterCursor ? [...trimmedMetaRows].reverse() : trimmedMetaRows).map((row) => ({
1209
- eventOffset: this.extractEventOffset(row),
1210
- rawUpdateId: row.update_id,
1211
- updateId: this.normalizeUpdateId(row.update_id),
1212
- recordTime: row.record_time ?? null,
1213
- }));
1209
+ const orderedUpdates = (useAfterCursor ? [...trimmedMetaRows].reverse() : trimmedMetaRows).flatMap((row) => {
1210
+ if (typeof row.update_id !== 'string') {
1211
+ return [];
1212
+ }
1213
+ return [
1214
+ {
1215
+ eventOffset: this.extractEventOffset(row),
1216
+ rawUpdateId: row.update_id,
1217
+ updateId: this.normalizeUpdateId(row.update_id),
1218
+ recordTime: row.record_time ?? null,
1219
+ },
1220
+ ];
1221
+ });
1214
1222
  if (orderedUpdates.length === 0) {
1215
1223
  return {
1216
1224
  nodeId: node.id,
@@ -1398,12 +1406,17 @@ let PqsSummaryService = class PqsSummaryService {
1398
1406
  }
1399
1407
  }
1400
1408
  const rawRows = Array.from(dedupedRows.values());
1401
- const rawUpdateIds = rawRows.map((row) => row.update_id);
1409
+ const rawUpdateIds = rawRows
1410
+ .map((row) => row.update_id)
1411
+ .filter((updateId) => typeof updateId === 'string');
1402
1412
  const partiesByUpdateId = rawUpdateIds.length > 0
1403
1413
  ? await this.fetchPartiesByUpdateId(node, client.query.bind(client), rawUpdateIds)
1404
1414
  : new Map();
1405
1415
  return rawRows
1406
1416
  .map((row) => {
1417
+ if (typeof row.update_id !== 'string') {
1418
+ return null;
1419
+ }
1407
1420
  const normalizedUpdateId = this.normalizeUpdateId(row.update_id);
1408
1421
  const eventOffset = this.extractEventOffset(row);
1409
1422
  const exact = this.isExactMatch(query, [eventOffset, normalizedUpdateId]);
@@ -2493,20 +2506,27 @@ let PqsSummaryService = class PqsSummaryService {
2493
2506
  const client = this.clientFactory.getClient(node);
2494
2507
  const result = await client.query(pqsPartyRecentUpdatesQuery(node, partyId, limit));
2495
2508
  const rows = result.rows ?? [];
2496
- const rawUpdateIds = rows.map((row) => row.update_id);
2509
+ const rawUpdateIds = rows
2510
+ .map((row) => row.update_id)
2511
+ .filter((updateId) => typeof updateId === 'string');
2497
2512
  const partiesByUpdateId = rawUpdateIds.length > 0
2498
2513
  ? await this.fetchPartiesByUpdateId(node, client.query.bind(client), rawUpdateIds)
2499
2514
  : new Map();
2500
- return rows.map((row) => {
2515
+ return rows.flatMap((row) => {
2516
+ if (typeof row.update_id !== 'string') {
2517
+ return [];
2518
+ }
2501
2519
  const updateId = this.normalizeUpdateId(row.update_id);
2502
- return {
2503
- nodeId: node.id,
2504
- label: node.label,
2505
- eventOffset: this.extractEventOffset(row),
2506
- updateId,
2507
- recordTime: typeof row.record_time === 'string' ? row.record_time : null,
2508
- parties: partiesByUpdateId.get(updateId) ?? [],
2509
- };
2520
+ return [
2521
+ {
2522
+ nodeId: node.id,
2523
+ label: node.label,
2524
+ eventOffset: this.extractEventOffset(row),
2525
+ updateId,
2526
+ recordTime: typeof row.record_time === 'string' ? row.record_time : null,
2527
+ parties: partiesByUpdateId.get(updateId) ?? [],
2528
+ },
2529
+ ];
2510
2530
  });
2511
2531
  }
2512
2532
  async fetchPartyRecentContractsForNode(node, partyId, limit) {
@@ -3033,6 +3053,9 @@ let PqsSummaryService = class PqsSummaryService {
3033
3053
  return negative ? -parsed : parsed;
3034
3054
  }
3035
3055
  normalizeUpdateId(updateId) {
3056
+ if (typeof updateId !== 'string') {
3057
+ return '';
3058
+ }
3036
3059
  return updateId.startsWith('\\x') ? updateId.slice(2) : updateId;
3037
3060
  }
3038
3061
  extractTokenMovement(templateId, decoded) {
@@ -3085,14 +3108,7 @@ let PqsSummaryService = class PqsSummaryService {
3085
3108
  return null;
3086
3109
  }
3087
3110
  const issuer = this.readNestedScalarField(decoded.value, ['instrumentId', 'admin']);
3088
- const tokenId = this.buildObservedTokenId(intrinsicId, issuer);
3089
- return {
3090
- tokenId,
3091
- name: this.readConfiguredDecodedTokenMetadata(decoded.value, 'name') ?? intrinsicId,
3092
- symbol: this.readConfiguredDecodedTokenMetadata(decoded.value, 'symbol'),
3093
- issuer,
3094
- source: 'pqs',
3095
- };
3111
+ return this.buildObservedTokenSummary(intrinsicId, issuer, this.readConfiguredDecodedTokenMetadata(decoded.value, 'name') ?? intrinsicId, this.readConfiguredDecodedTokenMetadata(decoded.value, 'symbol'));
3096
3112
  }
3097
3113
  extractObservedTokenSummary(templateId, decoded) {
3098
3114
  if (!templateId) {
@@ -3123,14 +3139,25 @@ let PqsSummaryService = class PqsSummaryService {
3123
3139
  ?? this.readNestedScalarField(decoded.value, ['vaultIdentity', 'admin'])
3124
3140
  ?? this.readScalarField(decoded.value, 'vaultParty')
3125
3141
  ?? this.readScalarField(decoded.value, 'issuer');
3126
- const tokenId = this.buildObservedTokenId(intrinsicId, issuer);
3142
+ return this.buildObservedTokenSummary(intrinsicId, issuer, this.readConfiguredDecodedTokenMetadata(decoded.value, 'name')
3143
+ ?? this.readScalarField(decoded.value, 'name')
3144
+ ?? instrumentIdText
3145
+ ?? symbol
3146
+ ?? intrinsicId, symbol);
3147
+ }
3148
+ buildObservedTokenSummary(intrinsicId, issuer, fallbackName, symbol) {
3149
+ if (this.isNativeAmuletIntrinsicId(intrinsicId)) {
3150
+ return {
3151
+ tokenId: CANTON_COIN_TOKEN_ID,
3152
+ name: CANTON_COIN_TOKEN_NAME,
3153
+ symbol: null,
3154
+ issuer: null,
3155
+ source: 'pqs',
3156
+ };
3157
+ }
3127
3158
  return {
3128
- tokenId,
3129
- name: this.readConfiguredDecodedTokenMetadata(decoded.value, 'name')
3130
- ?? this.readScalarField(decoded.value, 'name')
3131
- ?? instrumentIdText
3132
- ?? symbol
3133
- ?? intrinsicId,
3159
+ tokenId: this.buildObservedTokenId(intrinsicId, issuer),
3160
+ name: fallbackName,
3134
3161
  symbol,
3135
3162
  issuer,
3136
3163
  source: 'pqs',
@@ -3144,6 +3171,9 @@ let PqsSummaryService = class PqsSummaryService {
3144
3171
  }
3145
3172
  return `${normalizedIssuer}::${normalizedIntrinsicId}`;
3146
3173
  }
3174
+ isNativeAmuletIntrinsicId(intrinsicId) {
3175
+ return intrinsicId.trim() === NATIVE_AMULET_INTRINSIC_ID;
3176
+ }
3147
3177
  normalizeShareLikeIntrinsicTokenId(intrinsicId) {
3148
3178
  const normalizedIntrinsicId = intrinsicId.trim();
3149
3179
  if (normalizedIntrinsicId.endsWith(':share')) {