@xyo-network/chain-bridge 1.19.17 → 1.20.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 (146) hide show
  1. package/dist/node/config/getTestGateway.d.ts +4 -0
  2. package/dist/node/config/getTestGateway.d.ts.map +1 -0
  3. package/dist/node/config/index.d.ts +1 -1
  4. package/dist/node/config/index.d.ts.map +1 -1
  5. package/dist/node/index.mjs +767 -520
  6. package/dist/node/index.mjs.map +1 -1
  7. package/dist/node/modules/index.d.ts +0 -1
  8. package/dist/node/modules/index.d.ts.map +1 -1
  9. package/dist/node/queue/flowProducer.d.ts +2 -1
  10. package/dist/node/queue/flowProducer.d.ts.map +1 -1
  11. package/dist/node/queue/flows/createEthToXl1BridgeJob.d.ts +10 -0
  12. package/dist/node/queue/flows/createEthToXl1BridgeJob.d.ts.map +1 -0
  13. package/dist/node/queue/flows/createXl1ToEthBridgeJob.d.ts.map +1 -1
  14. package/dist/node/queue/flows/index.d.ts +1 -0
  15. package/dist/node/queue/flows/index.d.ts.map +1 -1
  16. package/dist/node/queue/getXl1ToEthQueueJobs.d.ts +20 -0
  17. package/dist/node/queue/getXl1ToEthQueueJobs.d.ts.map +1 -0
  18. package/dist/node/queue/getXl1ToEthQueues.d.ts +14 -0
  19. package/dist/node/queue/getXl1ToEthQueues.d.ts.map +1 -0
  20. package/dist/node/queue/index.d.ts +4 -0
  21. package/dist/node/queue/index.d.ts.map +1 -1
  22. package/dist/node/queue/prefix.d.ts +2 -0
  23. package/dist/node/queue/prefix.d.ts.map +1 -0
  24. package/dist/node/queue/telemetry.d.ts +3 -0
  25. package/dist/node/queue/telemetry.d.ts.map +1 -0
  26. package/dist/node/queue/workers/EthToXl1BridgeParent.d.ts +8 -0
  27. package/dist/node/queue/workers/EthToXl1BridgeParent.d.ts.map +1 -0
  28. package/dist/node/queue/workers/EthTransactionMonitor.d.ts +11 -0
  29. package/dist/node/queue/workers/EthTransactionMonitor.d.ts.map +1 -1
  30. package/dist/node/queue/workers/EthTransactionPreparation.d.ts +9 -1
  31. package/dist/node/queue/workers/EthTransactionPreparation.d.ts.map +1 -1
  32. package/dist/node/queue/workers/EthTransactionSubmission.d.ts +10 -0
  33. package/dist/node/queue/workers/EthTransactionSubmission.d.ts.map +1 -1
  34. package/dist/node/queue/workers/EthTransactionSubmissionStorage.d.ts +13 -0
  35. package/dist/node/queue/workers/EthTransactionSubmissionStorage.d.ts.map +1 -0
  36. package/dist/node/queue/workers/WorkerDescription.d.ts +2 -1
  37. package/dist/node/queue/workers/WorkerDescription.d.ts.map +1 -1
  38. package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts +8 -0
  39. package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts.map +1 -1
  40. package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts +10 -0
  41. package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts.map +1 -1
  42. package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts +9 -0
  43. package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts.map +1 -1
  44. package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts +10 -0
  45. package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts.map +1 -1
  46. package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.d.ts +13 -0
  47. package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.d.ts.map +1 -0
  48. package/dist/node/queue/workers/createWorkers.d.ts +2 -1
  49. package/dist/node/queue/workers/createWorkers.d.ts.map +1 -1
  50. package/dist/node/queue/workers/index.d.ts +3 -0
  51. package/dist/node/queue/workers/index.d.ts.map +1 -1
  52. package/dist/node/queue/workers/util/index.d.ts +0 -2
  53. package/dist/node/queue/workers/util/index.d.ts.map +1 -1
  54. package/dist/node/server/addFlowProducer.d.ts.map +1 -1
  55. package/dist/node/server/addWorkers.d.ts.map +1 -1
  56. package/dist/node/server/index.d.ts +2 -0
  57. package/dist/node/server/index.d.ts.map +1 -1
  58. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.d.ts.map +1 -1
  59. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts +1 -1
  60. package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts.map +1 -1
  61. package/dist/node/server/server.d.ts.map +1 -1
  62. package/dist/node/services/IBridgeServiceCollection.d.ts +1 -1
  63. package/dist/node/services/IBridgeServiceCollection.d.ts.map +1 -1
  64. package/dist/node/services/TxState.d.ts +0 -7
  65. package/dist/node/services/TxState.d.ts.map +1 -1
  66. package/dist/node/util/index.d.ts +0 -3
  67. package/dist/node/util/index.d.ts.map +1 -1
  68. package/dist/node/validation/AsyncLogger.d.ts +5 -0
  69. package/dist/node/validation/AsyncLogger.d.ts.map +1 -0
  70. package/dist/node/validation/index.d.ts +7 -0
  71. package/dist/node/validation/index.d.ts.map +1 -0
  72. package/dist/node/validation/validateBridgeEstimate.d.ts.map +1 -0
  73. package/dist/node/validation/validateBridgeEstimateExact.d.ts.map +1 -0
  74. package/dist/node/validation/validateBridgeTransaction.d.ts.map +1 -0
  75. package/dist/node/{queue/workers/util/validateSufficientAllowance.d.ts → validation/validateSufficientLiquiditySourceAllowance.d.ts} +3 -7
  76. package/dist/node/validation/validateSufficientLiquiditySourceAllowance.d.ts.map +1 -0
  77. package/dist/node/{queue/workers/util/validateSufficientBalance.d.ts → validation/validateSufficientLiquiditySourceBalance.d.ts} +3 -7
  78. package/dist/node/validation/validateSufficientLiquiditySourceBalance.d.ts.map +1 -0
  79. package/dist/node/validation/validateSufficientRunnerEthBalanceForGas.d.ts +14 -0
  80. package/dist/node/validation/validateSufficientRunnerEthBalanceForGas.d.ts.map +1 -0
  81. package/dist/node/validation/validateSufficientXL1SourceAddressBalance.d.ts +15 -0
  82. package/dist/node/validation/validateSufficientXL1SourceAddressBalance.d.ts.map +1 -0
  83. package/package.json +31 -35
  84. package/src/config/getBridgeWalletAccount.ts +1 -1
  85. package/src/config/getTestGateway.ts +24 -0
  86. package/src/config/index.ts +1 -1
  87. package/src/modules/index.ts +0 -1
  88. package/src/queue/flowProducer.ts +7 -2
  89. package/src/queue/flows/createEthToXl1BridgeJob.ts +71 -0
  90. package/src/queue/flows/createXl1ToEthBridgeJob.ts +48 -20
  91. package/src/queue/flows/index.ts +1 -0
  92. package/src/queue/getXl1ToEthQueueJobs.ts +57 -0
  93. package/src/queue/getXl1ToEthQueues.ts +39 -0
  94. package/src/queue/index.ts +4 -0
  95. package/src/queue/prefix.ts +1 -0
  96. package/src/queue/telemetry.ts +12 -0
  97. package/src/queue/workers/EthToXl1BridgeParent.ts +40 -0
  98. package/src/queue/workers/EthTransactionMonitor.ts +14 -6
  99. package/src/queue/workers/EthTransactionPreparation.ts +21 -9
  100. package/src/queue/workers/EthTransactionSubmission.ts +10 -38
  101. package/src/queue/workers/EthTransactionSubmissionStorage.ts +76 -0
  102. package/src/queue/workers/WorkerDescription.ts +2 -1
  103. package/src/queue/workers/Xl1ToEthBridgeParent.ts +13 -5
  104. package/src/queue/workers/Xl1TransactionMonitor.ts +18 -12
  105. package/src/queue/workers/Xl1TransactionPreparation.ts +11 -7
  106. package/src/queue/workers/Xl1TransactionSubmission.ts +12 -12
  107. package/src/queue/workers/Xl1TransactionSubmissionStorage.ts +77 -0
  108. package/src/queue/workers/createWorkers.ts +15 -8
  109. package/src/queue/workers/index.ts +3 -0
  110. package/src/queue/workers/util/index.ts +0 -2
  111. package/src/server/addFlowProducer.ts +5 -2
  112. package/src/server/addWorkers.ts +6 -2
  113. package/src/server/index.ts +3 -2
  114. package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.ts +11 -1
  115. package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.ts +27 -101
  116. package/src/server/server.ts +1 -0
  117. package/src/services/IBridgeServiceCollection.ts +1 -1
  118. package/src/services/TxState.ts +0 -18
  119. package/src/services/getServices.ts +1 -1
  120. package/src/util/index.ts +0 -3
  121. package/src/validation/AsyncLogger.ts +5 -0
  122. package/src/validation/index.ts +6 -0
  123. package/src/{util → validation}/validateBridgeEstimate.ts +1 -1
  124. package/src/{util → validation}/validateBridgeEstimateExact.ts +1 -1
  125. package/src/{util → validation}/validateBridgeTransaction.ts +1 -2
  126. package/src/{queue/workers/util/validateSufficientAllowance.ts → validation/validateSufficientLiquiditySourceAllowance.ts} +3 -6
  127. package/src/{queue/workers/util/validateSufficientBalance.ts → validation/validateSufficientLiquiditySourceBalance.ts} +3 -6
  128. package/src/validation/validateSufficientRunnerEthBalanceForGas.ts +57 -0
  129. package/src/validation/validateSufficientXL1SourceAddressBalance.ts +39 -0
  130. package/dist/node/config/getGateway.d.ts +0 -4
  131. package/dist/node/config/getGateway.d.ts.map +0 -1
  132. package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.d.ts +0 -60
  133. package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.d.ts.map +0 -1
  134. package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/index.d.ts +0 -2
  135. package/dist/node/modules/XL1TransactionCompletionMonitorSentinel/index.d.ts.map +0 -1
  136. package/dist/node/queue/workers/util/validateSufficientAllowance.d.ts.map +0 -1
  137. package/dist/node/queue/workers/util/validateSufficientBalance.d.ts.map +0 -1
  138. package/dist/node/util/validateBridgeEstimate.d.ts.map +0 -1
  139. package/dist/node/util/validateBridgeEstimateExact.d.ts.map +0 -1
  140. package/dist/node/util/validateBridgeTransaction.d.ts.map +0 -1
  141. package/src/config/getGateway.ts +0 -23
  142. package/src/modules/XL1TransactionCompletionMonitorSentinel/XL1TransactionCompletionMonitorSentinel.ts +0 -165
  143. package/src/modules/XL1TransactionCompletionMonitorSentinel/index.ts +0 -1
  144. /package/dist/node/{util → validation}/validateBridgeEstimate.d.ts +0 -0
  145. /package/dist/node/{util → validation}/validateBridgeEstimateExact.d.ts +0 -0
  146. /package/dist/node/{util → validation}/validateBridgeTransaction.d.ts +0 -0
@@ -1,9 +1,6 @@
1
- import type { Promisable } from '@xylabs/sdk-js';
2
1
  import type { BridgeableToken, LiquidityPoolBridge } from '@xyo-network/typechain';
3
2
  import { type SignedHydratedTransaction } from '@xyo-network/xl1-sdk';
4
- interface IAsyncLogger {
5
- log: (message: string) => Promisable<unknown>;
6
- }
3
+ import type { AsyncLogger } from './AsyncLogger.ts';
7
4
  /**
8
5
  * Checks if the liquidity source has sufficient balance for the bridge to execute the transaction. This doesn't
9
6
  * ensure that (due to race conditions) the transaction will succeed, but is a quick check to avoid
@@ -14,6 +11,5 @@ interface IAsyncLogger {
14
11
  * @param logger Optional logger for asynchronous logging
15
12
  * @returns True if the liquidity source balance is sufficient to execute the bridge
16
13
  */
17
- export declare const validateSufficientBalance: (tx: SignedHydratedTransaction, bridgeableToken: BridgeableToken, bridge: LiquidityPoolBridge, logger?: IAsyncLogger) => Promise<boolean>;
18
- export {};
19
- //# sourceMappingURL=validateSufficientBalance.d.ts.map
14
+ export declare const validateSufficientLiquiditySourceBalance: (tx: SignedHydratedTransaction, bridgeableToken: BridgeableToken, bridge: LiquidityPoolBridge, logger?: AsyncLogger) => Promise<boolean>;
15
+ //# sourceMappingURL=validateSufficientLiquiditySourceBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateSufficientLiquiditySourceBalance.d.ts","sourceRoot":"","sources":["../../../src/validation/validateSufficientLiquiditySourceBalance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAClF,OAAO,EAAkB,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AAErF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,wCAAwC,GACnD,IAAI,yBAAyB,EAC7B,iBAAiB,eAAe,EAChC,QAAQ,mBAAmB,EAC3B,SAAS,WAAW,qBAarB,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { ContractTransaction, Wallet } from 'ethers';
2
+ import type { AsyncLogger } from './AsyncLogger.ts';
3
+ /**
4
+ * Validates that the wallet (the account that will submit the tx) has enough ETH
5
+ * to cover the estimated gas cost (plus a buffer) for the transaction.
6
+ * @param preparedTx The transaction that is being prepared for submission.
7
+ * This should be a fully populated transaction (to/from/data/value) except for gas fields.
8
+ * @param wallet The wallet that will be used to submit the transaction.
9
+ * @param logger Optional logger for asynchronous logging.
10
+ * @param bufferBps The buffer to apply to the estimated gas cost, in basis points (1/100th of a percent).
11
+ * @returns A boolean indicating whether the wallet has sufficient ETH to cover the estimated gas cost with the buffer applied.
12
+ */
13
+ export declare const validateSufficientRunnerEthBalanceForGas: (preparedTx: ContractTransaction, wallet: Wallet, logger?: AsyncLogger, bufferBps?: bigint) => Promise<boolean>;
14
+ //# sourceMappingURL=validateSufficientRunnerEthBalanceForGas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateSufficientRunnerEthBalanceForGas.d.ts","sourceRoot":"","sources":["../../../src/validation/validateSufficientRunnerEthBalanceForGas.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAInD;;;;;;;;;GASG;AACH,eAAO,MAAM,wCAAwC,GACnD,YAAY,mBAAmB,EAC/B,QAAQ,MAAM,EACd,SAAS,WAAW,EACpB,YAAW,MAA+B,qBAmC3C,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { BridgeConfig } from '@xyo-network/chain-orchestration';
2
+ import type { BridgeIntent, XyoGatewayRunner } from '@xyo-network/xl1-sdk';
3
+ import type { AsyncLogger } from './AsyncLogger.ts';
4
+ /**
5
+ * Checks if the liquidity source has sufficient balance for the bridge to execute the transaction. This doesn't
6
+ * ensure that (due to race conditions) the transaction will succeed, but is a quick check to avoid
7
+ * submitting transactions that are likely to fail.
8
+ * @param bridgeIntent The bridge intent containing the details of the bridge transaction, including the source address and amount being bridged
9
+ * @param gateway The XyoGatewayRunner to check the balance of the source address on XL1
10
+ * @param config The bridge configuration, used to generate a bridge estimate for the transaction
11
+ * @param logger Optional logger for asynchronous logging
12
+ * @returns True if the liquidity source balance is sufficient to execute the bridge
13
+ */
14
+ export declare const validateSufficientXL1SourceAddressBalance: (bridgeIntent: BridgeIntent, gateway: XyoGatewayRunner, config: BridgeConfig, logger?: AsyncLogger) => Promise<boolean>;
15
+ //# sourceMappingURL=validateSufficientXL1SourceAddressBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validateSufficientXL1SourceAddressBalance.d.ts","sourceRoot":"","sources":["../../../src/validation/validateSufficientXL1SourceAddressBalance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEnD;;;;;;;;;GASG;AACH,eAAO,MAAM,yCAAyC,GACpD,cAAc,YAAY,EAC1B,SAAS,gBAAgB,EACzB,QAAQ,YAAY,EACpB,SAAS,WAAW,qBAerB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/chain-bridge",
3
- "version": "1.19.17",
3
+ "version": "1.20.0",
4
4
  "description": "XYO Layer One Bridge",
5
5
  "homepage": "https://xylabs.com",
6
6
  "bugs": {
@@ -49,25 +49,25 @@
49
49
  "types": "tsc --noEmit -p tsconfig.test.json"
50
50
  },
51
51
  "dependencies": {
52
- "@opentelemetry/instrumentation": "~0.212.0",
52
+ "@opentelemetry/instrumentation": "~0.213.0",
53
53
  "@opentelemetry/instrumentation-express": "~0.60.0",
54
- "@opentelemetry/instrumentation-http": "~0.212.0",
54
+ "@opentelemetry/instrumentation-http": "~0.213.0",
55
55
  "@xylabs/express": "~5.0.80",
56
56
  "@xylabs/mongo": "~5.0.80",
57
57
  "@xylabs/sdk-js": "~5.0.80",
58
- "@xyo-network/boundwitness-validator": "~5.3.8",
59
- "@xyo-network/chain-orchestration": "~1.19.17",
60
- "@xyo-network/chain-protocol": "~1.19.17",
61
- "@xyo-network/chain-services": "~1.19.17",
62
- "@xyo-network/sdk-js": "~5.3.8",
63
- "@xyo-network/sentinel-abstract": "~5.3.8",
64
- "@xyo-network/sentinel-model": "~5.3.8",
65
- "@xyo-network/typechain": "~4.1.1",
66
- "@xyo-network/wallet": "~5.3.8",
67
- "@xyo-network/wallet-model": "~5.3.8",
68
- "@xyo-network/xl1-sdk": "~1.24.27",
58
+ "@xyo-network/boundwitness-validator": "~5.3.15",
59
+ "@xyo-network/chain-orchestration": "~1.20.0",
60
+ "@xyo-network/chain-protocol": "~1.20.0",
61
+ "@xyo-network/chain-services": "~1.20.0",
62
+ "@xyo-network/sdk-js": "~5.3.15",
63
+ "@xyo-network/sentinel-abstract": "~5.3.15",
64
+ "@xyo-network/sentinel-model": "~5.3.15",
65
+ "@xyo-network/typechain": "~4.1.2",
66
+ "@xyo-network/wallet-model": "~5.3.15",
67
+ "@xyo-network/xl1-sdk": "~1.25.14",
69
68
  "async-mutex": "~0.5.0",
70
69
  "bullmq": "~5.70.1",
70
+ "bullmq-otel": "~1.3.0",
71
71
  "compression": "~1.8.1",
72
72
  "cors": "~2.8.6",
73
73
  "ethers": "^6.16.0",
@@ -82,35 +82,31 @@
82
82
  "@types/cors": "~2.8.19",
83
83
  "@types/express": "5.0.6",
84
84
  "@types/express-serve-static-core": "~5.1.1",
85
- "@types/node": "~25.3.0",
86
- "@xylabs/axios": "~5.0.80",
85
+ "@types/node": "~25.3.3",
87
86
  "@xylabs/mongo": "~5.0.80",
88
87
  "@xylabs/sdk-js": "~5.0.80",
89
88
  "@xylabs/ts-scripts-yarn3": "~7.3.2",
90
89
  "@xylabs/tsconfig": "~7.3.2",
91
90
  "@xylabs/vitest-extended": "~5.0.80",
92
- "@xyo-network/account": "~5.3.8",
93
- "@xyo-network/account-model": "~5.3.8",
94
- "@xyo-network/archivist-abstract": "~5.3.8",
95
- "@xyo-network/archivist-memory": "~5.3.8",
96
- "@xyo-network/archivist-mongodb": "~5.3.8",
97
- "@xyo-network/archivist-view": "~5.3.8",
91
+ "@xyo-network/account": "~5.3.15",
92
+ "@xyo-network/account-model": "~5.3.15",
93
+ "@xyo-network/archivist-abstract": "~5.3.15",
94
+ "@xyo-network/archivist-mongodb": "~5.3.15",
95
+ "@xyo-network/archivist-view": "~5.3.15",
98
96
  "@xyo-network/bios": "~7.2.1",
99
97
  "@xyo-network/bios-model": "~7.2.1",
100
- "@xyo-network/boundwitness-builder": "~5.3.8",
101
- "@xyo-network/chain-protocol": "~1.19.17",
102
- "@xyo-network/chain-services": "~1.19.17",
103
- "@xyo-network/chain-telemetry": "~1.19.17",
104
- "@xyo-network/manifest-wrapper": "~5.3.8",
105
- "@xyo-network/module-abstract": "~5.3.8",
106
- "@xyo-network/module-abstract-mongodb": "~5.3.8",
107
- "@xyo-network/node-memory": "~5.3.8",
108
- "@xyo-network/sdk-js": "~5.3.8",
109
- "@xyo-network/sentinel-memory": "~5.3.8",
110
- "@xyo-network/wallet": "~5.3.8",
111
- "@xyo-network/xl1-sdk": "~1.24.27",
98
+ "@xyo-network/boundwitness-builder": "~5.3.15",
99
+ "@xyo-network/chain-protocol": "~1.20.0",
100
+ "@xyo-network/chain-services": "~1.20.0",
101
+ "@xyo-network/chain-telemetry": "~1.20.0",
102
+ "@xyo-network/module-abstract": "~5.3.15",
103
+ "@xyo-network/module-abstract-mongodb": "~5.3.15",
104
+ "@xyo-network/node-memory": "~5.3.15",
105
+ "@xyo-network/sdk-js": "~5.3.15",
106
+ "@xyo-network/sentinel-memory": "~5.3.15",
107
+ "@xyo-network/xl1-sdk": "~1.25.14",
112
108
  "async-mutex": "~0.5.0",
113
- "axios": "~1.13.5",
109
+ "axios": "~1.13.6",
114
110
  "dotenv": "~17.3.1",
115
111
  "eslint": "^9.39.3",
116
112
  "ethers": "^6.16.0",
@@ -1,6 +1,6 @@
1
1
  import type { Address, Promisable } from '@xylabs/sdk-js'
2
2
  import { isDefined, isUndefined } from '@xylabs/sdk-js'
3
- import { HDWallet } from '@xyo-network/wallet'
3
+ import { HDWallet } from '@xyo-network/sdk-js'
4
4
  import type { WalletInstance } from '@xyo-network/wallet-model'
5
5
  import type { ActorConfig } from '@xyo-network/xl1-sdk'
6
6
  import { ADDRESS_INDEX, generateXyoBaseWalletFromPhrase } from '@xyo-network/xl1-sdk'
@@ -0,0 +1,24 @@
1
+ import { assertEx, isDefined } from '@xylabs/sdk-js'
2
+ import { basicRemoteRunnerLocator, type BridgeConfig } from '@xyo-network/chain-orchestration'
3
+ import { HDWallet } from '@xyo-network/sdk-js'
4
+ import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk'
5
+ import {
6
+ ADDRESS_INDEX, generateXyoBaseWalletFromPhrase, HttpRpcRemoteConfigZod, XyoGatewayRunnerMoniker,
7
+ } from '@xyo-network/xl1-sdk'
8
+
9
+ let gatewayInstance: XyoGatewayRunner | undefined
10
+
11
+ export const getTestGateway = async (config: BridgeConfig): Promise<XyoGatewayRunner> => {
12
+ if (isDefined(gatewayInstance)) return gatewayInstance
13
+ const { mnemonic } = config
14
+ const httpRpcConfig = HttpRpcRemoteConfigZod.safeParse(config.remote?.rpc)
15
+ const endpoint = assertEx(
16
+ httpRpcConfig.success ? assertEx(httpRpcConfig.data.url, () => 'RPC URL is required for gateway [no httpConfig]') : undefined,
17
+ () => 'RPC URL is required for gateway',
18
+ )
19
+ const walletPhrase = isDefined(mnemonic) ? mnemonic : HDWallet.generateMnemonic()
20
+ const wallet = await generateXyoBaseWalletFromPhrase(walletPhrase)
21
+ const signerAccount = await wallet.derivePath(ADDRESS_INDEX.XYO)
22
+ const locator = await basicRemoteRunnerLocator('test', { rpc: { protocol: 'http', url: endpoint } }, signerAccount)
23
+ return await locator.getInstance<XyoGatewayRunner>(XyoGatewayRunnerMoniker)
24
+ }
@@ -5,11 +5,11 @@ export * from './getBridgeFeesAddress.ts'
5
5
  export * from './getBridgeSettings.ts'
6
6
  export * from './getBridgeWalletAccount.ts'
7
7
  export * from './getFeeStructure.ts'
8
- export * from './getGateway.ts'
9
8
  export * from './getMaxBridgeAmount.ts'
10
9
  export * from './getMinBridgeAmount.ts'
11
10
  export * from './getRemoteChainId.ts'
12
11
  export * from './getRemoteTokenAddress.ts'
12
+ export * from './getTestGateway.ts'
13
13
  export * from './getTransferAddresses.ts'
14
14
  export * from './getXl1ChainId.ts'
15
15
  export * from './getXl1TokenAddress.ts'
@@ -1,2 +1 @@
1
1
  export * from './EVMLiquidityBridgeTransactionCompletionMonitorSentinel/index.ts'
2
- export * from './XL1TransactionCompletionMonitorSentinel/index.ts'
@@ -1,11 +1,16 @@
1
1
  import { isDefined } from '@xylabs/sdk-js'
2
2
  import { FlowProducer } from 'bullmq'
3
+ import type { BullMQOtel } from 'bullmq-otel'
3
4
  import type { Redis } from 'ioredis'
4
5
 
6
+ import { prefix } from './prefix.ts'
7
+
5
8
  let flowProducer: FlowProducer | undefined
6
9
 
7
- export const getFlowProducer = (connection: Redis) => {
10
+ export const getFlowProducer = (connection: Redis, telemetry?: BullMQOtel) => {
8
11
  if (isDefined(flowProducer)) return flowProducer
9
- flowProducer = new FlowProducer({ connection })
12
+ flowProducer = new FlowProducer({
13
+ connection, telemetry, prefix,
14
+ })
10
15
  return flowProducer
11
16
  }
@@ -0,0 +1,71 @@
1
+ import { PayloadBuilder } from '@xyo-network/sdk-js'
2
+ import type { SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
3
+ import type { FlowProducer } from 'bullmq'
4
+
5
+ import {
6
+ EthToXl1BridgeParent, Xl1TransactionMonitor, Xl1TransactionPreparation, Xl1TransactionSubmission,
7
+ Xl1TransactionSubmissionStorage,
8
+ } from '../workers/index.ts'
9
+
10
+ /**
11
+ * Creates a job flow for bridging a transaction from Ethereum to XL1.
12
+ * @param flowProducer The flow producer to run the job
13
+ * @param tx The bridge transaction
14
+ * @returns The JobNode representing the ETH to XL1 bridge job
15
+ */
16
+ export const createEthToXl1BridgeJob = async (
17
+ flowProducer: FlowProducer,
18
+ tx: SignedHydratedTransaction,
19
+ ) => {
20
+ const jobId = await PayloadBuilder.hash(tx[0])
21
+ const flow = await flowProducer.add({
22
+ // Step 0 (runs first as parent job)
23
+ name: EthToXl1BridgeParent.name,
24
+ queueName: EthToXl1BridgeParent.queueName,
25
+ data: { tx },
26
+ opts: { jobId },
27
+ children: [
28
+ {
29
+ // Step 4
30
+ name: Xl1TransactionMonitor.name,
31
+ queueName: Xl1TransactionMonitor.queueName,
32
+ data: { tx },
33
+ opts: {
34
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
35
+ },
36
+ children: [
37
+ {
38
+ // Step 3
39
+ name: Xl1TransactionSubmissionStorage.name,
40
+ queueName: Xl1TransactionSubmissionStorage.queueName,
41
+ data: { tx },
42
+ opts: {
43
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
44
+ },
45
+ children: [
46
+ {
47
+ // Step 2
48
+ name: Xl1TransactionSubmission.name,
49
+ queueName: Xl1TransactionSubmission.queueName,
50
+ data: { tx },
51
+ opts: { jobId },
52
+ children: [
53
+ {
54
+ // Step 1 (runs first as deepest child)
55
+ name: Xl1TransactionPreparation.name,
56
+ queueName: Xl1TransactionPreparation.queueName,
57
+ data: { tx },
58
+ opts: {
59
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
60
+ },
61
+ },
62
+ ],
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ },
68
+ ],
69
+ })
70
+ return flow
71
+ }
@@ -3,8 +3,8 @@ import type { SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
3
3
  import type { FlowProducer } from 'bullmq'
4
4
 
5
5
  import {
6
- EthTransactionMonitor, EthTransactionPreparation, EthTransactionSubmission, Xl1ToEthBridgeParent, Xl1TransactionMonitor, Xl1TransactionPreparation,
7
- Xl1TransactionSubmission,
6
+ EthTransactionMonitor, EthTransactionPreparation, EthTransactionSubmission, EthTransactionSubmissionStorage, Xl1ToEthBridgeParent, Xl1TransactionMonitor,
7
+ Xl1TransactionPreparation, Xl1TransactionSubmission, Xl1TransactionSubmissionStorage,
8
8
  } from '../workers/index.ts'
9
9
 
10
10
  /**
@@ -19,13 +19,14 @@ export const createXl1ToEthBridgeJob = async (
19
19
  ) => {
20
20
  const jobId = await PayloadBuilder.hash(tx[0])
21
21
  const flow = await flowProducer.add({
22
+ // Step 0 (runs first as parent job)
22
23
  name: Xl1ToEthBridgeParent.name,
23
24
  queueName: Xl1ToEthBridgeParent.queueName,
24
25
  data: { tx },
25
26
  opts: { jobId },
26
27
  children: [
27
28
  {
28
- // Step 6 (runs after child completes)
29
+ // Step 8
29
30
  name: EthTransactionMonitor.name,
30
31
  queueName: EthTransactionMonitor.queueName,
31
32
  data: { tx },
@@ -34,40 +35,67 @@ export const createXl1ToEthBridgeJob = async (
34
35
  },
35
36
  children: [
36
37
  {
37
- // Step 5
38
- name: EthTransactionSubmission.name,
39
- queueName: EthTransactionSubmission.queueName,
38
+ // Step 7
39
+ name: EthTransactionSubmissionStorage.name,
40
+ queueName: EthTransactionSubmissionStorage.queueName,
40
41
  data: { tx },
42
+ opts: {
43
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
44
+ },
41
45
  children: [
42
46
  {
43
- // Step 4
44
- name: EthTransactionPreparation.name,
45
- queueName: EthTransactionPreparation.queueName,
47
+ // Step 6
48
+ name: EthTransactionSubmission.name,
49
+ queueName: EthTransactionSubmission.queueName,
46
50
  data: { tx },
47
51
  opts: { jobId },
48
52
  children: [
49
53
  {
50
- // Step 3
51
- name: Xl1TransactionMonitor.name,
52
- queueName: Xl1TransactionMonitor.queueName,
54
+ // Step 5
55
+ name: EthTransactionPreparation.name,
56
+ queueName: EthTransactionPreparation.queueName,
53
57
  data: { tx },
54
58
  opts: {
55
59
  jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
56
60
  },
57
61
  children: [
58
62
  {
59
- // Step 2
60
- name: Xl1TransactionSubmission.name,
61
- queueName: Xl1TransactionSubmission.queueName,
63
+ // Step 4
64
+ name: Xl1TransactionMonitor.name,
65
+ queueName: Xl1TransactionMonitor.queueName,
62
66
  data: { tx },
63
- opts: { jobId },
67
+ opts: {
68
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
69
+ },
64
70
  children: [
65
71
  {
66
- // Step 1 (runs first as deepest child)
67
- name: Xl1TransactionPreparation.name,
68
- queueName: Xl1TransactionPreparation.queueName,
72
+ // Step 3
73
+ name: Xl1TransactionSubmissionStorage.name,
74
+ queueName: Xl1TransactionSubmissionStorage.queueName,
69
75
  data: { tx },
70
- opts: { jobId },
76
+ opts: {
77
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
78
+ },
79
+ children: [
80
+ {
81
+ // Step 2
82
+ name: Xl1TransactionSubmission.name,
83
+ queueName: Xl1TransactionSubmission.queueName,
84
+ data: { tx },
85
+ opts: { jobId },
86
+ children: [
87
+ {
88
+ // Step 1 (runs first as deepest child)
89
+ name: Xl1TransactionPreparation.name,
90
+ queueName: Xl1TransactionPreparation.queueName,
91
+ data: { tx },
92
+ opts: {
93
+ jobId, attempts: 60, backoff: { type: 'fixed', delay: 5000 },
94
+ },
95
+ },
96
+ ],
97
+ },
98
+ ],
71
99
  },
72
100
  ],
73
101
  },
@@ -1 +1,2 @@
1
+ export * from './createEthToXl1BridgeJob.ts'
1
2
  export * from './createXl1ToEthBridgeJob.ts'
@@ -0,0 +1,57 @@
1
+ import type { Xl1ToEthQueues } from './getXl1ToEthQueues.ts'
2
+ import type {
3
+ EthTransactionMonitorJob, EthTransactionPreparationJob,
4
+ EthTransactionSubmissionJob,
5
+ Xl1ToEthBridgeParentJob,
6
+ Xl1TransactionMonitorJob, Xl1TransactionPreparationJob, Xl1TransactionSubmissionJob,
7
+ Xl1TransactionSubmissionStorageJob,
8
+ } from './workers/index.ts'
9
+
10
+ export interface StatusQueueJobs {
11
+ ethTransactionMonitorJob?: EthTransactionMonitorJob
12
+ ethTransactionPreparationJob?: EthTransactionPreparationJob
13
+ ethTransactionSubmissionJob?: EthTransactionSubmissionJob
14
+ xl1ToEthBridgeParentJob?: Xl1ToEthBridgeParentJob
15
+ xl1TransactionMonitorJob?: Xl1TransactionMonitorJob
16
+ xl1TransactionPreparationJob?: Xl1TransactionPreparationJob
17
+ xl1TransactionSubmissionJob?: Xl1TransactionSubmissionJob
18
+ xl1TransactionSubmissionStorageJob?: Xl1TransactionSubmissionStorageJob
19
+ }
20
+
21
+ /**
22
+ * Checks all the relevant status queues for a job with the given id and returns the jobs found in an object
23
+ * @param queues The status queues to check for jobs
24
+ * @param jobId The job id to look for in the queues, which is the same as the tx hash of the bridge transaction
25
+ * @returns An object containing the jobs found in the status queues corresponding to the given job id
26
+ */
27
+ export const getStatusQueueJobs = async (queues: Xl1ToEthQueues, jobId: string): Promise<StatusQueueJobs> => {
28
+ const [
29
+ ethTransactionMonitorJob,
30
+ ethTransactionPreparationJob,
31
+ ethTransactionSubmissionJob,
32
+ xl1ToEthBridgeParentJob,
33
+ xl1TransactionMonitorJob,
34
+ xl1TransactionPreparationJob,
35
+ xl1TransactionSubmissionJob,
36
+ xl1TransactionSubmissionStorageJob,
37
+ ] = await Promise.all([
38
+ queues.ethTransactionMonitor.getJob(jobId),
39
+ queues.ethTransactionPreparation.getJob(jobId),
40
+ queues.ethTransactionSubmission.getJob(jobId),
41
+ queues.xl1ToEthBridgeParent.getJob(jobId),
42
+ queues.xl1TransactionMonitor.getJob(jobId),
43
+ queues.xl1TransactionPreparation.getJob(jobId),
44
+ queues.xl1TransactionSubmission.getJob(jobId),
45
+ queues.xl1TransactionSubmissionStorage.getJob(jobId),
46
+ ])
47
+ return {
48
+ ethTransactionMonitorJob,
49
+ ethTransactionPreparationJob,
50
+ ethTransactionSubmissionJob,
51
+ xl1ToEthBridgeParentJob,
52
+ xl1TransactionMonitorJob,
53
+ xl1TransactionPreparationJob,
54
+ xl1TransactionSubmissionStorageJob,
55
+ xl1TransactionSubmissionJob,
56
+ }
57
+ }
@@ -0,0 +1,39 @@
1
+ import type { BridgeConfig } from '@xyo-network/chain-orchestration'
2
+ import { Queue } from 'bullmq'
3
+
4
+ import { getConnection } from './connection.ts'
5
+ import { prefix } from './prefix.ts'
6
+ import {
7
+ EthTransactionMonitor, EthTransactionPreparation, EthTransactionSubmission, Xl1ToEthBridgeParent, Xl1TransactionMonitor, Xl1TransactionPreparation,
8
+ Xl1TransactionSubmission,
9
+ Xl1TransactionSubmissionStorage,
10
+ } from './workers/index.ts'
11
+
12
+ export interface Xl1ToEthQueues {
13
+ ethTransactionMonitor: Queue
14
+ ethTransactionPreparation: Queue
15
+ ethTransactionSubmission: Queue
16
+ xl1ToEthBridgeParent: Queue
17
+ xl1TransactionMonitor: Queue
18
+ xl1TransactionPreparation: Queue
19
+ xl1TransactionSubmission: Queue
20
+ xl1TransactionSubmissionStorage: Queue
21
+ }
22
+
23
+ let xl1ToEthQueues: Xl1ToEthQueues | undefined
24
+
25
+ export const getXl1ToEthQueues = (config: BridgeConfig): Xl1ToEthQueues => {
26
+ if (xl1ToEthQueues) return xl1ToEthQueues
27
+ const connection = getConnection(config)
28
+ xl1ToEthQueues = {
29
+ ethTransactionMonitor: new Queue(EthTransactionMonitor.queueName, { connection, prefix }),
30
+ ethTransactionPreparation: new Queue(EthTransactionPreparation.queueName, { connection, prefix }),
31
+ ethTransactionSubmission: new Queue(EthTransactionSubmission.queueName, { connection, prefix }),
32
+ xl1ToEthBridgeParent: new Queue(Xl1ToEthBridgeParent.queueName, { connection, prefix }),
33
+ xl1TransactionMonitor: new Queue(Xl1TransactionMonitor.queueName, { connection, prefix }),
34
+ xl1TransactionPreparation: new Queue(Xl1TransactionPreparation.queueName, { connection, prefix }),
35
+ xl1TransactionSubmission: new Queue(Xl1TransactionSubmission.queueName, { connection, prefix }),
36
+ xl1TransactionSubmissionStorage: new Queue(Xl1TransactionSubmissionStorage.queueName, { connection, prefix }),
37
+ }
38
+ return xl1ToEthQueues
39
+ }
@@ -1,4 +1,8 @@
1
1
  export * from './connection.ts'
2
2
  export * from './flowProducer.ts'
3
3
  export * from './flows/index.ts'
4
+ export * from './getXl1ToEthQueueJobs.ts'
5
+ export * from './getXl1ToEthQueues.ts'
6
+ export * from './prefix.ts'
7
+ export * from './telemetry.ts'
4
8
  export * from './workers/index.ts'
@@ -0,0 +1 @@
1
+ export const prefix = 'xl1-bridge'
@@ -0,0 +1,12 @@
1
+ import { isDefined } from '@xylabs/sdk-js'
2
+ import type { BullMQOtelOptions } from 'bullmq-otel'
3
+ import { BullMQOtel } from 'bullmq-otel'
4
+
5
+ let telemetry: BullMQOtel | undefined
6
+ const options: BullMQOtelOptions = { enableMetrics: true }
7
+
8
+ export const getTelemetry = () => {
9
+ if (isDefined(telemetry)) return telemetry
10
+ telemetry = new BullMQOtel(options)
11
+ return telemetry
12
+ }
@@ -0,0 +1,40 @@
1
+ import type { Job } from 'bullmq'
2
+ import { Worker } from 'bullmq'
3
+ import type { BullMQOtel } from 'bullmq-otel'
4
+ import type { Redis } from 'ioredis'
5
+
6
+ import { prefix } from '../prefix.ts'
7
+ import type { WorkerDescription } from './WorkerDescription.ts'
8
+
9
+ export type EthToXl1BridgeParentJobData = {}
10
+ export interface EthToXl1BridgeParentJobReturn { }
11
+ export type EthToXl1BridgeParentJob = Job<EthToXl1BridgeParentJobData, EthToXl1BridgeParentJobReturn>
12
+
13
+ const name = 'Bridge Ethereum to XL1'
14
+ const queueName = 'eth-to-xl1-bridge'
15
+ const createWorker = (connection: Redis, telemetry?: BullMQOtel) => {
16
+ const worker = new Worker(
17
+ queueName,
18
+ async (job: EthToXl1BridgeParentJob) => {
19
+ await job.log(`[${job.name}] start`)
20
+ // Parent job has no work other than waiting on children
21
+ await job.log(`[${job.name}] done`)
22
+ return {}
23
+ },
24
+ {
25
+ connection, telemetry, prefix,
26
+ },
27
+ )
28
+
29
+ worker.on('failed', (job, err) => {
30
+ console.error(`[${name}] Job ${job?.id} failed:`, err.message)
31
+ })
32
+
33
+ worker.on('error', (err) => {
34
+ console.error(`[${name}] Worker error:`, err)
35
+ })
36
+ }
37
+
38
+ export const EthToXl1BridgeParent: WorkerDescription = {
39
+ createWorker, name, queueName,
40
+ }
@@ -3,26 +3,30 @@ import { PayloadBuilder } from '@xyo-network/sdk-js'
3
3
  import type { SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
4
4
  import type { Job } from 'bullmq'
5
5
  import { Worker } from 'bullmq'
6
+ import type { BullMQOtel } from 'bullmq-otel'
6
7
  import type { Redis } from 'ioredis'
7
8
 
8
9
  import type { IBridgeServiceCollection } from '../../services/index.ts'
10
+ import { prefix } from '../prefix.ts'
9
11
  import type { WorkerDescription } from './WorkerDescription.ts'
10
12
 
11
- type JobData = { tx: SignedHydratedTransaction }
12
- interface ReturnType {
13
+ export type EthTransactionMonitorJobData = { tx: SignedHydratedTransaction }
14
+ export interface EthTransactionMonitorJobReturn {
13
15
  blockHash: string
14
16
  blockNumber: number
17
+ submissionHash: string
15
18
  }
19
+ export type EthTransactionMonitorJob = Job<EthTransactionMonitorJobData, EthTransactionMonitorJobReturn>
16
20
 
17
21
  const name = 'Monitor Submitted ETH Transaction'
18
22
  const queueName = 'eth-tx-monitor'
19
- const createWorker = (connection: Redis, services?: IBridgeServiceCollection) => {
23
+ const createWorker = (connection: Redis, telemetry?: BullMQOtel, services?: IBridgeServiceCollection) => {
20
24
  const provider = assertEx(services?.provider, () => 'provider service not provided')
21
25
  const stateMap = assertEx(services?.ethTxStateMap, () => 'ethTxStateMap service not provided')
22
26
 
23
27
  const worker = new Worker(
24
28
  queueName,
25
- async (job: Job<JobData, ReturnType>) => {
29
+ async (job: EthTransactionMonitorJob) => {
26
30
  const { tx } = job.data
27
31
  const hash = await PayloadBuilder.hash(tx[0])
28
32
  const state = assertEx(await stateMap.get(hash), () => 'State not found')
@@ -32,9 +36,13 @@ const createWorker = (connection: Redis, services?: IBridgeServiceCollection) =>
32
36
  const { blockHash, blockNumber } = receipt
33
37
  state.confirmationHash = blockHash
34
38
  await stateMap.set(hash, state)
35
- return { blockHash, blockNumber }
39
+ return {
40
+ blockHash, blockNumber, submissionHash,
41
+ }
42
+ },
43
+ {
44
+ connection, telemetry, prefix,
36
45
  },
37
- { connection },
38
46
  )
39
47
 
40
48
  worker.on('failed', (job, err) => {