@xyo-network/chain-bridge 1.20.4 → 1.20.5
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.
- package/dist/node/index.mjs +54 -31
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/modules/EVMLiquidityBridgeTransactionCompletionMonitorSentinel/EVMLiquidityBridgeTransactionCompletionMonitorSentinel.d.ts +2 -3
- package/dist/node/modules/EVMLiquidityBridgeTransactionCompletionMonitorSentinel/EVMLiquidityBridgeTransactionCompletionMonitorSentinel.d.ts.map +1 -1
- package/dist/node/queue/flows/createXl1ToEthBridgeJob/createXl1ToEthBridgeJob.d.ts +3 -1
- package/dist/node/queue/flows/createXl1ToEthBridgeJob/createXl1ToEthBridgeJob.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts +2 -4
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionPreparation.d.ts +2 -4
- package/dist/node/queue/workers/EthTransactionPreparation.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionSubmission.d.ts +2 -4
- package/dist/node/queue/workers/EthTransactionSubmission.d.ts.map +1 -1
- package/dist/node/queue/workers/EthTransactionSubmissionStorage.d.ts +2 -4
- package/dist/node/queue/workers/EthTransactionSubmissionStorage.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts +2 -4
- package/dist/node/queue/workers/Xl1ToEthBridgeParent.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionJobData.d.ts +15 -0
- package/dist/node/queue/workers/Xl1TransactionJobData.d.ts.map +1 -0
- package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts +2 -4
- package/dist/node/queue/workers/Xl1TransactionMonitor.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts +2 -3
- package/dist/node/queue/workers/Xl1TransactionPreparation.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts +2 -4
- package/dist/node/queue/workers/Xl1TransactionSubmission.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.d.ts +2 -4
- package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.d.ts.map +1 -1
- package/dist/node/queue/workers/util/submitEthTransaction.d.ts +3 -2
- package/dist/node/queue/workers/util/submitEthTransaction.d.ts.map +1 -1
- package/dist/node/queue/workers/util/submitXl1Transaction.d.ts +2 -1
- package/dist/node/queue/workers/util/submitXl1Transaction.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.d.ts.map +1 -1
- package/dist/node/services/Xl1TxState.d.ts +2 -0
- package/dist/node/services/Xl1TxState.d.ts.map +1 -1
- package/dist/node/validation/validateSufficientLiquiditySourceAllowance.d.ts +3 -1
- package/dist/node/validation/validateSufficientLiquiditySourceAllowance.d.ts.map +1 -1
- package/dist/node/validation/validateSufficientLiquiditySourceBalance.d.ts +3 -1
- package/dist/node/validation/validateSufficientLiquiditySourceBalance.d.ts.map +1 -1
- package/package.json +18 -19
- package/src/modules/EVMLiquidityBridgeTransactionCompletionMonitorSentinel/EVMLiquidityBridgeTransactionCompletionMonitorSentinel.ts +5 -4
- package/src/queue/flows/createXl1ToEthBridgeJob/createXl1ToEthBridgeJob.ts +23 -9
- package/src/queue/workers/EthTransactionMonitor.ts +2 -1
- package/src/queue/workers/EthTransactionPreparation.ts +8 -6
- package/src/queue/workers/EthTransactionSubmission.ts +4 -5
- package/src/queue/workers/EthTransactionSubmissionStorage.ts +2 -2
- package/src/queue/workers/Xl1ToEthBridgeParent.ts +2 -2
- package/src/queue/workers/Xl1TransactionJobData.ts +12 -0
- package/src/queue/workers/Xl1TransactionMonitor.ts +2 -2
- package/src/queue/workers/Xl1TransactionPreparation.ts +4 -3
- package/src/queue/workers/Xl1TransactionSubmission.ts +7 -8
- package/src/queue/workers/Xl1TransactionSubmissionStorage.ts +2 -1
- package/src/queue/workers/util/submitEthTransaction.ts +10 -3
- package/src/queue/workers/util/submitXl1Transaction.ts +4 -5
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemote.ts +2 -2
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteStatus.ts +3 -2
- package/src/services/Xl1TxState.ts +4 -1
- package/src/validation/validateSufficientLiquiditySourceAllowance.ts +5 -1
- package/src/validation/validateSufficientLiquiditySourceBalance.ts +5 -1
package/dist/node/index.mjs
CHANGED
|
@@ -368,8 +368,12 @@ var validateBridgeTransaction = /* @__PURE__ */ __name(async (signedTxBw, intent
|
|
|
368
368
|
// src/validation/validateSufficientLiquiditySourceAllowance.ts
|
|
369
369
|
import { assertEx as assertEx7, hexToBigInt as hexToBigInt3 } from "@xylabs/sdk-js";
|
|
370
370
|
import { isBridgeIntent } from "@xyo-network/xl1-sdk";
|
|
371
|
-
var validateSufficientLiquiditySourceAllowance = /* @__PURE__ */ __name(async (tx, bridgeableToken, bridge, logger) => {
|
|
372
|
-
const
|
|
371
|
+
var validateSufficientLiquiditySourceAllowance = /* @__PURE__ */ __name(async (tx, offChainPayloads, bridgeableToken, bridge, logger) => {
|
|
372
|
+
const allPayloads = [
|
|
373
|
+
...tx[1],
|
|
374
|
+
...offChainPayloads
|
|
375
|
+
];
|
|
376
|
+
const bridgeIntent = assertEx7(allPayloads.find(isBridgeIntent), () => "No bridge intent found");
|
|
373
377
|
const amount = hexToBigInt3(bridgeIntent.destAmount);
|
|
374
378
|
const liquiditySourceAddress = await bridge.liquiditySource();
|
|
375
379
|
const bridgeAddress = await bridge.getAddress();
|
|
@@ -381,8 +385,12 @@ var validateSufficientLiquiditySourceAllowance = /* @__PURE__ */ __name(async (t
|
|
|
381
385
|
// src/validation/validateSufficientLiquiditySourceBalance.ts
|
|
382
386
|
import { assertEx as assertEx8, hexToBigInt as hexToBigInt4 } from "@xylabs/sdk-js";
|
|
383
387
|
import { isBridgeIntent as isBridgeIntent2 } from "@xyo-network/xl1-sdk";
|
|
384
|
-
var validateSufficientLiquiditySourceBalance = /* @__PURE__ */ __name(async (tx, bridgeableToken, bridge, logger) => {
|
|
385
|
-
const
|
|
388
|
+
var validateSufficientLiquiditySourceBalance = /* @__PURE__ */ __name(async (tx, offChainPayloads, bridgeableToken, bridge, logger) => {
|
|
389
|
+
const allPayloads = [
|
|
390
|
+
...tx[1],
|
|
391
|
+
...offChainPayloads
|
|
392
|
+
];
|
|
393
|
+
const bridgeIntent = assertEx8(allPayloads.find(isBridgeIntent2), () => "No bridge intent found");
|
|
386
394
|
const amount = hexToBigInt4(bridgeIntent.destAmount);
|
|
387
395
|
const liquiditySourceAddress = await bridge.liquiditySource();
|
|
388
396
|
const balance = await bridgeableToken.balanceOf(liquiditySourceAddress);
|
|
@@ -436,21 +444,25 @@ var createWorker2 = /* @__PURE__ */ __name((connection2, telemetry2, services) =
|
|
|
436
444
|
const stateMap = assertEx11(services?.ethTxStateMap, () => "ethTxStateMap service not provided");
|
|
437
445
|
const wallet = assertEx11(services?.wallet, () => "wallet service not provided");
|
|
438
446
|
const worker = new Worker2(queueName2, async (job) => {
|
|
439
|
-
const { tx } = job.data;
|
|
447
|
+
const { tx, offChainPayloads } = job.data;
|
|
440
448
|
const hash = await PayloadBuilder5.hash(tx[0]);
|
|
441
449
|
await job.log(`[${hash}] preparing ETH transaction`);
|
|
442
450
|
await job.log(`[${hash}] validating liquiditySource has sufficient allowance`);
|
|
443
|
-
if (!await validateSufficientLiquiditySourceAllowance(tx, bridgeableToken, bridge, job)) {
|
|
451
|
+
if (!await validateSufficientLiquiditySourceAllowance(tx, offChainPayloads, bridgeableToken, bridge, job)) {
|
|
444
452
|
throw new Error("Liquidity source does not have sufficient allowance for the bridge to execute the transaction");
|
|
445
453
|
}
|
|
446
454
|
await job.log(`[${hash}] validated liquiditySource has sufficient allowance`);
|
|
447
455
|
await job.log(`[${hash}] validating liquiditySource has sufficient balance`);
|
|
448
|
-
if (!await validateSufficientLiquiditySourceBalance(tx, bridgeableToken, bridge, job)) {
|
|
456
|
+
if (!await validateSufficientLiquiditySourceBalance(tx, offChainPayloads, bridgeableToken, bridge, job)) {
|
|
449
457
|
throw new Error("Liquidity source does not have sufficient balance for the bridge to execute the transaction");
|
|
450
458
|
}
|
|
451
459
|
await job.log(`[${hash}] validated liquiditySource has sufficient balance`);
|
|
452
460
|
await job.log(`[${hash}] building ETH transaction`);
|
|
453
|
-
const
|
|
461
|
+
const allPayloads = [
|
|
462
|
+
...tx[1],
|
|
463
|
+
...offChainPayloads
|
|
464
|
+
];
|
|
465
|
+
const bridgeIntent = assertEx11(allPayloads.find(isBridgeIntent3), () => "No bridge intent found");
|
|
454
466
|
const amount = hexToBigInt6(bridgeIntent.destAmount);
|
|
455
467
|
const srcAddress = getAddress(bridgeIntent.srcAddress);
|
|
456
468
|
const destAddress = getAddress(bridgeIntent.destAddress);
|
|
@@ -496,9 +508,13 @@ import { Worker as Worker3 } from "bullmq";
|
|
|
496
508
|
import { assertEx as assertEx12, hexToBigInt as hexToBigInt7, toEthAddress } from "@xylabs/sdk-js";
|
|
497
509
|
import { PayloadBuilder as PayloadBuilder6 } from "@xyo-network/sdk-js";
|
|
498
510
|
import { isBridgeIntent as isBridgeIntent4 } from "@xyo-network/xl1-sdk";
|
|
499
|
-
var submitEthTransaction = /* @__PURE__ */ __name(async (tx,
|
|
511
|
+
var submitEthTransaction = /* @__PURE__ */ __name(async (tx, offChainPayloads, bridge, wallet) => {
|
|
500
512
|
const xl1Transaction = assertEx12(tx[0], () => "No corresponding XL1 transaction found");
|
|
501
|
-
const
|
|
513
|
+
const allPayloads = [
|
|
514
|
+
...tx[1],
|
|
515
|
+
...offChainPayloads
|
|
516
|
+
];
|
|
517
|
+
const bridgeIntent = assertEx12(allPayloads.find(isBridgeIntent4), () => "No bridge intent found");
|
|
502
518
|
const srcAddress = toEthAddress(bridgeIntent.srcAddress);
|
|
503
519
|
const destAddress = toEthAddress(bridgeIntent.destAddress);
|
|
504
520
|
const amount = hexToBigInt7(bridgeIntent.destAmount);
|
|
@@ -509,10 +525,8 @@ var submitEthTransaction = /* @__PURE__ */ __name(async (tx, bridgeableToken, br
|
|
|
509
525
|
}, "submitEthTransaction");
|
|
510
526
|
|
|
511
527
|
// src/queue/workers/util/submitXl1Transaction.ts
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
const offChainPayloads = preparedTx[1].filter((p) => !isAllowedBlockPayload(p));
|
|
515
|
-
const result = await gateway.addTransactionToChain(preparedTx, offChainPayloads);
|
|
528
|
+
var submitXl1Transaction = /* @__PURE__ */ __name(async (preparedTx, offChain = [], gateway) => {
|
|
529
|
+
const result = await gateway.addTransactionToChain(preparedTx, offChain);
|
|
516
530
|
return result;
|
|
517
531
|
}, "submitXl1Transaction");
|
|
518
532
|
|
|
@@ -521,11 +535,10 @@ var name3 = "Submit ETH Transaction";
|
|
|
521
535
|
var queueName3 = "eth-tx-submit";
|
|
522
536
|
var createWorker3 = /* @__PURE__ */ __name((connection2, telemetry2, services) => {
|
|
523
537
|
const bridge = assertEx13(services?.bridge, () => "bridge service not provided");
|
|
524
|
-
const bridgeableToken = assertEx13(services?.bridgeableToken, () => "bridgeableToken service not provided");
|
|
525
538
|
const wallet = assertEx13(services?.wallet, () => "wallet service not provided");
|
|
526
539
|
const stateMap = assertEx13(services?.ethTxStateMap, () => "ethTxStateMap service not provided");
|
|
527
540
|
const worker = new Worker3(queueName3, async (job) => {
|
|
528
|
-
const { tx } = job.data;
|
|
541
|
+
const { tx, offChainPayloads } = job.data;
|
|
529
542
|
const hash = await PayloadBuilder7.hash(tx[0]);
|
|
530
543
|
const state = assertEx13(await stateMap.get(hash), () => `[${hash}] state not found`);
|
|
531
544
|
const { submissionHash: existingSubmissionHash } = state;
|
|
@@ -536,7 +549,7 @@ var createWorker3 = /* @__PURE__ */ __name((connection2, telemetry2, services) =
|
|
|
536
549
|
};
|
|
537
550
|
}
|
|
538
551
|
await job.log(`[${hash}] Submitting ETH tx`);
|
|
539
|
-
const submissionHash = assertEx13(await submitEthTransaction(tx,
|
|
552
|
+
const submissionHash = assertEx13(await submitEthTransaction(tx, offChainPayloads, bridge, wallet), () => `[${hash}] submissionHash not found in receipt`);
|
|
540
553
|
await job.log(`[${hash}] Submitted ETH tx and received submission response hash ${submissionHash}`);
|
|
541
554
|
return {
|
|
542
555
|
submissionHash
|
|
@@ -694,12 +707,13 @@ var queueName7 = "xl1-tx-prepare";
|
|
|
694
707
|
var createWorker7 = /* @__PURE__ */ __name((connection2, telemetry2, services) => {
|
|
695
708
|
const stateMap = assertEx16(services?.xl1TxStateMap, () => "xl1TxStateMap service not provided");
|
|
696
709
|
const worker = new Worker7(queueName7, async (job) => {
|
|
697
|
-
const { tx } = job.data;
|
|
710
|
+
const { tx, offChainPayloads = [] } = job.data;
|
|
698
711
|
const hash = await PayloadBuilder10.hash(tx[0]);
|
|
699
712
|
await job.log(`[${hash}] preparing XL1 transaction`);
|
|
700
713
|
const preparedTx = tx;
|
|
701
714
|
await job.log(`[${hash}] storing XL1 preparedTx`);
|
|
702
715
|
await stateMap.set(hash, {
|
|
716
|
+
offChainPayloads,
|
|
703
717
|
preparedTx
|
|
704
718
|
});
|
|
705
719
|
await job.log(`[${hash}] stored XL1 preparedTx`);
|
|
@@ -738,16 +752,16 @@ var createWorker8 = /* @__PURE__ */ __name((connection2, telemetry2, services) =
|
|
|
738
752
|
const { tx } = job.data;
|
|
739
753
|
const hash = await PayloadBuilder11.hash(tx[0]);
|
|
740
754
|
const state = assertEx17(await stateMap.get(hash), () => `[${hash}] state not found`);
|
|
741
|
-
const preparedTx =
|
|
742
|
-
const { submissionHash: existingSubmissionHash } = state;
|
|
755
|
+
const { preparedTx, offChainPayloads = [], submissionHash: existingSubmissionHash } = state;
|
|
743
756
|
if (isDefined9(existingSubmissionHash)) {
|
|
744
757
|
await job.log(`[${hash}] Tx already submitted with submission response hash ${existingSubmissionHash}`);
|
|
745
758
|
return {
|
|
746
759
|
submissionHash: existingSubmissionHash
|
|
747
760
|
};
|
|
748
761
|
}
|
|
762
|
+
const txToSubmit = assertEx17(preparedTx, () => `[${hash}] preparedTx not found`);
|
|
749
763
|
await job.log(`[${hash}] Submitting XL1 tx`);
|
|
750
|
-
const [submissionHash] = await submitXl1Transaction(
|
|
764
|
+
const [submissionHash] = await submitXl1Transaction(txToSubmit, offChainPayloads, gateway);
|
|
751
765
|
await job.log(`[${hash}] Submitted XL1 tx`);
|
|
752
766
|
return {
|
|
753
767
|
submissionHash
|
|
@@ -827,14 +841,15 @@ var getJobIdForXl1ToEthBridgeJob = /* @__PURE__ */ __name(async (tx) => {
|
|
|
827
841
|
}, "getJobIdForXl1ToEthBridgeJob");
|
|
828
842
|
|
|
829
843
|
// src/queue/flows/createXl1ToEthBridgeJob/createXl1ToEthBridgeJob.ts
|
|
830
|
-
var createXl1ToEthBridgeJob = /* @__PURE__ */ __name(async (flowProducer2, tx) => {
|
|
844
|
+
var createXl1ToEthBridgeJob = /* @__PURE__ */ __name(async (flowProducer2, tx, offChainPayloads = []) => {
|
|
831
845
|
const jobId = await getJobIdForXl1ToEthBridgeJob(tx);
|
|
832
846
|
const flow = await flowProducer2.add({
|
|
833
847
|
// Step 0 (runs first as parent job)
|
|
834
848
|
name: Xl1ToEthBridgeParent.name,
|
|
835
849
|
queueName: Xl1ToEthBridgeParent.queueName,
|
|
836
850
|
data: {
|
|
837
|
-
tx
|
|
851
|
+
tx,
|
|
852
|
+
offChainPayloads
|
|
838
853
|
},
|
|
839
854
|
opts: {
|
|
840
855
|
jobId
|
|
@@ -877,7 +892,8 @@ var createXl1ToEthBridgeJob = /* @__PURE__ */ __name(async (flowProducer2, tx) =
|
|
|
877
892
|
name: EthTransactionSubmission.name,
|
|
878
893
|
queueName: EthTransactionSubmission.queueName,
|
|
879
894
|
data: {
|
|
880
|
-
tx
|
|
895
|
+
tx,
|
|
896
|
+
offChainPayloads
|
|
881
897
|
},
|
|
882
898
|
opts: {
|
|
883
899
|
jobId
|
|
@@ -888,7 +904,8 @@ var createXl1ToEthBridgeJob = /* @__PURE__ */ __name(async (flowProducer2, tx) =
|
|
|
888
904
|
name: EthTransactionPreparation.name,
|
|
889
905
|
queueName: EthTransactionPreparation.queueName,
|
|
890
906
|
data: {
|
|
891
|
-
tx
|
|
907
|
+
tx,
|
|
908
|
+
offChainPayloads
|
|
892
909
|
},
|
|
893
910
|
opts: {
|
|
894
911
|
jobId,
|
|
@@ -947,7 +964,8 @@ var createXl1ToEthBridgeJob = /* @__PURE__ */ __name(async (flowProducer2, tx) =
|
|
|
947
964
|
name: Xl1TransactionPreparation.name,
|
|
948
965
|
queueName: Xl1TransactionPreparation.queueName,
|
|
949
966
|
data: {
|
|
950
|
-
tx
|
|
967
|
+
tx,
|
|
968
|
+
offChainPayloads
|
|
951
969
|
},
|
|
952
970
|
opts: {
|
|
953
971
|
jobId,
|
|
@@ -1227,8 +1245,7 @@ var makeBridgeToRemoteRoute = /* @__PURE__ */ __name((config) => {
|
|
|
1227
1245
|
const singedHydratedTransaction = [
|
|
1228
1246
|
signedTxBw,
|
|
1229
1247
|
[
|
|
1230
|
-
transfer
|
|
1231
|
-
bridgeIntent
|
|
1248
|
+
transfer
|
|
1232
1249
|
]
|
|
1233
1250
|
];
|
|
1234
1251
|
const existingFlow = await getXl1ToEthBridgeJob(flowProducer2, singedHydratedTransaction);
|
|
@@ -1236,7 +1253,9 @@ var makeBridgeToRemoteRoute = /* @__PURE__ */ __name((config) => {
|
|
|
1236
1253
|
res.status(200).send();
|
|
1237
1254
|
return;
|
|
1238
1255
|
}
|
|
1239
|
-
await createXl1ToEthBridgeJob(flowProducer2, singedHydratedTransaction
|
|
1256
|
+
await createXl1ToEthBridgeJob(flowProducer2, singedHydratedTransaction, [
|
|
1257
|
+
bridgeIntent
|
|
1258
|
+
]);
|
|
1240
1259
|
const srcConfirmation = await PayloadBuilder14.hash(signedTxBw);
|
|
1241
1260
|
const bridgeCommonFieldsZod = z2.object({}).extend(BridgeSourceObservationFieldsZod.shape);
|
|
1242
1261
|
const bridgeCommonFields = bridgeCommonFieldsZod.parse(bridgeIntent);
|
|
@@ -1344,9 +1363,13 @@ var makeBridgeToRemoteStatusRoute = /* @__PURE__ */ __name((config) => {
|
|
|
1344
1363
|
const result = [];
|
|
1345
1364
|
const queues = getXl1ToEthQueues(config);
|
|
1346
1365
|
const statusQueueJobs = await getStatusQueueJobs(queues, jobId);
|
|
1347
|
-
const tx = statusQueueJobs.xl1ToEthBridgeParentJob?.data
|
|
1366
|
+
const { tx, offChainPayloads = [] } = statusQueueJobs.xl1ToEthBridgeParentJob?.data ?? {};
|
|
1348
1367
|
if (!tx) return res.sendStatus(404);
|
|
1349
|
-
const
|
|
1368
|
+
const allPayloads = [
|
|
1369
|
+
...tx[1],
|
|
1370
|
+
...offChainPayloads
|
|
1371
|
+
];
|
|
1372
|
+
const bridgeIntent = allPayloads.find(isBridgeIntent5);
|
|
1350
1373
|
if (!bridgeIntent) return res.sendStatus(404);
|
|
1351
1374
|
result[0] = asBridgeIntent(PayloadBuilder15.omitMeta(bridgeIntent));
|
|
1352
1375
|
const { xl1TransactionMonitorJob } = statusQueueJobs;
|