@xyo-network/chain-bridge 1.23.2 → 2.0.0

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.
Files changed (115) hide show
  1. package/dist/node/BridgeActor.d.ts +1 -0
  2. package/dist/node/BridgeActor.d.ts.map +1 -1
  3. package/dist/node/index.mjs +1495 -1014
  4. package/dist/node/index.mjs.map +4 -4
  5. package/dist/node/server/routes/bridge/routeDefinitions/getRouteDefinitions.d.ts.map +1 -1
  6. package/dist/node/server/routes/bridge/routeDefinitions/pathParams/ChainIdPathParam.d.ts +2 -1
  7. package/dist/node/server/routes/bridge/routeDefinitions/pathParams/ChainIdPathParam.d.ts.map +1 -1
  8. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeConfig.d.ts +0 -22
  9. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeConfig.d.ts.map +1 -1
  10. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteEstimate.d.ts +0 -89
  11. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteEstimate.d.ts.map +1 -1
  12. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetry.d.ts +10 -0
  13. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetry.d.ts.map +1 -0
  14. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetryFailed.d.ts +9 -0
  15. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteRetryFailed.d.ts.map +1 -0
  16. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatus.d.ts +0 -81
  17. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatus.d.ts.map +1 -1
  18. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatusByTx.d.ts +28 -0
  19. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeFromRemoteStatusByTx.d.ts.map +1 -0
  20. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts +0 -81
  21. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts.map +1 -1
  22. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts +0 -72
  23. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts.map +1 -1
  24. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts +0 -72
  25. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts.map +1 -1
  26. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetry.d.ts +10 -0
  27. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetry.d.ts.map +1 -0
  28. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetryFailed.d.ts +9 -0
  29. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteRetryFailed.d.ts.map +1 -0
  30. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts +0 -81
  31. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts.map +1 -1
  32. package/dist/node/server/routes/bridge/routeDefinitions/routes/index.d.ts +5 -0
  33. package/dist/node/server/routes/bridge/routeDefinitions/routes/index.d.ts.map +1 -1
  34. package/dist/node/server/server.d.ts +3 -1
  35. package/dist/node/server/server.d.ts.map +1 -1
  36. package/dist/node/services/BridgeFulfillmentState.d.ts +21 -12
  37. package/dist/node/services/BridgeFulfillmentState.d.ts.map +1 -1
  38. package/dist/node/services/IBridgeServiceCollection.d.ts +8 -1
  39. package/dist/node/services/IBridgeServiceCollection.d.ts.map +1 -1
  40. package/dist/node/services/evm/getFeeStructure.d.ts +1 -1
  41. package/dist/node/services/evm/getFeeStructure.d.ts.map +1 -1
  42. package/dist/node/services/evm/index.d.ts +1 -0
  43. package/dist/node/services/evm/index.d.ts.map +1 -1
  44. package/dist/node/services/evm/resolveDeployBlock.d.ts +28 -0
  45. package/dist/node/services/evm/resolveDeployBlock.d.ts.map +1 -0
  46. package/dist/node/services/getServices.d.ts +3 -1
  47. package/dist/node/services/getServices.d.ts.map +1 -1
  48. package/dist/node/services/queue/flows/createEthToXl1BridgeJob/getJobIdForEthToXl1BridgeJob.d.ts +2 -13
  49. package/dist/node/services/queue/flows/createEthToXl1BridgeJob/getJobIdForEthToXl1BridgeJob.d.ts.map +1 -1
  50. package/dist/node/services/queue/index.d.ts +2 -0
  51. package/dist/node/services/queue/index.d.ts.map +1 -1
  52. package/dist/node/services/queue/retryFailedJobs.d.ts +39 -0
  53. package/dist/node/services/queue/retryFailedJobs.d.ts.map +1 -0
  54. package/dist/node/services/queue/retrySingleFailedJob.d.ts +29 -0
  55. package/dist/node/services/queue/retrySingleFailedJob.d.ts.map +1 -0
  56. package/dist/node/services/queue/scanner/EvmBridgeCursor.d.ts +1 -0
  57. package/dist/node/services/queue/scanner/EvmBridgeCursor.d.ts.map +1 -1
  58. package/dist/node/services/queue/scanner/EvmBridgeScanner.d.ts +1 -0
  59. package/dist/node/services/queue/scanner/EvmBridgeScanner.d.ts.map +1 -1
  60. package/dist/node/services/queue/scanner/EvmBridgeScannerRunner.d.ts +1 -2
  61. package/dist/node/services/queue/scanner/EvmBridgeScannerRunner.d.ts.map +1 -1
  62. package/dist/node/services/queue/scanner/buildEvmBridgeScannerRunner.d.ts +0 -3
  63. package/dist/node/services/queue/scanner/buildEvmBridgeScannerRunner.d.ts.map +1 -1
  64. package/dist/node/services/queue/workers/EthEventVerification.d.ts.map +1 -1
  65. package/dist/node/services/queue/workers/EthToXl1BridgeParent.d.ts.map +1 -1
  66. package/dist/node/services/queue/workers/EthTransactionMonitor.d.ts.map +1 -1
  67. package/dist/node/services/queue/workers/EthTransactionPreparation.d.ts.map +1 -1
  68. package/dist/node/services/queue/workers/EthTransactionSubmission.d.ts.map +1 -1
  69. package/dist/node/services/queue/workers/EthTransactionSubmissionStorage.d.ts.map +1 -1
  70. package/dist/node/services/queue/workers/Xl1ReserveTxFulfillment.d.ts.map +1 -1
  71. package/dist/node/services/queue/workers/Xl1ToEthBridgeParent.d.ts.map +1 -1
  72. package/dist/node/services/queue/workers/Xl1TransactionMonitor.d.ts.map +1 -1
  73. package/dist/node/services/queue/workers/Xl1TransactionPreparation.d.ts.map +1 -1
  74. package/dist/node/services/queue/workers/Xl1TransactionSubmission.d.ts.map +1 -1
  75. package/dist/node/services/queue/workers/Xl1TransactionSubmissionStorage.d.ts.map +1 -1
  76. package/dist/node/services/queue/workers/util/buildAcceptedSnapshot.d.ts +47 -0
  77. package/dist/node/services/queue/workers/util/buildAcceptedSnapshot.d.ts.map +1 -0
  78. package/dist/node/services/queue/workers/util/buildEthToXl1ReserveTx.d.ts.map +1 -1
  79. package/dist/node/services/queue/workers/util/index.d.ts +1 -1
  80. package/dist/node/services/queue/workers/util/index.d.ts.map +1 -1
  81. package/dist/node/services/queue/workers/util/resolveEvmBlockTagAtDepth.d.ts +7 -3
  82. package/dist/node/services/queue/workers/util/resolveEvmBlockTagAtDepth.d.ts.map +1 -1
  83. package/dist/node/services/queue/workers/util/verifyEthBridgeEvent.d.ts +7 -4
  84. package/dist/node/services/queue/workers/util/verifyEthBridgeEvent.d.ts.map +1 -1
  85. package/dist/node/services/util/generateBridgeEstimate.d.ts.map +1 -1
  86. package/dist/node/services/util/index.d.ts +0 -5
  87. package/dist/node/services/util/index.d.ts.map +1 -1
  88. package/dist/node/services/validation/validateBridgeEstimate.d.ts.map +1 -1
  89. package/dist/node/services/validation/validateSufficientXl1ReserveBalance.d.ts +15 -10
  90. package/dist/node/services/validation/validateSufficientXl1ReserveBalance.d.ts.map +1 -1
  91. package/dist/node/telemetry/bucketFailureReason.d.ts +17 -0
  92. package/dist/node/telemetry/bucketFailureReason.d.ts.map +1 -0
  93. package/dist/node/telemetry/createBalanceMonitor.d.ts +5 -0
  94. package/dist/node/telemetry/createBalanceMonitor.d.ts.map +1 -1
  95. package/dist/node/telemetry/createBridgeFlowMetrics.d.ts +76 -0
  96. package/dist/node/telemetry/createBridgeFlowMetrics.d.ts.map +1 -0
  97. package/dist/node/telemetry/createInFlightPoller.d.ts +29 -0
  98. package/dist/node/telemetry/createInFlightPoller.d.ts.map +1 -0
  99. package/dist/node/telemetry/createQueueMetrics.d.ts +4 -0
  100. package/dist/node/telemetry/createQueueMetrics.d.ts.map +1 -1
  101. package/dist/node/telemetry/index.d.ts +3 -0
  102. package/dist/node/telemetry/index.d.ts.map +1 -1
  103. package/package.json +89 -88
  104. package/dist/node/services/queue/workers/util/buildEthToXl1BridgePayloads.d.ts +0 -44
  105. package/dist/node/services/queue/workers/util/buildEthToXl1BridgePayloads.d.ts.map +0 -1
  106. package/dist/node/services/util/BridgeFees.d.ts +0 -13
  107. package/dist/node/services/util/BridgeFees.d.ts.map +0 -1
  108. package/dist/node/services/util/bridgeFeesAsBigInt.d.ts +0 -7
  109. package/dist/node/services/util/bridgeFeesAsBigInt.d.ts.map +0 -1
  110. package/dist/node/services/util/calculateBridgeFees.d.ts +0 -6
  111. package/dist/node/services/util/calculateBridgeFees.d.ts.map +0 -1
  112. package/dist/node/services/util/calculateMaxBridgeAmount.d.ts +0 -11
  113. package/dist/node/services/util/calculateMaxBridgeAmount.d.ts.map +0 -1
  114. package/dist/node/services/util/createBridgeTransfer.d.ts +0 -14
  115. package/dist/node/services/util/createBridgeTransfer.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Xl1TransactionSubmission.d.ts","sourceRoot":"","sources":["../../../../../src/services/queue/workers/Xl1TransactionSubmission.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAKjC,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAEvE,MAAM,MAAM,+BAA+B,GAAG,qBAAqB,CAAA;AACnE,MAAM,WAAW,iCAAiC;IAChD,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACvD;AACD,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,+BAA+B,EAAE,iCAAiC,CAAC,CAAA;AAkDjH,eAAO,MAAM,wBAAwB,EAAE,iBAEtC,CAAA"}
1
+ {"version":3,"file":"Xl1TransactionSubmission.d.ts","sourceRoot":"","sources":["../../../../../src/services/queue/workers/Xl1TransactionSubmission.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAKjC,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAG1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAEvE,MAAM,MAAM,+BAA+B,GAAG,qBAAqB,CAAA;AACnE,MAAM,WAAW,iCAAiC;IAChD,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACvD;AACD,MAAM,MAAM,2BAA2B,GAAG,GAAG,CAAC,+BAA+B,EAAE,iCAAiC,CAAC,CAAA;AAqDjH,eAAO,MAAM,wBAAwB,EAAE,iBAEtC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Xl1TransactionSubmissionStorage.d.ts","sourceRoot":"","sources":["../../../../../src/services/queue/workers/Xl1TransactionSubmissionStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAKjC,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIvE,MAAM,MAAM,sCAAsC,GAAG,qBAAqB,CAAA;AAC1E,MAAM,WAAW,wCAAwC;IACvD,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACvD;AACD,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAAC,sCAAsC,EAAE,wCAAwC,CAAC,CAAA;AAwDtI,eAAO,MAAM,+BAA+B,EAAE,iBAE7C,CAAA"}
1
+ {"version":3,"file":"Xl1TransactionSubmissionStorage.d.ts","sourceRoot":"","sources":["../../../../../src/services/queue/workers/Xl1TransactionSubmissionStorage.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAKjC,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIvE,MAAM,MAAM,sCAAsC,GAAG,qBAAqB,CAAA;AAC1E,MAAM,WAAW,wCAAwC;IACvD,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACvD;AACD,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAAC,sCAAsC,EAAE,wCAAwC,CAAC,CAAA;AA2DtI,eAAO,MAAM,+BAA+B,EAAE,iBAE7C,CAAA"}
@@ -0,0 +1,47 @@
1
+ import type { Address, Hash, Hex } from '@xylabs/sdk-js';
2
+ import type { BridgeFees } from '@xyo-network/chain-bridge-shared';
3
+ import type { BridgeDestinationObservation, BridgeIntent, BridgeSourceObservation, ChainId } from '@xyo-network/xl1-sdk';
4
+ export interface BuildAcceptedSnapshotOptions {
5
+ /** Gross EVM deposit, in atto. */
6
+ amount: bigint;
7
+ /** XL1 address that will sign the Stage 2 reserve transfer (the bridge wallet). */
8
+ bridgeAccountAddress: Address;
9
+ /** Contract-assigned bridge id. */
10
+ bridgeId: bigint;
11
+ destAddress: Address;
12
+ evmChainId: Hex;
13
+ evmContractAddress: Address;
14
+ evmSrcAddress: Address;
15
+ evmTokenAddress: Hex;
16
+ /** Tx hash of the EVM transaction that emitted BridgedToRemote(bridgeId). */
17
+ evmTxHash: Hex;
18
+ feeFixed: Hex;
19
+ feeRateBasisPoints: number;
20
+ feesAddress: Address;
21
+ xl1ChainId: ChainId;
22
+ xl1TokenAddress: Hex;
23
+ }
24
+ export interface AcceptedSnapshot {
25
+ acceptedFees: BridgeFees;
26
+ acceptedIntent: BridgeIntent;
27
+ acceptedSourceObservation: BridgeSourceObservation;
28
+ }
29
+ /**
30
+ * Builds the at-acceptance snapshot for an inbound (EVM→XL1) bridge — the BridgeIntent, the
31
+ * BridgeFees value computed against the in-force fee config, and the BridgeSourceObservation
32
+ * (the intent extended with `srcConfirmation = evmTxHash`). Stage 1 writes these onto the
33
+ * fulfillment state immediately after canonical verification so downstream consumers see a
34
+ * stable view that doesn't drift if fee config changes mid-flight.
35
+ *
36
+ * Composes existing bridge-shared helpers — fees come from `calculateBridgeFees`, the intent
37
+ * from `buildEthToXl1BridgePayloads` (the Transfer it also returns is discarded; Stage 2
38
+ * rebuilds the Transfer from the snapshotted intent for actual submission).
39
+ */
40
+ export declare function buildAcceptedSnapshot(options: BuildAcceptedSnapshotOptions): AcceptedSnapshot;
41
+ /**
42
+ * Build the at-fulfillment destination observation. Extends the snapshotted intent with the
43
+ * `destConfirmation` set to the included XL1 tx hash. Symmetric to Stage 1's source-
44
+ * observation construction (which extends the intent with `srcConfirmation`).
45
+ */
46
+ export declare function buildAcceptedDestinationObservation(intent: BridgeIntent, destConfirmation: Hash): BridgeDestinationObservation;
47
+ //# sourceMappingURL=buildAcceptedSnapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildAcceptedSnapshot.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/buildAcceptedSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAAE,IAAI,EAAE,GAAG,EACnB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAA;AAGlE,OAAO,KAAK,EACV,4BAA4B,EAAE,YAAY,EAAE,uBAAuB,EAAE,OAAO,EAC7E,MAAM,sBAAsB,CAAA;AAK7B,MAAM,WAAW,4BAA4B;IAC3C,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,mFAAmF;IACnF,oBAAoB,EAAE,OAAO,CAAA;IAC7B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,GAAG,CAAA;IACf,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,GAAG,CAAA;IACpB,6EAA6E;IAC7E,SAAS,EAAE,GAAG,CAAA;IACd,QAAQ,EAAE,GAAG,CAAA;IACb,kBAAkB,EAAE,MAAM,CAAA;IAC1B,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,GAAG,CAAA;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,UAAU,CAAA;IACxB,cAAc,EAAE,YAAY,CAAA;IAC5B,yBAAyB,EAAE,uBAAuB,CAAA;CACnD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,gBAAgB,CA+C7F;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,YAAY,EACpB,gBAAgB,EAAE,IAAI,GACrB,4BAA4B,CAQ9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildEthToXl1ReserveTx.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/buildEthToXl1ReserveTx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EACe,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAC5E,MAAM,sBAAsB,CAAA;AAK7B,MAAM,WAAW,6BAA6B;IAC5C;kFAC8E;IAC9E,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,eAAe,CAAA;IAC9B,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,GAAG,CAAA;IACf,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,GAAG,CAAA;IACpB,6EAA6E;IAC7E,SAAS,EAAE,GAAG,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB;sFACkF;IAClF,WAAW,EAAE,OAAO,CAAA;IACpB;;yEAEqE;IACrE,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,GAAG,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,yBAAyB,CAAC,CAgEpC"}
1
+ {"version":3,"file":"buildEthToXl1ReserveTx.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/buildEthToXl1ReserveTx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAGlD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D,OAAO,KAAK,EACe,OAAO,EAAE,yBAAyB,EAAE,cAAc,EAC5E,MAAM,sBAAsB,CAAA;AAG7B,MAAM,WAAW,6BAA6B;IAC5C;kFAC8E;IAC9E,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,eAAe,CAAA;IAC9B,4EAA4E;IAC5E,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,OAAO,CAAA;IACpB,UAAU,EAAE,GAAG,CAAA;IACf,kBAAkB,EAAE,OAAO,CAAA;IAC3B,aAAa,EAAE,OAAO,CAAA;IACtB,eAAe,EAAE,GAAG,CAAA;IACpB,6EAA6E;IAC7E,SAAS,EAAE,GAAG,CAAA;IACd,GAAG,EAAE,cAAc,CAAA;IACnB;sFACkF;IAClF,WAAW,EAAE,OAAO,CAAA;IACpB;;yEAEqE;IACrE,UAAU,EAAE,MAAM,CAAA;IAClB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;IACnB,eAAe,EAAE,GAAG,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,yBAAyB,CAAC,CAgEpC"}
@@ -1,4 +1,4 @@
1
- export * from './buildEthToXl1BridgePayloads.ts';
1
+ export * from './buildAcceptedSnapshot.ts';
2
2
  export * from './buildEthToXl1ReserveTx.ts';
3
3
  export * from './resolveEvmBlockTagAtDepth.ts';
4
4
  export * from './submitEthTransaction.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAA;AAChD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA;AACzC,cAAc,2BAA2B,CAAA"}
@@ -20,8 +20,12 @@ import type { EvmConfirmationDepth } from '../../../evm/index.ts';
20
20
  * yet) and ethers throws BAD_DATA. Letting the server resolve 'latest' at call time
21
21
  * sidesteps the race entirely. Also saves the head-fetch round-trip.
22
22
  *
23
- * - numeric depth > 0: subtract from the current head and clamp to >= 0. The head fetch
24
- * is unavoidable here — we need a specific past block, not the live head.
23
+ * - numeric depth > 0: subtract from the current head and clamp to >= `deployBlock`.
24
+ * The head fetch is unavoidable here — we need a specific past block, not the live
25
+ * head. The deploy-block floor guards against the early-life scenario where
26
+ * `head - depth < deployBlock` (e.g. the actor starts on a 32-confirmation depth a
27
+ * few blocks after deploy): a pre-deploy block would fail an `eth_call` with
28
+ * BAD_DATA, so we clamp upward to the deploy block instead.
25
29
  */
26
- export declare function resolveEvmBlockTagAtDepth(provider: Provider, depth: EvmConfirmationDepth): Promise<number | 'latest' | 'finalized'>;
30
+ export declare function resolveEvmBlockTagAtDepth(provider: Provider, depth: EvmConfirmationDepth, deployBlock: number): Promise<number | 'latest' | 'finalized'>;
27
31
  //# sourceMappingURL=resolveEvmBlockTagAtDepth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolveEvmBlockTagAtDepth.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/resolveEvmBlockTagAtDepth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC,CAK1C"}
1
+ {"version":3,"file":"resolveEvmBlockTagAtDepth.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/resolveEvmBlockTagAtDepth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAEtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,oBAAoB,EAC3B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,QAAQ,GAAG,WAAW,CAAC,CAK1C"}
@@ -8,6 +8,10 @@ export interface EthBridgeEventData {
8
8
  destToken: Address;
9
9
  /** Tx hash of the EVM transaction that emitted BridgedToRemote(id). */
10
10
  evmTxHash: Hex;
11
+ /** Wall-clock timestamp (epoch ms) the bridge actor observed the event at confirmation
12
+ * depth. Optional for back-compat with state-map entries written before this field
13
+ * existed; new writes always populate it. Powers the settle-latency histogram. */
14
+ observedAt?: number;
11
15
  srcAddress: Address;
12
16
  }
13
17
  /**
@@ -23,9 +27,8 @@ export interface EthBridgeEventData {
23
27
  * or never reached canonical state — the caller must treat this as terminal.
24
28
  *
25
29
  * The event-log lookup is what surfaces the EVM tx hash for `BridgeSourceObservation`'s
26
- * `srcConfirmation`. It scans from genesis to the depth-tagged block; on chains with long
27
- * history this is expensive, so a future optimization should narrow the range (cache the
28
- * contract's deploy block or accept a fromBlock hint).
30
+ * `srcConfirmation`. Floored at `deployBlock` (cached at actor startup) so the eth_getLogs
31
+ * range is the contract's lifetime, not genesis-to-now.
29
32
  */
30
- export declare function verifyEthBridgeEvent(id: bigint, bridge: LiquidityPoolBridge, provider: Provider, confirmationDepth: EvmConfirmationDepth): Promise<EthBridgeEventData | null>;
33
+ export declare function verifyEthBridgeEvent(id: bigint, bridge: LiquidityPoolBridge, provider: Provider, confirmationDepth: EvmConfirmationDepth, deployBlock: number): Promise<EthBridgeEventData | null>;
31
34
  //# sourceMappingURL=verifyEthBridgeEvent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verifyEthBridgeEvent.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/verifyEthBridgeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAGjE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,uEAAuE;IACvE,SAAS,EAAE,GAAG,CAAA;IACd,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,oBAAoB,GACtC,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA0BpC"}
1
+ {"version":3,"file":"verifyEthBridgeEvent.d.ts","sourceRoot":"","sources":["../../../../../../src/services/queue/workers/util/verifyEthBridgeEvent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAGtC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAGjE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,OAAO,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,uEAAuE;IACvE,SAAS,EAAE,GAAG,CAAA;IACd;;sFAEkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,QAAQ,EAClB,iBAAiB,EAAE,oBAAoB,EACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CA4BpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"generateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/util/generateBridgeEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EACV,YAAY,EAAsB,QAAQ,EAC3C,MAAM,sBAAsB,CAAA;AAQ7B,eAAO,MAAM,sBAAsB,GACjC,YAAY,GAAG,EACf,WAAW,GAAG,EACd,aAAa,GAAG,EAChB,QAAQ,YAAY,EACpB,gBAAgB,MAAM,KACrB,OAAO,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAkClC,CAAA"}
1
+ {"version":3,"file":"generateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/util/generateBridgeEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIlE,eAAO,MAAM,sBAAsB,GACjC,YAAY,GAAG,EACf,WAAW,GAAG,EACd,aAAa,GAAG,EAChB,QAAQ,YAAY,EACpB,gBAAgB,MAAM,KACrB,OAAO,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAGlC,CAAA"}
@@ -1,8 +1,3 @@
1
- export * from './BridgeFees.ts';
2
- export * from './bridgeFeesAsBigInt.ts';
3
- export * from './calculateBridgeFees.ts';
4
- export * from './calculateMaxBridgeAmount.ts';
5
- export * from './createBridgeTransfer.ts';
6
1
  export * from './generateBridgeEstimate.ts';
7
2
  export * from './getConfigFromEnv.ts';
8
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/services/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"validateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateBridgeEstimate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKlE;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAuCjB,CAAA"}
1
+ {"version":3,"file":"validateBridgeEstimate.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateBridgeEstimate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAIlE;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAuCjB,CAAA"}
@@ -8,21 +8,26 @@ export interface ValidateSufficientXl1ReserveBalanceArgs {
8
8
  logger?: AsyncLogger;
9
9
  }
10
10
  /**
11
- * Checks that the bridge's XL1 reserve account has at least `amount` of native balance
12
- * available to cover an inbound (EVM XL1) reserve transfer. Mirrors the XL1 EVM
13
- * direction's `validateSufficientXL1SourceAddressBalance` in spirit: a quick pre-flight
14
- * gate to avoid building, signing, and dispatching a transaction the chain will then
15
- * reject for insufficient funds.
11
+ * 1 XL1 of headroom above the requested amount. The actual XL1 transaction the bridge will
12
+ * submit pays a small network fee on top of the transfer; without a buffer, an exactly-equal
13
+ * balance check would pass here and the chain would then reject the tx for being a few atto
14
+ * short. One XL1 is far above any realistic per-tx fee and stays comfortably under the
15
+ * configured minBridgeAmount (1500 XL1 by default), so it doesn't materially affect the
16
+ * threshold at which legitimate bridges become serviceable.
17
+ */
18
+ export declare const RESERVE_FEE_BUFFER: bigint;
19
+ /**
20
+ * Checks that the bridge's XL1 reserve account has at least `amount + RESERVE_FEE_BUFFER`
21
+ * of native balance available to cover an inbound (EVM → XL1) reserve transfer plus the
22
+ * network fee the actual submission will pay. Mirrors the XL1 → EVM direction's
23
+ * `validateSufficientXL1SourceAddressBalance` in spirit: a quick pre-flight gate to avoid
24
+ * building, signing, and dispatching a transaction the chain will then reject for
25
+ * insufficient funds.
16
26
  *
17
27
  * Race conditions: a concurrent submission could deplete the reserve between this check
18
28
  * and the actual XL1 submission. That's acceptable — the worker chain will fail the
19
29
  * submission, BullMQ will retry, and the next retry will re-validate. The check exists to
20
30
  * filter the bulk of insufficient-balance cases cheaply, not to be perfectly atomic.
21
- *
22
- * Network fees are not included in the comparison (matching the XL1 → EVM validator's
23
- * convention). Operators are expected to keep the reserve sufficiently above any single
24
- * bridge amount; tiny network-fee deltas would only flip the outcome at the margin and
25
- * BullMQ retry handles those.
26
31
  */
27
32
  export declare function validateSufficientXl1ReserveBalance({ amount, bridgeAccount, gateway, logger, }: ValidateSufficientXl1ReserveBalanceArgs): Promise<boolean>;
28
33
  //# sourceMappingURL=validateSufficientXl1ReserveBalance.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validateSufficientXl1ReserveBalance.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateSufficientXl1ReserveBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,MAAM,WAAW,uCAAuC;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,eAAe,CAAA;IAC9B,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mCAAmC,CAAC,EACxD,MAAM,EACN,aAAa,EACb,OAAO,EACP,MAAM,GACP,EAAE,uCAAuC,GAAG,OAAO,CAAC,OAAO,CAAC,CAK5D"}
1
+ {"version":3,"file":"validateSufficientXl1ReserveBalance.d.ts","sourceRoot":"","sources":["../../../../src/services/validation/validateSufficientXl1ReserveBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAG5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD,MAAM,WAAW,uCAAuC;IACtD,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,eAAe,CAAA;IAC9B,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,MAAsC,CAAA;AAEvE;;;;;;;;;;;;GAYG;AACH,wBAAsB,mCAAmC,CAAC,EACxD,MAAM,EACN,aAAa,EACb,OAAO,EACP,MAAM,GACP,EAAE,uCAAuC,GAAG,OAAO,CAAC,OAAO,CAAC,CAS5D"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Closed-enum failure-reason buckets for the bridge's terminal-failure counter. Free-form
3
+ * `failedReason` strings (from thrown Errors at BullMQ retry exhaustion) get collapsed to
4
+ * one of these values so the metric label stays low-cardinality and queryable.
5
+ *
6
+ * Adding a new bucket here means the `reason` label gets a new possible value — coordinate
7
+ * with the dashboard / alert rules before doing so.
8
+ */
9
+ export type BridgeFailureReason = 'attempts_exhausted' | 'below_min_bridge_amount' | 'orphaned_at_depth' | 'other' | 'reserve_insufficient';
10
+ /**
11
+ * Map a free-form `failedReason` (BullMQ's `Job.failedReason` or `Error.message` at terminal
12
+ * failure) into a `BridgeFailureReason`. Order matters — more specific patterns come first
13
+ * so the well-known structured errors don't fall through to the generic 'attempts_exhausted'
14
+ * bucket.
15
+ */
16
+ export declare function bucketFailureReason(failedReason: string): BridgeFailureReason;
17
+ //# sourceMappingURL=bucketFailureReason.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bucketFailureReason.d.ts","sourceRoot":"","sources":["../../../src/telemetry/bucketFailureReason.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,MAAM,mBAAmB,GACzB,oBAAoB,GACpB,yBAAyB,GACzB,mBAAmB,GACnB,OAAO,GACP,sBAAsB,CAAA;AAE5B;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB,CAS7E"}
@@ -1,4 +1,5 @@
1
1
  import type { Meter } from '@opentelemetry/api';
2
+ import type { Hex } from '@xylabs/sdk-js';
2
3
  import type { AccountInstance } from '@xyo-network/sdk-js';
3
4
  import type { BridgeableToken, LiquidityPoolBridge } from '@xyo-network/typechain';
4
5
  import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk';
@@ -11,6 +12,10 @@ export interface BalanceMonitorConfig {
11
12
  intervalMs?: number;
12
13
  meter: Meter;
13
14
  provider: Provider;
15
+ /** Remote (EVM) chain id, attached as a low-cardinality `remoteChainId` label so a
16
+ * single bridge actor monitoring multiple destinations can be queried per-chain in
17
+ * Prometheus. */
18
+ remoteChainId: Hex;
14
19
  wallet: Wallet;
15
20
  }
16
21
  export interface BalanceMonitorHandle {
@@ -1 +1 @@
1
- {"version":3,"file":"createBalanceMonitor.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createBalanceMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAOD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAsFvF"}
1
+ {"version":3,"file":"createBalanceMonitor.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createBalanceMonitor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,eAAe,CAAA;IACxB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,eAAe,EAAE,eAAe,CAAA;IAChC,OAAO,EAAE,gBAAgB,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB;;qBAEiB;IACjB,aAAa,EAAE,GAAG,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAOD,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAwFvF"}
@@ -0,0 +1,76 @@
1
+ import type { Meter } from '@opentelemetry/api';
2
+ import type { Hex } from '@xylabs/sdk-js';
3
+ import type { BridgeFailureReason } from './bucketFailureReason.ts';
4
+ export type BridgeDirection = 'inbound' | 'outbound';
5
+ /**
6
+ * What user-facing action caused the retry. `api_singular` for the singular retry routes
7
+ * (one bridge id, one increment); `api_bulk` for the bulk retryFailed routes (one
8
+ * increment per actually-retried job). BullBoard's manual retry button has no operator-
9
+ * facing hook today, so it is deliberately not represented here.
10
+ */
11
+ export type BridgeRetryTrigger = 'api_singular' | 'api_bulk';
12
+ export interface RecordBridgeRetryOptions {
13
+ /** Default 1. Bulk routes pass `result.counts.retried` so a single call records the
14
+ * whole batch atomically. */
15
+ count?: number;
16
+ direction: BridgeDirection;
17
+ trigger: BridgeRetryTrigger;
18
+ }
19
+ export interface RecordBridgeSuccessOptions {
20
+ direction: BridgeDirection;
21
+ /** Fee skim, in AttoXL1, attributable to this single bridge. Recorded as a counter
22
+ * increment on bridge_fee_revenue_total. */
23
+ feeAmount: bigint;
24
+ /** Wall-clock seconds from acceptance (canonical observed) to fulfillment (tx submitted /
25
+ * confirmed). Optional — outbound may pass `undefined` when a clean
26
+ * acceptance-to-fulfillment timestamp isn't available, in which case the histogram is
27
+ * not recorded for that flow. */
28
+ latencySeconds?: number;
29
+ /** Token contract / chain id the fee is denominated in. Bridge fees are XL1-denominated
30
+ * for both directions today; this label exists so future direction-specific fee streams
31
+ * can be distinguished without a metric rename. */
32
+ token: Hex;
33
+ }
34
+ export interface BridgeFlowMetricsConfig {
35
+ /** Optional — when absent (no OTel meter wired up), the returned handle records nothing
36
+ * (no-op). Keeps worker call sites unconditional. */
37
+ meter?: Meter;
38
+ /** Low-cardinality remote-chain label attached to every recording. */
39
+ remoteChainId: Hex;
40
+ }
41
+ export interface BridgeFlowMetricsHandle {
42
+ /** Increments bridge_attempt_expirations_total for a non-terminal per-attempt failure
43
+ * (inbound: Stage 2's exp-block elapsed; outbound: BullMQ retry with attempts remaining). */
44
+ recordAttemptExpiration(opts: {
45
+ direction: BridgeDirection;
46
+ }): void;
47
+ /** Increments bridge_retried_total. Fired from the retry routes when a job actually
48
+ * moves from `failed` to `waiting` (never on dry-run, never on filter-mismatch /
49
+ * not-in-failed-state skips). */
50
+ recordRetried(opts: RecordBridgeRetryOptions): void;
51
+ recordSuccess(opts: RecordBridgeSuccessOptions): void;
52
+ /** Increments bridge_terminal_failures_total. Fired from the leaf worker's .on('failed')
53
+ * when `job.attemptsMade >= job.opts.attempts` (or one-shot attempts=1). */
54
+ recordTerminalFailure(opts: {
55
+ direction: BridgeDirection;
56
+ reason: BridgeFailureReason;
57
+ }): void;
58
+ }
59
+ /**
60
+ * Three metrics for successful bridge settlements, per direction (inbound = EVM→XL1,
61
+ * outbound = XL1→EVM):
62
+ *
63
+ * - `bridge_completed_total` — counter, labels (remoteChainId, direction).
64
+ * - `bridge_settle_latency_seconds` — histogram, same labels. Recorded only when the
65
+ * caller can supply a latency; the inbound path always can (canonical.observedAt and
66
+ * fulfilled.submittedAt are both wall-clock ms), the outbound path supplies what it
67
+ * can (currently EthTransactionMonitor's own wait time).
68
+ * - `bridge_fee_revenue_total` — counter, labels (remoteChainId, direction, token).
69
+ * `feeAmount` is in AttoXL1 (matching the protocol); operators converting to whole
70
+ * XL1 can divide by 10^18 in their PromQL.
71
+ *
72
+ * No-op when constructed without a meter: workers can call recordSuccess unconditionally
73
+ * even on actors that don't have OTel wired up.
74
+ */
75
+ export declare function createBridgeFlowMetrics(config: BridgeFlowMetricsConfig): BridgeFlowMetricsHandle;
76
+ //# sourceMappingURL=createBridgeFlowMetrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createBridgeFlowMetrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createBridgeFlowMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACU,KAAK,EAC1B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAEnE,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,UAAU,CAAA;AAEpD;;;;;GAKG;AACH,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,UAAU,CAAA;AAE5D,MAAM,WAAW,wBAAwB;IACvC;iCAC6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,kBAAkB,CAAA;CAC5B;AAED,MAAM,WAAW,0BAA0B;IACzC,SAAS,EAAE,eAAe,CAAA;IAC1B;gDAC4C;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB;;;qCAGiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;uDAEmD;IACnD,KAAK,EAAE,GAAG,CAAA;CACX;AAED,MAAM,WAAW,uBAAuB;IACtC;yDACqD;IACrD,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,sEAAsE;IACtE,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,uBAAuB;IACtC;iGAC6F;IAC7F,uBAAuB,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,eAAe,CAAA;KAAE,GAAG,IAAI,CAAA;IACnE;;qCAEiC;IACjC,aAAa,CAAC,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAA;IACnD,aAAa,CAAC,IAAI,EAAE,0BAA0B,GAAG,IAAI,CAAA;IACrD;gFAC4E;IAC5E,qBAAqB,CAAC,IAAI,EAAE;QAAE,SAAS,EAAE,eAAe,CAAC;QAAC,MAAM,EAAE,mBAAmB,CAAA;KAAE,GAAG,IAAI,CAAA;CAC/F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,uBAAuB,CA0EhG"}
@@ -0,0 +1,29 @@
1
+ import type { Meter } from '@opentelemetry/api';
2
+ import type { Hex } from '@xylabs/sdk-js';
3
+ import type { IterableMap } from '@xyo-network/xl1-sdk';
4
+ import type { BridgeFulfillmentState } from '../services/index.ts';
5
+ export interface InFlightPollerConfig {
6
+ bridgeFulfillmentMap: IterableMap<string, BridgeFulfillmentState>;
7
+ intervalMs?: number;
8
+ meter: Meter;
9
+ /** Same low-cardinality label used by the other bridge metrics so dashboards can join. */
10
+ remoteChainId: Hex;
11
+ }
12
+ export interface InFlightPollerHandle {
13
+ /** Run one poll and record the gauge. Exposed for tests and so callers can prime the
14
+ * gauge before the first interval tick. */
15
+ poll: () => Promise<void>;
16
+ start: () => void;
17
+ stop: () => void;
18
+ }
19
+ /**
20
+ * Periodically counts entries in `bridgeFulfillmentMap` that represent in-flight inbound
21
+ * (EVM→XL1) bridges — those where Stage 1 wrote `canonical` but Stage 2 has not yet
22
+ * transitioned to `fulfilled`. Records the count on
23
+ * `bridge_in_flight{remoteChainId, direction='inbound'}`.
24
+ *
25
+ * Outbound (XL1→EVM) has no equivalent durable state map today; the gauge stays inbound-only
26
+ * until a parallel store exists.
27
+ */
28
+ export declare function createInFlightPoller(config: InFlightPollerConfig): InFlightPollerHandle;
29
+ //# sourceMappingURL=createInFlightPoller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createInFlightPoller.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createInFlightPoller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAElE,MAAM,WAAW,oBAAoB;IACnC,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;IACjE,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ,0FAA0F;IAC1F,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC;+CAC2C;IAC3C,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IACzB,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAID;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAwCvF"}
@@ -1,4 +1,5 @@
1
1
  import type { Meter } from '@opentelemetry/api';
2
+ import type { Hex } from '@xylabs/sdk-js';
2
3
  import type { Queue } from 'bullmq';
3
4
  export interface QueueMetricsConfig {
4
5
  intervalMs?: number;
@@ -11,6 +12,9 @@ export interface QueueMetricsConfig {
11
12
  * shared XL1 queues collide on identical key names so spread-merge dedupes naturally.
12
13
  */
13
14
  queues: Record<string, Queue>;
15
+ /** Remote (EVM) chain id, attached as a low-cardinality `remoteChainId` label on every
16
+ * queue gauge so queries can scope to a single destination chain. */
17
+ remoteChainId: Hex;
14
18
  }
15
19
  export interface QueueMetricsHandle {
16
20
  start: () => void;
@@ -1 +1 @@
1
- {"version":3,"file":"createQueueMetrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createQueueMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAID,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CA6DjF"}
1
+ {"version":3,"file":"createQueueMetrics.d.ts","sourceRoot":"","sources":["../../../src/telemetry/createQueueMetrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAEnC,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,KAAK,CAAA;IACZ;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IAC7B;yEACqE;IACrE,aAAa,EAAE,GAAG,CAAA;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,IAAI,EAAE,MAAM,IAAI,CAAA;CACjB;AAID,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CA+DjF"}
@@ -1,3 +1,6 @@
1
+ export * from './bucketFailureReason.ts';
1
2
  export * from './createBalanceMonitor.ts';
3
+ export * from './createBridgeFlowMetrics.ts';
4
+ export * from './createInFlightPoller.ts';
2
5
  export * from './createQueueMetrics.ts';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,yBAAyB,CAAA"}